aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2021-09-18 08:13:55 -0400
committerKen Brown <kbrown@cornell.edu>2021-09-18 08:40:11 -0400
commite5fcb021cc9dcb1f19d45030457be86b4a226e65 (patch)
treeb5ce17d5f382dff541d1805cb7ed91fd31ca5d38 /winsup
parent9b0841aa789e74b6778744b89af76b60bd1a78bc (diff)
downloadnewlib-e5fcb021cc9dcb1f19d45030457be86b4a226e65.zip
newlib-e5fcb021cc9dcb1f19d45030457be86b4a226e65.tar.gz
newlib-e5fcb021cc9dcb1f19d45030457be86b4a226e65.tar.bz2
Cygwin: allow open_setup to fail
Convert fhandler_base::open_setup to a (virtual) method that returns a bool result. For the moment, it and its overrides always return true.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/fhandler.cc3
-rw-r--r--winsup/cygwin/fhandler.h10
-rw-r--r--winsup/cygwin/fhandler_console.cc4
-rw-r--r--winsup/cygwin/fhandler_pipe.cc9
-rw-r--r--winsup/cygwin/fhandler_tty.cc8
5 files changed, 20 insertions, 14 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 9dfe70b..1af469e 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -789,9 +789,10 @@ fhandler_base::fd_reopen (int, mode_t)
return NULL;
}
-void
+bool
fhandler_base::open_setup (int)
{
+ return true;
}
/* states:
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 61113e6..3471e95 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -355,7 +355,7 @@ class fhandler_base
int open_null (int flags);
virtual int open (int, mode_t);
virtual fhandler_base *fd_reopen (int, mode_t);
- virtual void open_setup (int flags);
+ virtual bool open_setup (int flags);
void set_unique_id (int64_t u) { unique_id = u; }
void set_unique_id () { NtAllocateLocallyUniqueId ((PLUID) &unique_id); }
@@ -1206,7 +1206,7 @@ public:
select_record *select_except (select_stuff *);
char *get_proc_fd_name (char *buf);
int open (int flags, mode_t mode = 0);
- void open_setup (int flags);
+ bool open_setup (int flags);
void fixup_after_fork (HANDLE);
int dup (fhandler_base *child, int);
void set_close_on_exec (bool val);
@@ -2132,7 +2132,7 @@ private:
bool use_archetype () const {return true;}
int open (int flags, mode_t mode);
- void open_setup (int flags);
+ bool open_setup (int flags);
int dup (fhandler_base *, int);
void __reg3 read (void *ptr, size_t& len);
@@ -2300,7 +2300,7 @@ class fhandler_pty_slave: public fhandler_pty_common
HANDLE& get_handle_nat () { return io_handle_nat; }
int open (int flags, mode_t mode = 0);
- void open_setup (int flags);
+ bool open_setup (int flags);
ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len);
int init (HANDLE, DWORD, mode_t);
@@ -2399,7 +2399,7 @@ public:
void doecho (const void *str, DWORD len);
int accept_input ();
int open (int flags, mode_t mode = 0);
- void open_setup (int flags);
+ bool open_setup (int flags);
ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len);
int close ();
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index e00f2cd..ee862b1 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1366,13 +1366,13 @@ fhandler_console::open (int flags, mode_t)
return 1;
}
-void
+bool
fhandler_console::open_setup (int flags)
{
set_flags ((flags & ~O_TEXT) | O_BINARY);
if (myself->set_ctty (this, flags) && !myself->cygstarted)
init_console_handler (true);
- fhandler_base::open_setup (flags);
+ return fhandler_base::open_setup (flags);
}
int
diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc
index 73ace3a..590ecf6 100644
--- a/winsup/cygwin/fhandler_pipe.cc
+++ b/winsup/cygwin/fhandler_pipe.cc
@@ -191,10 +191,11 @@ out:
return 0;
}
-void
+bool
fhandler_pipe::open_setup (int flags)
{
- fhandler_base::open_setup (flags);
+ if (!fhandler_base::open_setup (flags))
+ goto err;
if (get_dev () == FH_PIPER && !read_mtx)
{
SECURITY_ATTRIBUTES *sa = sec_none_cloexec (flags);
@@ -211,6 +212,10 @@ fhandler_pipe::open_setup (int flags)
}
if (get_dev () == FH_PIPEW && !query_hdl)
set_pipe_non_blocking (is_nonblocking ());
+ return true;
+
+err:
+ return false;
}
off_t
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 1ea9a47..05fe534 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -964,13 +964,13 @@ err_no_msg:
return 0;
}
-void
+bool
fhandler_pty_slave::open_setup (int flags)
{
set_flags ((flags & ~O_TEXT) | O_BINARY);
myself->set_ctty (this, flags);
report_tty_counts (this, "opened", "");
- fhandler_base::open_setup (flags);
+ return fhandler_base::open_setup (flags);
}
void
@@ -1947,14 +1947,14 @@ fhandler_pty_master::open (int flags, mode_t)
return 1;
}
-void
+bool
fhandler_pty_master::open_setup (int flags)
{
set_flags ((flags & ~O_TEXT) | O_BINARY);
char buf[sizeof ("opened pty master for ptyNNNNNNNNNNN")];
__small_sprintf (buf, "opened pty master for pty%d", get_minor ());
report_tty_counts (this, buf, "");
- fhandler_base::open_setup (flags);
+ return fhandler_base::open_setup (flags);
}
off_t