* Use new unified status_flag accessor methods from classes fhandler_*,
tty_min, mtinfo and fs_info thoroughout. * fhandler.h: Redefine all set_close_on_exec methods to take a bool argument. (enum conn_state): Rename from connect_state. (class fhandler_base): Rename some status flags to align with accessor method names. Drop encoded flag entirely. Unify status accessor methods. Const'ify all read accessor methods. (class fhandler_socket): Ditto. (class fhandler_dev_raw): Ditto. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() instead of evaluating FATness of file system here. (fhandler_disk_file::opendir): Drop call to set_encoded(). (fhandler_disk_file::readdir): Use pc.isencoded() directly. * mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. * path.cc (fsinfo_cnt): Add. (fs_info::update): Accomodate class changes. Evaluate file system name specific flags right here. Add thread safety for reading and writing global fsinfo array. * path.h (enum path_types): Drop values for flags kept in fs already. (struct fs_info): Move status informatin into private struct type status_flags. Add accessor methods. Remove path and file system name string arrays in favor of status bits. (class path_conv): Use new fs_info status information where appropriate. (path_conf::fs_has_ea): Rename from fs_fast_ea. (path_conf::fs_has_acls): New method. (path_conf::root_dir): Remove. (path_conf::volname): Remove. * syscalls (statfs): Evaluate root dir locally. * tty.h (class tty_min): Unify status accessor methods. Const'ify all read accessor methods.
This commit is contained in:
		| @@ -1,3 +1,38 @@ | ||||
| 2004-04-10  Corinna Vinschen  <corinna@vinschen.de> | ||||
|  | ||||
| 	* Use new unified status_flag accessor methods from classes fhandler_*, | ||||
| 	tty_min, mtinfo and fs_info thoroughout. | ||||
| 	* fhandler.h: Redefine all set_close_on_exec methods to take a bool | ||||
| 	argument. | ||||
| 	(enum conn_state): Rename from connect_state. | ||||
| 	(class fhandler_base): Rename some status flags to align with | ||||
| 	accessor method names.  Drop encoded flag entirely.  Unify status | ||||
| 	accessor methods.  Const'ify all read accessor methods. | ||||
| 	(class fhandler_socket): Ditto. | ||||
| 	(class fhandler_dev_raw): Ditto. | ||||
| 	* fhandler_disk_file.cc (fhandler_base::fstat_fs): Use fs.fs_is_fat() | ||||
| 	instead of evaluating FATness of file system here. | ||||
| 	(fhandler_disk_file::opendir): Drop call to set_encoded(). | ||||
| 	(fhandler_disk_file::readdir): Use pc.isencoded() directly. | ||||
| 	* mtinfo.h (class mtinfo_drive): Const'ify all read accessor methods. | ||||
| 	* path.cc (fsinfo_cnt): Add. | ||||
| 	(fs_info::update): Accomodate class changes. Evaluate file system | ||||
| 	name specific flags right here. Add thread safety for reading and | ||||
| 	writing global fsinfo array. | ||||
| 	* path.h (enum path_types): Drop values for flags kept in fs already. | ||||
| 	(struct fs_info): Move status informatin into private struct type | ||||
| 	status_flags.  Add accessor methods. Remove path and file system | ||||
| 	name string arrays in favor of status bits. | ||||
| 	(class path_conv): Use new fs_info status information where | ||||
| 	appropriate. | ||||
| 	(path_conf::fs_has_ea): Rename from fs_fast_ea. | ||||
| 	(path_conf::fs_has_acls): New method. | ||||
| 	(path_conf::root_dir): Remove. | ||||
| 	(path_conf::volname): Remove. | ||||
| 	* syscalls (statfs): Evaluate root dir locally. | ||||
| 	* tty.h (class tty_min): Unify status accessor methods.  Const'ify | ||||
| 	all read accessor methods. | ||||
|  | ||||
| 2004-04-09  Thomas Pfaff  <tpfaff@gmx.net> | ||||
|  | ||||
| 	* thread.h (pthread::init_mainthread): Remove parameter forked. | ||||
|   | ||||
| @@ -484,7 +484,7 @@ dtable::dup_worker (fhandler_base *oldfh) | ||||
|       return NULL; | ||||
|     } | ||||
|  | ||||
|   newfh->set_close_on_exec_flag (0); | ||||
|   newfh->close_on_exec (false); | ||||
|   MALLOC_CHECK; | ||||
|   debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (), oldfh->get_io_handle (), newfh->get_io_handle ()); | ||||
|   return newfh; | ||||
| @@ -639,7 +639,7 @@ dtable::fixup_before_exec (DWORD target_proc_id) | ||||
|   lock (); | ||||
|   fhandler_base *fh; | ||||
|   for (size_t i = 0; i < size; i++) | ||||
|     if ((fh = fds[i]) != NULL && !fh->get_close_on_exec ()) | ||||
|     if ((fh = fds[i]) != NULL && !fh->close_on_exec ()) | ||||
|       { | ||||
| 	debug_printf ("fd %d (%s)", i, fh->get_name ()); | ||||
| 	fh->fixup_before_fork_exec (target_proc_id); | ||||
| @@ -668,7 +668,7 @@ dtable::fixup_after_exec () | ||||
|     if ((fh = fds[i]) != NULL) | ||||
|       { | ||||
| 	fh->clear_readahead (); | ||||
| 	if (fh->get_close_on_exec ()) | ||||
| 	if (fh->close_on_exec ()) | ||||
| 	  { | ||||
| 	    if (fh->archetype) | ||||
| 	      fh->close (); | ||||
| @@ -693,7 +693,7 @@ dtable::fixup_after_fork (HANDLE parent) | ||||
|   for (size_t i = 0; i < size; i++) | ||||
|     if ((fh = fds[i]) != NULL) | ||||
|       { | ||||
| 	if (fh->get_close_on_exec () || fh->get_need_fork_fixup ()) | ||||
| 	if (fh->close_on_exec () || fh->need_fork_fixup ()) | ||||
| 	  { | ||||
| 	    debug_printf ("fd %d (%s)", i, fh->get_name ()); | ||||
| 	    fh->fixup_after_fork (parent); | ||||
| @@ -727,7 +727,7 @@ dtable::vfork_child_dup () | ||||
|     if (not_open (i)) | ||||
|       continue; | ||||
|     else if ((newtable[i] = dup_worker (fds[i])) != NULL) | ||||
|       newtable[i]->set_close_on_exec (fds[i]->get_close_on_exec ()); | ||||
|       newtable[i]->set_close_on_exec (fds[i]->close_on_exec ()); | ||||
|     else | ||||
|       { | ||||
| 	res = 0; | ||||
| @@ -783,7 +783,7 @@ dtable::vfork_child_fixup () | ||||
|     if ((fh = fds[i]) != NULL) | ||||
|       { | ||||
| 	fh->clear_readahead (); | ||||
| 	if (!fh->archetype && fh->get_close_on_exec ()) | ||||
| 	if (!fh->archetype && fh->close_on_exec ()) | ||||
| 	  release (i); | ||||
| 	else | ||||
| 	  { | ||||
|   | ||||
| @@ -180,8 +180,8 @@ fhandler_base::set_flags (int flags, int supplied_bin) | ||||
|   debug_printf ("flags %p, supplied_bin %p", flags, supplied_bin); | ||||
|   if ((bin = flags & (O_BINARY | O_TEXT))) | ||||
|     debug_printf ("O_TEXT/O_BINARY set in flags %p", bin); | ||||
|   else if (get_r_binset () && get_w_binset ()) | ||||
|     bin = get_r_binary () ? O_BINARY : O_TEXT;	// FIXME: Not quite right | ||||
|   else if (rbinset () && wbinset ()) | ||||
|     bin = rbinary () ? O_BINARY : O_TEXT;	// FIXME: Not quite right | ||||
|   else if ((fmode = get_default_fmode (flags)) & O_BINARY) | ||||
|     bin = O_BINARY; | ||||
|   else if (fmode & O_TEXT) | ||||
| @@ -189,14 +189,14 @@ fhandler_base::set_flags (int flags, int supplied_bin) | ||||
|   else if (supplied_bin) | ||||
|     bin = supplied_bin; | ||||
|   else | ||||
|     bin = get_w_binary () || get_r_binary () || (binmode != O_TEXT) | ||||
|     bin = wbinary () || rbinary () || (binmode != O_TEXT) | ||||
| 	  ? O_BINARY : O_TEXT; | ||||
|  | ||||
|   openflags = flags | bin; | ||||
|  | ||||
|   bin &= O_BINARY; | ||||
|   set_r_binary (bin); | ||||
|   set_w_binary (bin); | ||||
|   rbinary (bin ? true : false); | ||||
|   wbinary (bin ? true : false); | ||||
|   syscall_printf ("filemode set to %s", bin ? "binary" : "text"); | ||||
| } | ||||
|  | ||||
| @@ -434,7 +434,7 @@ fhandler_base::open (int flags, mode_t mode) | ||||
|   SECURITY_ATTRIBUTES sa = sec_none; | ||||
|   security_descriptor sd; | ||||
|  | ||||
|   syscall_printf ("(%s, %p) query_open %d", get_win32_name (), flags, get_query_open ()); | ||||
|   syscall_printf ("(%s, %p) query_open %d", get_win32_name (), flags, query_open ()); | ||||
|  | ||||
|   if (get_win32_name () == NULL) | ||||
|     { | ||||
| @@ -442,8 +442,8 @@ fhandler_base::open (int flags, mode_t mode) | ||||
|       goto done; | ||||
|     } | ||||
|  | ||||
|   if (get_query_open ()) | ||||
|     access = get_query_open () == query_read_control ? READ_CONTROL : 0; | ||||
|   if (query_open ()) | ||||
|     access = (query_open () == query_read_control ? READ_CONTROL : 0); | ||||
|   else if (get_major () == DEV_TAPE_MAJOR) | ||||
|     access = GENERIC_READ | GENERIC_WRITE; | ||||
|   else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY) | ||||
| @@ -475,7 +475,7 @@ fhandler_base::open (int flags, mode_t mode) | ||||
|     creation_distribution = CREATE_NEW; | ||||
|  | ||||
|   if (flags & O_APPEND) | ||||
|     set_append_p (); | ||||
|     append_mode (true); | ||||
|  | ||||
|   /* These flags are host dependent. */ | ||||
|   shared = wincap.shared (); | ||||
| @@ -498,7 +498,7 @@ fhandler_base::open (int flags, mode_t mode) | ||||
|   /* CreateFile() with dwDesiredAccess == 0 when called on remote | ||||
|      share returns some handle, even if file doesn't exist. This code | ||||
|      works around this bug. */ | ||||
|   if (get_query_open () && isremote () && | ||||
|   if (query_open () && isremote () && | ||||
|       creation_distribution == OPEN_EXISTING && !pc.exists ()) | ||||
|     { | ||||
|       set_errno (ENOENT); | ||||
| @@ -526,13 +526,13 @@ fhandler_base::open (int flags, mode_t mode) | ||||
| 	  else if (flags & (O_WRONLY | O_RDWR)) | ||||
| 	    set_errno (EISDIR); | ||||
| 	  else | ||||
| 	    set_nohandle (true); | ||||
| 	    nohandle (true); | ||||
| 	} | ||||
|       else if (GetLastError () == ERROR_INVALID_HANDLE) | ||||
| 	set_errno (ENOENT); | ||||
|       else | ||||
| 	__seterrno (); | ||||
|       if (!get_nohandle ()) | ||||
|       if (!nohandle ()) | ||||
| 	goto done; | ||||
|    } | ||||
|  | ||||
| @@ -597,7 +597,7 @@ fhandler_base::read (void *in_ptr, size_t& len) | ||||
|   else | ||||
|     len = copied_chars; | ||||
|  | ||||
|   if (get_r_binary () || len <= 0) | ||||
|   if (rbinary () || len <= 0) | ||||
|     goto out; | ||||
|  | ||||
|   /* Scan buffer and turn \r\n into \n */ | ||||
| @@ -660,8 +660,7 @@ out: | ||||
|   if (need_signal) | ||||
|     SetEvent (read_state); | ||||
|  | ||||
|   debug_printf ("returning %d, %s mode", len, | ||||
| 		get_r_binary () ? "binary" : "text"); | ||||
|   debug_printf ("returning %d, %s mode", len, rbinary () ? "binary" : "text"); | ||||
|   return; | ||||
| } | ||||
|  | ||||
| @@ -670,15 +669,15 @@ fhandler_base::write (const void *ptr, size_t len) | ||||
| { | ||||
|   int res; | ||||
|  | ||||
|   if (get_append_p ()) | ||||
|   if (append_mode ()) | ||||
|     SetFilePointer (get_output_handle (), 0, 0, FILE_END); | ||||
|   else if (get_did_lseek ()) | ||||
|   else if (did_lseek ()) | ||||
|     { | ||||
|       _off64_t actual_length, current_position; | ||||
|       DWORD size_high = 0; | ||||
|       LONG pos_high = 0; | ||||
|  | ||||
|       set_did_lseek (false); /* don't do it again */ | ||||
|       did_lseek (false); /* don't do it again */ | ||||
|  | ||||
|       actual_length = GetFileSize (get_output_handle (), &size_high); | ||||
|       actual_length += ((_off64_t) size_high) << 32; | ||||
| @@ -745,7 +744,7 @@ fhandler_base::write (const void *ptr, size_t len) | ||||
| 	} | ||||
|     } | ||||
|  | ||||
|   if (get_w_binary ()) | ||||
|   if (wbinary ()) | ||||
|     { | ||||
|       debug_printf ("binary write"); | ||||
|       res = raw_write (ptr, len); | ||||
| @@ -970,7 +969,7 @@ fhandler_base::lseek (_off64_t offset, int whence) | ||||
|  | ||||
|       /* When next we write(), we will check to see if *this* seek went beyond | ||||
| 	 the end of the file, and back-seek and fill with zeros if so - DJ */ | ||||
|       set_did_lseek (true); | ||||
|       did_lseek (true); | ||||
|  | ||||
|       /* If this was a SEEK_CUR with offset 0, we still might have | ||||
| 	 readahead that we have to take into account when calculating | ||||
| @@ -988,7 +987,7 @@ fhandler_base::close () | ||||
|   int res = -1; | ||||
|  | ||||
|   syscall_printf ("closing '%s' handle %p", get_name (), get_handle ()); | ||||
|   if (get_nohandle () || CloseHandle (get_handle ())) | ||||
|   if (nohandle () || CloseHandle (get_handle ())) | ||||
|     res = 0; | ||||
|   else | ||||
|     { | ||||
| @@ -1109,7 +1108,7 @@ fhandler_base::init (HANDLE f, DWORD a, mode_t bin) | ||||
|     flags = O_RDWR; | ||||
|   set_flags (flags | bin); | ||||
|   set_open_status (); | ||||
|   debug_printf ("created new fhandler_base for handle %p, bin %d", f, get_r_binary ()); | ||||
|   debug_printf ("created new fhandler_base for handle %p, bin %d", f, rbinary ()); | ||||
| } | ||||
|  | ||||
| void | ||||
| @@ -1124,7 +1123,7 @@ fhandler_base::dup (fhandler_base *child) | ||||
|   debug_printf ("in fhandler_base dup"); | ||||
|  | ||||
|   HANDLE nh; | ||||
|   if (!get_nohandle ()) | ||||
|   if (!nohandle ()) | ||||
|     { | ||||
|       if (!DuplicateHandle (hMainProc, get_handle (), hMainProc, &nh, 0, TRUE, | ||||
| 			    DUPLICATE_SAME_ACCESS)) | ||||
| @@ -1148,10 +1147,10 @@ int fhandler_base::fcntl (int cmd, void *arg) | ||||
|   switch (cmd) | ||||
|     { | ||||
|     case F_GETFD: | ||||
|       res = get_close_on_exec () ? FD_CLOEXEC : 0; | ||||
|       res = close_on_exec () ? FD_CLOEXEC : 0; | ||||
|       break; | ||||
|     case F_SETFD: | ||||
|       set_close_on_exec ((int) arg); | ||||
|       set_close_on_exec (((int) arg & FD_CLOEXEC) ? 1 : 0); | ||||
|       res = 0; | ||||
|       break; | ||||
|     case F_GETFL: | ||||
| @@ -1320,9 +1319,9 @@ void | ||||
| fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name) | ||||
| { | ||||
|   HANDLE oh = h; | ||||
|   if (/* !is_socket () && */ !get_close_on_exec ()) | ||||
|   if (/* !is_socket () && */ !close_on_exec ()) | ||||
|     debug_printf ("handle %p already opened", h); | ||||
|   else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !get_close_on_exec (), | ||||
|   else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !close_on_exec (), | ||||
| 			     DUPLICATE_SAME_ACCESS)) | ||||
|     system_printf ("%s - %E, handle %s<%p>", get_name (), name, h); | ||||
|   else if (oh != h) | ||||
| @@ -1330,11 +1329,11 @@ fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name) | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_base::set_close_on_exec (int val) | ||||
| fhandler_base::set_close_on_exec (bool val) | ||||
| { | ||||
|   if (!get_nohandle ()) | ||||
|   if (!nohandle ()) | ||||
|     set_no_inheritance (io_handle, val); | ||||
|   set_close_on_exec_flag (val); | ||||
|   close_on_exec (val); | ||||
|   debug_printf ("set close_on_exec for %s to %d", get_name (), val); | ||||
| } | ||||
|  | ||||
| @@ -1342,7 +1341,7 @@ void | ||||
| fhandler_base::fixup_after_fork (HANDLE parent) | ||||
| { | ||||
|   debug_printf ("inheriting '%s' from parent", get_name ()); | ||||
|   if (!get_nohandle ()) | ||||
|   if (!nohandle ()) | ||||
|     fork_fixup (parent, io_handle, "io_handle"); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -36,7 +36,7 @@ typedef struct __DIR DIR; | ||||
| struct dirent; | ||||
| struct iovec; | ||||
|  | ||||
| enum connect_state | ||||
| enum conn_state | ||||
| { | ||||
|   unconnected = 0, | ||||
|   connect_pending = 1, | ||||
| @@ -77,15 +77,13 @@ class fhandler_base | ||||
|     unsigned rbinset            : 1; /* binary read mode explicitly set */ | ||||
|     unsigned wbinary            : 1; /* binary write mode */ | ||||
|     unsigned wbinset            : 1; /* binary write mode explicitly set */ | ||||
|     unsigned no_handle          : 1; /* No handle associated with fhandler. */ | ||||
|     unsigned async_io           : 1; /* async I/O */ | ||||
|     unsigned nohandle           : 1; /* No handle associated with fhandler. */ | ||||
|     unsigned uninterruptible_io : 1; /* Set if I/O should be uninterruptible. */ | ||||
|     unsigned append_mode        : 1; /* always append */ | ||||
|     unsigned lseeked            : 1; /* set when lseek is called as a flag that | ||||
|     unsigned did_lseek          : 1; /* set when lseek is called as a flag that | ||||
| 					_write should check if we've moved | ||||
| 					beyond EOF, zero filling or making | ||||
| 					file sparse if so. */ | ||||
|     unsigned encoded            : 1; /* native path is encoded */ | ||||
|     unsigned query_open         : 2; /* open file without requesting either | ||||
|     					read or write access */ | ||||
|     unsigned close_on_exec      : 1; /* close-on-exec */ | ||||
| @@ -93,10 +91,9 @@ class fhandler_base | ||||
|  | ||||
|    public: | ||||
|     status_flags () : | ||||
|       rbinary (0), rbinset (0), wbinary (0), wbinset (0), no_handle (0), | ||||
|       async_io (0), uninterruptible_io (0), append_mode (0), lseeked (0), | ||||
|       encoded (0), query_open (no_query), close_on_exec (0), | ||||
|       need_fork_fixup (0) | ||||
|       rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0), | ||||
|       uninterruptible_io (0), append_mode (0), did_lseek (0), | ||||
|       query_open (no_query), close_on_exec (0), need_fork_fixup (0) | ||||
|       {} | ||||
|   } status, open_status; | ||||
|  | ||||
| @@ -148,28 +145,20 @@ class fhandler_base | ||||
|   int get_access () const { return access; } | ||||
|   void set_access (int x) { access = x; } | ||||
|  | ||||
|   bool get_async () { return status.async_io; } | ||||
|   void set_async (int x) { status.async_io = (x ? 1 : 0); } | ||||
|  | ||||
|   int get_flags () { return openflags; } | ||||
|   void set_flags (int x, int supplied_bin = 0); | ||||
|  | ||||
|   bool is_nonblocking (); | ||||
|   void set_nonblocking (int yes); | ||||
|  | ||||
|   bool get_w_binary () { return status.wbinset ? status.wbinary : 1; } | ||||
|   bool get_r_binary () { return status.rbinset ? status.rbinary : 1; } | ||||
|   bool wbinary () const { return status.wbinset ? status.wbinary : 1; } | ||||
|   bool rbinary () const { return status.rbinset ? status.rbinary : 1; } | ||||
|  | ||||
|   bool get_w_binset () { return status.wbinset; } | ||||
|   bool get_r_binset () { return status.rbinset; } | ||||
|   bool wbinset () const { return status.wbinset; } | ||||
|   bool rbinset () const { return status.rbinset; } | ||||
|  | ||||
|   void set_w_binary (int b) {status.wbinary = (b ? 1 : 0); status.wbinset = 1;} | ||||
|   void set_r_binary (int b) {status.rbinary = (b ? 1 : 0); status.rbinset = 1;} | ||||
|   void clear_w_binary () { status.wbinary = 0; status.wbinset = 0; } | ||||
|   void clear_r_binary () { status.rbinary = 0; status.rbinset = 0; } | ||||
|  | ||||
|   bool get_nohandle () { return status.no_handle; } | ||||
|   void set_nohandle (bool x) { status.no_handle = x; } | ||||
|   void wbinary (bool b) {status.wbinary = b; status.wbinset = 1;} | ||||
|   void rbinary (bool b) {status.rbinary = b; status.rbinset = 1;} | ||||
|  | ||||
|   void set_open_status () {open_status = status;} | ||||
|   void reset_to_open_binmode () | ||||
| @@ -179,47 +168,47 @@ class fhandler_base | ||||
| 		   ? O_BINARY : O_TEXT)); | ||||
|   } | ||||
|  | ||||
|   bool nohandle () const { return status.nohandle; } | ||||
|   void nohandle (bool x) { status.nohandle = x; } | ||||
|  | ||||
|   bool uninterruptible_io () const { return status.uninterruptible_io; } | ||||
|   void uninterruptible_io (bool b) { status.uninterruptible_io = b; } | ||||
|  | ||||
|   bool append_mode () const { return status.append_mode; } | ||||
|   void append_mode (bool b) { status.append_mode = b; } | ||||
|  | ||||
|   bool did_lseek () const { return status.did_lseek; } | ||||
|   void did_lseek (bool b) { status.did_lseek = b; } | ||||
|  | ||||
|   query_state query_open () const { return (query_state) status.query_open; } | ||||
|   void query_open (query_state val) { status.query_open = val; } | ||||
|  | ||||
|   bool close_on_exec () const { return status.close_on_exec; } | ||||
|   void close_on_exec (bool b) { status.close_on_exec = b; } | ||||
|  | ||||
|   bool need_fork_fixup () const { return status.need_fork_fixup; } | ||||
|   void need_fork_fixup (bool b) { status.need_fork_fixup = b; } | ||||
|  | ||||
|   int get_default_fmode (int flags); | ||||
|  | ||||
|   bool get_r_no_interrupt () { return status.uninterruptible_io; } | ||||
|   void set_r_no_interrupt (bool b) { status.uninterruptible_io = b; } | ||||
|  | ||||
|   bool get_close_on_exec () { return status.close_on_exec; } | ||||
|   void set_close_on_exec_flag (int b) { status.close_on_exec = (b ? 1 : 0); } | ||||
|   virtual void set_close_on_exec (bool val); | ||||
|  | ||||
|   LPSECURITY_ATTRIBUTES get_inheritance (bool all = 0) | ||||
|   { | ||||
|     if (all) | ||||
|       return get_close_on_exec () ? &sec_all_nih : &sec_all; | ||||
|       return close_on_exec () ? &sec_all_nih : &sec_all; | ||||
|     else | ||||
|       return get_close_on_exec () ? &sec_none_nih : &sec_none; | ||||
|       return close_on_exec () ? &sec_none_nih : &sec_none; | ||||
|   } | ||||
|  | ||||
|   void set_did_lseek (bool b) { status.lseeked = b; } | ||||
|   bool get_did_lseek () { return status.lseeked; } | ||||
|  | ||||
|   bool get_need_fork_fixup () { return status.need_fork_fixup; } | ||||
|   void set_need_fork_fixup () { status.need_fork_fixup = 1; } | ||||
|  | ||||
|   bool get_encoded () { return status.encoded;} | ||||
|   void set_encoded () { status.encoded = 1;} | ||||
|  | ||||
|   virtual void set_close_on_exec (int val); | ||||
|  | ||||
|   virtual void fixup_before_fork_exec (DWORD) {} | ||||
|   virtual void fixup_after_fork (HANDLE); | ||||
|   virtual void fixup_after_exec () {} | ||||
|  | ||||
|   bool get_append_p () { return status.append_mode; } | ||||
|   void set_append_p () { status.append_mode = 1; } | ||||
|  | ||||
|   void set_fs_flags (DWORD flags) { fs_flags = flags; } | ||||
|   bool get_fs_flags (DWORD flagval = UINT32_MAX) | ||||
|     { return (fs_flags & (flagval)); } | ||||
|  | ||||
|   query_state get_query_open () { return (query_state) status.query_open; } | ||||
|   void set_query_open (query_state val) { status.query_open = val; } | ||||
|  | ||||
|   bool get_readahead_valid () { return raixget < ralen; } | ||||
|   int puts_readahead (const char *s, size_t len = (size_t) -1); | ||||
|   int put_readahead (char value); | ||||
| @@ -356,13 +345,14 @@ class fhandler_socket: public fhandler_base | ||||
|   char *sun_path; | ||||
|   struct status_flags | ||||
|   { | ||||
|     unsigned sock_saw_shut_rd      : 1; /* Socket saw a SHUT_RD */ | ||||
|     unsigned sock_saw_shut_wr      : 1; /* Socket saw a SHUT_WR */ | ||||
|     unsigned had_connect_or_listen : 2; | ||||
|     unsigned async_io              : 1; /* async I/O */ | ||||
|     unsigned saw_shutdown_read     : 1; /* Socket saw a SHUT_RD */ | ||||
|     unsigned saw_shutdown_write    : 1; /* Socket saw a SHUT_WR */ | ||||
|     unsigned connect_state         : 2; | ||||
|    public: | ||||
|     status_flags () : | ||||
|       sock_saw_shut_rd (0), sock_saw_shut_wr (0), | ||||
|       had_connect_or_listen (unconnected) | ||||
|       async_io (0), saw_shutdown_read (0), saw_shutdown_write (0), | ||||
|       connect_state (unconnected) | ||||
|       {} | ||||
|   } status; | ||||
|  | ||||
| @@ -372,22 +362,19 @@ class fhandler_socket: public fhandler_base | ||||
|   int get_socket () { return (int) get_handle(); } | ||||
|   fhandler_socket *is_socket () { return this; } | ||||
|  | ||||
|   bool saw_shutdown_read () const { return status.sock_saw_shut_rd; } | ||||
|   bool saw_shutdown_write () const { return status.sock_saw_shut_wr; } | ||||
|   bool async_io () const { return status.async_io; } | ||||
|   void async_io (bool b) { status.async_io = b; } | ||||
|  | ||||
|   void set_shutdown_read () { status.sock_saw_shut_rd = 1;} | ||||
|   void set_shutdown_write () { status.sock_saw_shut_wr = 1;} | ||||
|   bool saw_shutdown_read () const { return status.saw_shutdown_read; } | ||||
|   bool saw_shutdown_write () const { return status.saw_shutdown_write; } | ||||
|  | ||||
|   bool is_unconnected () const | ||||
|   	{ return status.had_connect_or_listen == unconnected; } | ||||
|   bool is_connect_pending () const | ||||
|     { return status.had_connect_or_listen == connect_pending; } | ||||
|   bool is_connected () const | ||||
|   	{ return status.had_connect_or_listen == connected; } | ||||
|   void set_connect_state (connect_state newstate) | ||||
| 	{ status.had_connect_or_listen = newstate; } | ||||
|   connect_state get_connect_state () const | ||||
| 	{ return (connect_state) status.had_connect_or_listen; } | ||||
|   void saw_shutdown_read (bool b) { status.saw_shutdown_read = b;} | ||||
|   void saw_shutdown_write (bool b) { status.saw_shutdown_write = b;} | ||||
|  | ||||
|   conn_state connect_state () const | ||||
| 	{ return (conn_state) status.connect_state; } | ||||
|   void connect_state (conn_state newstate) | ||||
| 	{ status.connect_state = newstate; } | ||||
|  | ||||
|   int bind (const struct sockaddr *name, int namelen); | ||||
|   int connect (const struct sockaddr *name, int namelen); | ||||
| @@ -414,7 +401,7 @@ class fhandler_socket: public fhandler_base | ||||
|   void hclose (HANDLE) {close ();} | ||||
|   int dup (fhandler_base *child); | ||||
|  | ||||
|   void set_close_on_exec (int val); | ||||
|   void set_close_on_exec (bool val); | ||||
|   virtual void fixup_before_fork_exec (DWORD); | ||||
|   void fixup_after_fork (HANDLE); | ||||
|   void fixup_after_exec (); | ||||
| @@ -453,7 +440,7 @@ public: | ||||
|   select_record *select_read (select_record *s); | ||||
|   select_record *select_write (select_record *s); | ||||
|   select_record *select_except (select_record *s); | ||||
|   void set_close_on_exec (int val); | ||||
|   void set_close_on_exec (bool val); | ||||
|   void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); | ||||
|   int close (); | ||||
|   void create_guard (SECURITY_ATTRIBUTES *sa) {guard = CreateMutex (sa, FALSE, NULL);} | ||||
| @@ -509,14 +496,17 @@ class fhandler_dev_raw: public fhandler_base | ||||
|       {} | ||||
|   } status; | ||||
|   | ||||
|   bool eom_detected () const { return status.eom_detected; } | ||||
|   void eom_detected (bool b) { status.eom_detected = b; } | ||||
|   bool eom_detected () { return status.eom_detected; } | ||||
|  | ||||
|   bool eof_detected () const { return status.eof_detected; } | ||||
|   void eof_detected (bool b) { status.eof_detected = b; } | ||||
|   bool eof_detected () { return status.eof_detected; } | ||||
|  | ||||
|   bool lastblk_to_read () const { return status.lastblk_to_read; } | ||||
|   void lastblk_to_read (bool b) { status.lastblk_to_read = b; } | ||||
|   bool lastblk_to_read () { return status.lastblk_to_read; } | ||||
|  | ||||
|   bool is_writing () const { return status.is_writing; } | ||||
|   void is_writing (bool b) { status.is_writing = b; } | ||||
|   bool is_writing () { return status.is_writing; } | ||||
|  | ||||
|   virtual BOOL write_file (const void *buf, DWORD to_write, | ||||
| 			   DWORD *written, int *err); | ||||
| @@ -704,7 +694,7 @@ class fhandler_termios: public fhandler_base | ||||
|   fhandler_termios () : | ||||
|   fhandler_base () | ||||
|   { | ||||
|     set_need_fork_fixup (); | ||||
|     need_fork_fixup (true); | ||||
|   } | ||||
|   HANDLE& get_output_handle () { return output_handle; } | ||||
|   line_edit_status line_edit (const char *rptr, int nread, termios&); | ||||
| @@ -850,7 +840,7 @@ class fhandler_console: public fhandler_termios | ||||
|   select_record *select_write (select_record *s); | ||||
|   select_record *select_except (select_record *s); | ||||
|   void fixup_after_exec (); | ||||
|   void set_close_on_exec (int val); | ||||
|   void set_close_on_exec (bool val); | ||||
|   void fixup_after_fork (HANDLE parent); | ||||
|   void set_input_state (); | ||||
|   void send_winch_maybe (); | ||||
| @@ -886,7 +876,7 @@ class fhandler_tty_common: public fhandler_termios | ||||
|   tty *get_ttyp () { return (tty *) tc; } | ||||
|  | ||||
|   int close (); | ||||
|   void set_close_on_exec (int val); | ||||
|   void set_close_on_exec (bool val); | ||||
|   void fixup_after_fork (HANDLE parent); | ||||
|   select_record *select_read (select_record *s); | ||||
|   select_record *select_write (select_record *s); | ||||
| @@ -947,7 +937,7 @@ public: | ||||
|   _off64_t lseek (_off64_t, int) { return 0; } | ||||
|   char *ptsname (); | ||||
|  | ||||
|   void set_close_on_exec (int val); | ||||
|   void set_close_on_exec (bool val); | ||||
|   bool hit_eof (); | ||||
|   int get_unit () const { return slave.minor; } | ||||
| }; | ||||
| @@ -1074,7 +1064,7 @@ class fhandler_windows: public fhandler_base | ||||
|   _off64_t lseek (_off64_t, int) { return 0; } | ||||
|   int close (void) { return 0; } | ||||
|  | ||||
|   void set_close_on_exec (int val); | ||||
|   void set_close_on_exec (bool val); | ||||
|   void fixup_after_fork (HANDLE parent); | ||||
|   select_record *select_read (select_record *s); | ||||
|   select_record *select_write (select_record *s); | ||||
|   | ||||
| @@ -73,7 +73,7 @@ fhandler_dev_clipboard::open (int flags, mode_t) | ||||
|   membuffer = NULL; | ||||
|   if (!cygnativeformat) | ||||
|     cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE); | ||||
|   set_nohandle (true); | ||||
|   nohandle (true); | ||||
|   set_open_status (); | ||||
|   return 1; | ||||
| } | ||||
|   | ||||
| @@ -155,7 +155,7 @@ set_console_state_for_spawn () | ||||
|     { | ||||
|       /* ACK.  Temporarily define for use in TTYSETF macro */ | ||||
|       SetConsoleMode (h, ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT); | ||||
|       shared_console_info->tty_min_state.set_rstcons (); | ||||
|       shared_console_info->tty_min_state.rstcons (true); | ||||
|     } | ||||
|  | ||||
|   CloseHandle (h); | ||||
| @@ -536,7 +536,7 @@ sig_exit: | ||||
| void | ||||
| fhandler_console::set_input_state () | ||||
| { | ||||
|   if (tc->needs_rstcons ()) | ||||
|   if (tc->rstcons ()) | ||||
|     input_tcsetattr (0, &tc->ti); | ||||
| } | ||||
|  | ||||
| @@ -633,7 +633,7 @@ fhandler_console::open (int flags, mode_t) | ||||
|       return 0; | ||||
|     } | ||||
|   set_io_handle (h); | ||||
|   set_r_no_interrupt (1);	// Handled explicitly in read code | ||||
|   uninterruptible_io (true);	// Handled explicitly in read code | ||||
|  | ||||
|   h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE, | ||||
| 		  FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none, | ||||
| @@ -658,7 +658,7 @@ fhandler_console::open (int flags, mode_t) | ||||
|       SetConsoleMode (get_io_handle (), ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | cflags); | ||||
|     } | ||||
|  | ||||
|   tc->clear_rstcons (); | ||||
|   tc->rstcons (false); | ||||
|   set_open_status (); | ||||
|   cygheap->open_fhs++; | ||||
|   debug_printf ("incremented open_fhs, now %d", cygheap->open_fhs); | ||||
| @@ -789,7 +789,7 @@ fhandler_console::input_tcsetattr (int, struct termios const *t) | ||||
|  | ||||
| #if 0 | ||||
|   /* Enable/disable LF -> CRLF conversions */ | ||||
|   set_r_binary ((t->c_iflag & INLCR) ? 0 : 1); | ||||
|   rbinary ((t->c_iflag & INLCR) ? false : true); | ||||
| #endif | ||||
|  | ||||
|   /* There's some disparity between what we need and what's | ||||
| @@ -842,7 +842,7 @@ fhandler_console::input_tcsetattr (int, struct termios const *t) | ||||
| 		      res, t, flags, t->c_lflag, t->c_iflag); | ||||
|     } | ||||
|  | ||||
|   tc->clear_rstcons (); | ||||
|   tc->rstcons (false); | ||||
|   return res; | ||||
| } | ||||
|  | ||||
| @@ -1742,7 +1742,7 @@ fhandler_console::igncr_enabled (void) | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_console::set_close_on_exec (int val) | ||||
| fhandler_console::set_close_on_exec (bool val) | ||||
| { | ||||
|   fhandler_base::set_close_on_exec (val); | ||||
|   set_no_inheritance (output_handle, val); | ||||
| @@ -1761,7 +1761,7 @@ fhandler_console::fixup_after_fork (HANDLE) | ||||
|   if (!open (O_NOCTTY | get_flags (), 0)) | ||||
|     system_printf ("error opening console after fork, %E"); | ||||
|  | ||||
|   if (!get_close_on_exec ()) | ||||
|   if (!close_on_exec ()) | ||||
|     { | ||||
|       CloseHandle (h); | ||||
|       CloseHandle (oh); | ||||
|   | ||||
| @@ -164,7 +164,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf) | ||||
|  | ||||
|   if (get_io_handle ()) | ||||
|     { | ||||
|       if (get_nohandle ()) | ||||
|       if (nohandle ()) | ||||
| 	return fstat_by_name (buf); | ||||
|       else | ||||
| 	return fstat_by_handle (buf); | ||||
| @@ -173,9 +173,8 @@ fhandler_base::fstat_fs (struct __stat64 *buf) | ||||
|      then just do a "query open" as it is apparently much faster. */ | ||||
|   if (pc.exec_state () != dont_know_if_executable) | ||||
|     { | ||||
|       set_query_open (query_read_control); | ||||
|       if (strncasematch (pc.volname (), "FAT", 3) | ||||
| 	  && !strpbrk (get_win32_name (), "?*|<>")) | ||||
|       query_open (query_read_control); | ||||
|       if (pc.fs_is_fat () && !strpbrk (get_win32_name (), "?*|<>")) | ||||
| 	return fstat_by_name (buf); | ||||
|     } | ||||
|   if (!(oret = open_fs (open_flags, 0)) && get_errno () == EACCES) | ||||
| @@ -183,21 +182,21 @@ fhandler_base::fstat_fs (struct __stat64 *buf) | ||||
|       /* If we couldn't open the file, try a query open with no permissions. | ||||
| 	 This allows us to determine *some* things about the file, at least. */ | ||||
|       pc.set_exec (0); | ||||
|       set_query_open (query_null_access); | ||||
|       query_open (query_null_access); | ||||
|       oret = open_fs (open_flags, 0); | ||||
|     } | ||||
|  | ||||
|   if (oret) | ||||
|     { | ||||
|       /* We now have a valid handle, regardless of the "nohandle" state. | ||||
|          Since fhandler_base::open only calls CloseHandle if !get_nohandle, | ||||
|          Since fhandler_base::open only calls CloseHandle if !nohandle, | ||||
| 	 we have to set it to false before calling close_fs and restore | ||||
| 	 the state afterwards. */ | ||||
|       res = fstat_by_handle (buf); | ||||
|       bool nohandle = get_nohandle (); | ||||
|       set_nohandle (false); | ||||
|       bool no_handle = nohandle (); | ||||
|       nohandle (false); | ||||
|       close_fs (); | ||||
|       set_nohandle (nohandle); | ||||
|       nohandle (no_handle); | ||||
|       set_io_handle (NULL); | ||||
|     } | ||||
|   else | ||||
| @@ -631,7 +630,7 @@ fhandler_disk_file::opendir () | ||||
| 	goto free_dirent; | ||||
|  | ||||
|       fd = this; | ||||
|       fd->set_nohandle (true); | ||||
|       fd->nohandle (true); | ||||
|       dir->__d_dirent->d_fd = fd; | ||||
|       dir->__fh = this; | ||||
|       /* FindFirstFile doesn't seem to like duplicate /'s. */ | ||||
| @@ -647,8 +646,6 @@ fhandler_disk_file::opendir () | ||||
|  | ||||
|       res = dir; | ||||
|  | ||||
|       if (pc.isencoded ()) | ||||
| 	set_encoded (); | ||||
|     } | ||||
|  | ||||
|   syscall_printf ("%p = opendir (%s)", res, get_name ()); | ||||
| @@ -715,7 +712,7 @@ fhandler_disk_file::readdir (DIR *dir) | ||||
|     } | ||||
|  | ||||
|   /* We get here if `buf' contains valid data.  */ | ||||
|   if (get_encoded ()) | ||||
|   if (pc.isencoded ()) | ||||
|     (void) fnunmunge (dir->__d_dirent->d_name, buf.cFileName); | ||||
|   else | ||||
|     strcpy (dir->__d_dirent->d_name, buf.cFileName); | ||||
|   | ||||
| @@ -1075,8 +1075,8 @@ fhandler_dev_dsp::open (int flags, mode_t mode) | ||||
|     { /* All tried query () succeeded */ | ||||
|       rc = 1; | ||||
|       set_open_status (); | ||||
|       set_need_fork_fixup (); | ||||
|       set_close_on_exec_flag (1); | ||||
|       need_fork_fixup (true); | ||||
|       close_on_exec (true); | ||||
|     } | ||||
|   else | ||||
|     { /* One of the tried query () failed */ | ||||
|   | ||||
| @@ -106,7 +106,7 @@ fhandler_fifo::open_not_mine (int flags) | ||||
| 	  if (i == 0) | ||||
| 	    { | ||||
| 	      read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); | ||||
| 	      set_need_fork_fixup (); | ||||
| 	      need_fork_fixup (true); | ||||
| 	    } | ||||
| 	} | ||||
|       CloseHandle (hp); | ||||
|   | ||||
| @@ -219,7 +219,7 @@ fhandler_proc::open (int flags, mode_t mode) | ||||
|   if (!res) | ||||
|     goto out; | ||||
|  | ||||
|   set_nohandle (true); | ||||
|   nohandle (true); | ||||
|  | ||||
|   const char *path; | ||||
|  | ||||
|   | ||||
| @@ -163,7 +163,7 @@ fhandler_process::open (int flags, mode_t mode) | ||||
|   if (!res) | ||||
|     goto out; | ||||
|  | ||||
|   set_nohandle (true); | ||||
|   nohandle (true); | ||||
|  | ||||
|   const char *path; | ||||
|   path = get_name () + proc_len + 1; | ||||
|   | ||||
| @@ -32,7 +32,7 @@ int | ||||
| fhandler_dev_random::open (int flags, mode_t) | ||||
| { | ||||
|   set_flags ((flags & ~O_TEXT) | O_BINARY); | ||||
|   set_nohandle (true); | ||||
|   nohandle (true); | ||||
|   set_open_status (); | ||||
|   return 1; | ||||
| } | ||||
|   | ||||
| @@ -95,7 +95,7 @@ fhandler_dev_raw::writebuf (void) | ||||
| fhandler_dev_raw::fhandler_dev_raw () | ||||
|   : fhandler_base (), status () | ||||
| { | ||||
|   set_need_fork_fixup (); | ||||
|   need_fork_fixup (true); | ||||
| } | ||||
|  | ||||
| fhandler_dev_raw::~fhandler_dev_raw (void) | ||||
|   | ||||
| @@ -26,7 +26,7 @@ details. */ | ||||
| fhandler_serial::fhandler_serial () | ||||
|   : fhandler_base (), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid) | ||||
| { | ||||
|   set_need_fork_fixup (); | ||||
|   need_fork_fixup (true); | ||||
| } | ||||
|  | ||||
| void | ||||
| @@ -226,7 +226,7 @@ fhandler_serial::open (int flags, mode_t mode) | ||||
|  | ||||
|   (void) SetCommMask (get_handle (), EV_RXCHAR); | ||||
|  | ||||
|   set_r_no_interrupt (1);	// Handled explicitly in read code | ||||
|   uninterruptible_io (true);	// Handled explicitly in read code | ||||
|  | ||||
|   overlapped_setup (); | ||||
|  | ||||
| @@ -765,8 +765,8 @@ fhandler_serial::tcsetattr (int action, const struct termios *t) | ||||
|       res = -1; | ||||
|     } | ||||
|  | ||||
|   set_r_binary ((t->c_iflag & IGNCR) ? 0 : 1); | ||||
|   set_w_binary ((t->c_oflag & ONLCR) ? 0 : 1); | ||||
|   rbinary ((t->c_iflag & IGNCR) ? false : true); | ||||
|   wbinary ((t->c_oflag & ONLCR) ? false : true); | ||||
|  | ||||
|   if (dropDTR) | ||||
|     { | ||||
| @@ -1020,11 +1020,11 @@ fhandler_serial::tcgetattr (struct termios *t) | ||||
|  | ||||
|   /* FIXME: need to handle IGNCR */ | ||||
| #if 0 | ||||
|   if (!get_r_binary ()) | ||||
|   if (!rbinary ()) | ||||
|     t->c_iflag |= IGNCR; | ||||
| #endif | ||||
|  | ||||
|   if (!get_w_binary ()) | ||||
|   if (!wbinary ()) | ||||
|     t->c_oflag |= ONLCR; | ||||
|  | ||||
|   t->c_cc[VTIME] = vtime_ / 100; | ||||
| @@ -1038,7 +1038,7 @@ fhandler_serial::tcgetattr (struct termios *t) | ||||
| void | ||||
| fhandler_serial::fixup_after_fork (HANDLE parent) | ||||
| { | ||||
|   if (get_close_on_exec ()) | ||||
|   if (close_on_exec ()) | ||||
|     fhandler_base::fixup_after_fork (parent); | ||||
|   overlapped_setup (); | ||||
|   debug_printf ("io_status.hEvent %p", io_status.hEvent); | ||||
|   | ||||
| @@ -126,7 +126,7 @@ fhandler_socket::fhandler_socket () : | ||||
|   sun_path (NULL), | ||||
|   status () | ||||
| { | ||||
|   set_need_fork_fixup (); | ||||
|   need_fork_fixup (true); | ||||
|   prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF, | ||||
| 						 sizeof (WSAPROTOCOL_INFOA)); | ||||
| #if 0 | ||||
| @@ -200,7 +200,7 @@ fhandler_socket::create_secret_event (int* secret) | ||||
|  | ||||
|   if (!secret_event) | ||||
|     debug_printf("create event %E"); | ||||
|   else if (get_close_on_exec ()) | ||||
|   else if (close_on_exec ()) | ||||
|     /* Event allows inheritance, but handle will not be inherited */ | ||||
|     set_no_inheritance (secret_event, 1); | ||||
|  | ||||
| @@ -308,7 +308,7 @@ void | ||||
| fhandler_socket::fixup_after_exec () | ||||
| { | ||||
|   debug_printf ("here"); | ||||
|   if (!get_close_on_exec ()) | ||||
|   if (!close_on_exec ()) | ||||
|     fixup_after_fork (NULL); | ||||
| #if 0 | ||||
|   else if (!winsock2_active) | ||||
| @@ -325,7 +325,7 @@ fhandler_socket::dup (fhandler_base *child) | ||||
|   if (get_addr_family () == AF_LOCAL) | ||||
|     fhs->set_sun_path (get_sun_path ()); | ||||
|   fhs->set_socket_type (get_socket_type ()); | ||||
|   fhs->set_connect_state (get_connect_state ()); | ||||
|   fhs->connect_state (connect_state ()); | ||||
|  | ||||
|   if (winsock2_active) | ||||
|     { | ||||
| @@ -501,7 +501,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen) | ||||
|     { | ||||
|       /* Special handling for connect to return the correct error code | ||||
| 	 when called on a non-blocking socket. */ | ||||
|       if (is_nonblocking () || is_connect_pending ()) | ||||
|       if (is_nonblocking () || connect_state () == connect_pending) | ||||
| 	{ | ||||
| 	  err = WSAGetLastError (); | ||||
| 	  if (err == WSAEWOULDBLOCK || err == WSAEALREADY) | ||||
| @@ -547,9 +547,9 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen) | ||||
|  | ||||
|   err = WSAGetLastError (); | ||||
|   if (err == WSAEINPROGRESS || err == WSAEALREADY) | ||||
|     set_connect_state (connect_pending); | ||||
|     connect_state (connect_pending); | ||||
|   else | ||||
|     set_connect_state (connected); | ||||
|     connect_state (connected); | ||||
|  | ||||
|   return res; | ||||
| } | ||||
| @@ -561,7 +561,7 @@ fhandler_socket::listen (int backlog) | ||||
|   if (res) | ||||
|     set_winsock_errno (); | ||||
|   else | ||||
|     set_connect_state (connected); | ||||
|     connect_state (connected); | ||||
|   return res; | ||||
| } | ||||
|  | ||||
| @@ -636,7 +636,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) | ||||
| 	    ((fhandler_socket *) res_fd)->set_sun_path (get_sun_path ()); | ||||
| 	  ((fhandler_socket *) res_fd)->set_addr_family (get_addr_family ()); | ||||
| 	  ((fhandler_socket *) res_fd)->set_socket_type (get_socket_type ()); | ||||
| 	  ((fhandler_socket *) res_fd)->set_connect_state (connected); | ||||
| 	  ((fhandler_socket *) res_fd)->connect_state (connected); | ||||
| 	  res = res_fd; | ||||
| 	} | ||||
|       else | ||||
| @@ -1088,14 +1088,14 @@ fhandler_socket::shutdown (int how) | ||||
|     switch (how) | ||||
|       { | ||||
|       case SHUT_RD: | ||||
| 	set_shutdown_read (); | ||||
| 	saw_shutdown_read (true); | ||||
| 	break; | ||||
|       case SHUT_WR: | ||||
| 	set_shutdown_write (); | ||||
| 	saw_shutdown_write (true); | ||||
| 	break; | ||||
|       case SHUT_RDWR: | ||||
| 	set_shutdown_read (); | ||||
| 	set_shutdown_write (); | ||||
| 	saw_shutdown_read (true); | ||||
| 	saw_shutdown_write (true); | ||||
| 	break; | ||||
|       } | ||||
|   return res; | ||||
| @@ -1246,7 +1246,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) | ||||
| 	      *(int *) p ? ASYNC_MASK : 0); | ||||
|       syscall_printf ("Async I/O on socket %s", | ||||
| 	      *(int *) p ? "started" : "cancelled"); | ||||
|       set_async (*(int *) p); | ||||
|       async_io (*(int *) p != 0); | ||||
|       break; | ||||
|     case FIONREAD: | ||||
|       res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p); | ||||
| @@ -1267,7 +1267,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) | ||||
| 	  syscall_printf ("socket is now %sblocking", | ||||
| 			    *(int *) p ? "non" : ""); | ||||
| 	  /* Start AsyncSelect if async socket unblocked */ | ||||
| 	  if (*(int *) p && get_async ()) | ||||
| 	  if (*(int *) p && async_io ()) | ||||
| 	    WSAAsyncSelect (get_socket (), gethwnd (), WM_ASYNCIO, ASYNC_MASK); | ||||
|  | ||||
| 	  set_nonblocking (*(int *) p); | ||||
| @@ -1309,13 +1309,13 @@ fhandler_socket::fcntl (int cmd, void *arg) | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_socket::set_close_on_exec (int val) | ||||
| fhandler_socket::set_close_on_exec (bool val) | ||||
| { | ||||
|   if (secret_event) | ||||
|     set_no_inheritance (secret_event, val); | ||||
|   if (!winsock2_active) /* < Winsock 2.0 */ | ||||
|     set_no_inheritance (get_handle (), val); | ||||
|   set_close_on_exec_flag (val); | ||||
|   close_on_exec (val); | ||||
|   debug_printf ("set close_on_exec for %s to %d", get_name (), val); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -31,7 +31,7 @@ fhandler_termios::tcinit (tty_min *this_tc, bool force) | ||||
|  | ||||
|   tc = this_tc; | ||||
|  | ||||
|   if (force || !tc->is_initialized ()) | ||||
|   if (force || !tc->initialized ()) | ||||
|     { | ||||
|       tc->ti.c_iflag = BRKINT | ICRNL | IXON; | ||||
|       tc->ti.c_oflag = OPOST | ONLCR; | ||||
|   | ||||
| @@ -440,7 +440,7 @@ process_ioctl (void *) | ||||
| fhandler_tty_slave::fhandler_tty_slave () | ||||
|   : fhandler_tty_common () | ||||
| { | ||||
|   set_r_no_interrupt (1); | ||||
|   uninterruptible_io (true); | ||||
| } | ||||
|  | ||||
| /* FIXME: This function needs to close handles when it has | ||||
| @@ -1334,10 +1334,10 @@ fhandler_pty_master::ptsname () | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_tty_common::set_close_on_exec (int val) | ||||
| fhandler_tty_common::set_close_on_exec (bool val) | ||||
| { | ||||
|   if (archetype) | ||||
|     set_close_on_exec_flag (val); | ||||
|     close_on_exec (val); | ||||
|   else | ||||
|     { | ||||
|       if (output_done_event) | ||||
| @@ -1359,7 +1359,7 @@ fhandler_tty_common::set_close_on_exec (int val) | ||||
| 	 It is here because we need to specify the "from_pty" stuff here or | ||||
| 	 we'll get warnings from ForceCloseHandle when debugging. */ | ||||
|       set_no_inheritance (get_io_handle (), val); | ||||
|       set_close_on_exec_flag (val); | ||||
|       close_on_exec (val); | ||||
| #endif | ||||
|     } | ||||
| } | ||||
| @@ -1391,7 +1391,7 @@ fhandler_tty_common::fixup_after_fork (HANDLE parent) | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_pty_master::set_close_on_exec (int val) | ||||
| fhandler_pty_master::set_close_on_exec (bool val) | ||||
| { | ||||
|   fhandler_tty_common::set_close_on_exec (val); | ||||
|  | ||||
| @@ -1414,6 +1414,6 @@ fhandler_tty_master::init_console () | ||||
|  | ||||
|   console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY); | ||||
|   cygheap->open_fhs--;  	/* handled when individual fds are opened */ | ||||
|   console->set_r_no_interrupt (1); | ||||
|   console->uninterruptible_io (true); | ||||
|   return 0; | ||||
| } | ||||
|   | ||||
| @@ -75,7 +75,7 @@ fhandler_virtual::opendir () | ||||
|       if (fd >= 0) | ||||
| 	{ | ||||
| 	  fd = this; | ||||
| 	  fd->set_nohandle (true); | ||||
| 	  fd->nohandle (true); | ||||
| 	  dir->__d_dirent->d_fd = fd; | ||||
| 	  dir->__fh = this; | ||||
| 	  dir->__d_cookie = __DIRENT_COOKIE; | ||||
| @@ -207,8 +207,8 @@ fhandler_virtual::write (const void *ptr, size_t len) | ||||
| int | ||||
| fhandler_virtual::open (int flags, mode_t mode) | ||||
| { | ||||
|   set_r_binary (1); | ||||
|   set_w_binary (1); | ||||
|   rbinary (true); | ||||
|   wbinary (true); | ||||
|  | ||||
|   set_flags ((flags & ~O_TEXT) | O_BINARY); | ||||
|  | ||||
|   | ||||
| @@ -55,7 +55,7 @@ int | ||||
| fhandler_windows::open (int flags, mode_t) | ||||
| { | ||||
|   set_flags ((flags & ~O_TEXT) | O_BINARY); | ||||
|   set_close_on_exec_flag (1); | ||||
|   close_on_exec (true); | ||||
|   set_open_status (); | ||||
|   return 1; | ||||
| } | ||||
| @@ -125,12 +125,12 @@ fhandler_windows::ioctl (unsigned int cmd, void *val) | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_windows::set_close_on_exec (int val) | ||||
| fhandler_windows::set_close_on_exec (bool val) | ||||
| { | ||||
|   if (get_handle ()) | ||||
|     fhandler_base::set_close_on_exec (val); | ||||
|   else | ||||
|     fhandler_base::set_close_on_exec_flag (val); | ||||
|     fhandler_base::close_on_exec (val); | ||||
|   void *h = hWnd_; | ||||
|   if (h) | ||||
|     set_no_inheritance (h, val); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ int | ||||
| fhandler_dev_zero::open (int flags, mode_t) | ||||
| { | ||||
|   set_flags ((flags & ~O_TEXT) | O_BINARY); | ||||
|   set_nohandle (true); | ||||
|   nohandle (true); | ||||
|   set_open_status (); | ||||
|   return 1; | ||||
| } | ||||
|   | ||||
| @@ -113,18 +113,18 @@ public: | ||||
|   int ioctl (HANDLE mt, unsigned int cmd, void *buf); | ||||
|   int set_pos (HANDLE mt, int mode, long count, bool sfm_func); | ||||
|  | ||||
|   bool buffer_writes () const { return status.buffer_writes; } | ||||
|   void buffer_writes (bool b) { status.buffer_writes = b; } | ||||
|   bool buffer_writes () { return status.buffer_writes; } | ||||
|   bool two_fm () const { return status.two_fm; } | ||||
|   void two_fm (bool b) { status.two_fm = b; } | ||||
|   bool two_fm () { return status.two_fm; } | ||||
|   bool fast_eom () const { return status.fast_eom; } | ||||
|   void fast_eom (bool b) { status.fast_eom = b; } | ||||
|   bool fast_eom () { return status.fast_eom; } | ||||
|   bool auto_lock () const { return status.auto_lock; } | ||||
|   void auto_lock (bool b) { status.auto_lock = b; } | ||||
|   bool auto_lock () { return status.auto_lock; } | ||||
|   bool sysv () const { return status.sysv; } | ||||
|   void sysv (bool b) { status.sysv = b; } | ||||
|   bool sysv () { return status.sysv; } | ||||
|   bool nowait () const { return status.nowait; } | ||||
|   void nowait (bool b) { status.nowait = b; } | ||||
|   bool nowait () { return status.nowait; } | ||||
|   PTAPE_GET_DRIVE_PARAMETERS dp (void) { return &_dp; } | ||||
|   PTAPE_GET_MEDIA_PARAMETERS mp (void) { return &_mp; } | ||||
|   mtinfo_part *part (int num) { return &_part[num]; } | ||||
|   | ||||
| @@ -636,7 +636,7 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc) | ||||
|     return false; | ||||
|   fd->set_io_handle ((HANDLE) soc); | ||||
|   fd->set_flags (O_RDWR | O_BINARY); | ||||
|   fd->set_r_no_interrupt (winsock2_active); | ||||
|   fd->uninterruptible_io (winsock2_active); | ||||
|   cygheap->fdtab.inc_need_fixup_before (); | ||||
|   debug_printf ("fd %d, name '%s', soc %p", (int) fd, dev->name, soc); | ||||
|   return true; | ||||
| @@ -1960,7 +1960,7 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser, | ||||
|  | ||||
|       if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res)) | ||||
| 	{ | ||||
| 	  ((fhandler_socket *) res_fd)->set_connect_state (connected); | ||||
| 	  ((fhandler_socket *) res_fd)->connect_state (connected); | ||||
| 	  res = res_fd; | ||||
| 	} | ||||
|       else | ||||
| @@ -1977,7 +1977,7 @@ cygwin_rcmd (char **ahost, unsigned short inport, char *locuser, | ||||
| 	  if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s)) | ||||
| 	    { | ||||
| 	      *fd2p = newfd; | ||||
| 	      ((fhandler_socket *) fd2p)->set_connect_state (connected); | ||||
| 	      ((fhandler_socket *) fd2p)->connect_state (connected); | ||||
| 	    } | ||||
| 	  else | ||||
| 	    { | ||||
| @@ -2040,7 +2040,7 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser, | ||||
|  | ||||
|       if (res_fd >= 0 && fdsock (res_fd, tcp_dev, res)) | ||||
| 	{ | ||||
| 	  ((fhandler_socket *) res_fd)->set_connect_state (connected); | ||||
| 	  ((fhandler_socket *) res_fd)->connect_state (connected); | ||||
| 	  res = res_fd; | ||||
| 	} | ||||
|       else | ||||
| @@ -2056,7 +2056,7 @@ cygwin_rexec (char **ahost, unsigned short inport, char *locuser, | ||||
|  | ||||
| 	  if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s)) | ||||
| 	    { | ||||
| 	      ((fhandler_socket *) fd2p)->set_connect_state (connected); | ||||
| 	      ((fhandler_socket *) fd2p)->connect_state (connected); | ||||
| 	      *fd2p = newfd; | ||||
| 	    } | ||||
| 	  else | ||||
| @@ -2230,7 +2230,7 @@ socketpair (int family, int type, int protocol, int *sb) | ||||
| 	((fhandler_socket *) sb0)->set_sun_path (""); | ||||
| 	((fhandler_socket *) sb0)->set_addr_family (family); | ||||
| 	((fhandler_socket *) sb0)->set_socket_type (type); | ||||
| 	((fhandler_socket *) sb0)->set_connect_state (connected); | ||||
| 	((fhandler_socket *) sb0)->connect_state (connected); | ||||
|  | ||||
| 	cygheap_fdnew sb1 (sb0, false); | ||||
|  | ||||
| @@ -2239,7 +2239,7 @@ socketpair (int family, int type, int protocol, int *sb) | ||||
| 	    ((fhandler_socket *) sb1)->set_sun_path (""); | ||||
| 	    ((fhandler_socket *) sb1)->set_addr_family (family); | ||||
| 	    ((fhandler_socket *) sb1)->set_socket_type (type); | ||||
| 	    ((fhandler_socket *) sb1)->set_connect_state (connected); | ||||
| 	    ((fhandler_socket *) sb1)->connect_state (connected); | ||||
|  | ||||
| 	    sb[0] = sb0; | ||||
| 	    sb[1] = sb1; | ||||
|   | ||||
| @@ -354,26 +354,28 @@ mkrelpath (char *path) | ||||
|  | ||||
| #define MAX_FS_INFO_CNT 25 | ||||
| fs_info fsinfo[MAX_FS_INFO_CNT]; | ||||
| LONG fsinfo_cnt; | ||||
|  | ||||
| bool | ||||
| fs_info::update (const char *win32_path) | ||||
| { | ||||
|   char tmp_buf [CYG_MAX_PATH]; | ||||
|   strncpy (tmp_buf, win32_path, CYG_MAX_PATH); | ||||
|   char fsname [CYG_MAX_PATH]; | ||||
|   char root_dir [CYG_MAX_PATH]; | ||||
|   strncpy (root_dir, win32_path, CYG_MAX_PATH); | ||||
|  | ||||
|   if (!rootdir (tmp_buf)) | ||||
|   if (!rootdir (root_dir)) | ||||
|     { | ||||
|       debug_printf ("Cannot get root component of path %s", win32_path); | ||||
|       name_storage [0] = '\0'; | ||||
|       sym_opt_storage = flags_storage = serial_storage = 0; | ||||
|       clear (); | ||||
|       return false; | ||||
|     } | ||||
|  | ||||
|   __ino64_t tmp_name_hash = hash_path_name (1, tmp_buf); | ||||
|   __ino64_t tmp_name_hash = hash_path_name (1, root_dir); | ||||
|   if (tmp_name_hash == name_hash) | ||||
|     return true; | ||||
|   int idx = 0; | ||||
|   while (idx < MAX_FS_INFO_CNT && fsinfo[idx].name_hash) | ||||
|   LONG cur_fsinfo_cnt = fsinfo_cnt; | ||||
|   while (idx < cur_fsinfo_cnt && fsinfo[idx].name_hash) | ||||
|     { | ||||
|       if (tmp_name_hash == fsinfo[idx].name_hash) | ||||
| 	{ | ||||
| @@ -384,21 +386,22 @@ fs_info::update (const char *win32_path) | ||||
|     } | ||||
|   name_hash = tmp_name_hash; | ||||
|  | ||||
|   strncpy (root_dir_storage, tmp_buf, CYG_MAX_PATH); | ||||
|   drive_type_storage = GetDriveType (root_dir_storage); | ||||
|   if (drive_type_storage == DRIVE_REMOTE | ||||
|       || (drive_type_storage == DRIVE_UNKNOWN | ||||
| 	  && (root_dir_storage[0] == '\\' && root_dir_storage[1] == '\\'))) | ||||
|     is_remote_drive_storage = 1; | ||||
|   drive_type (GetDriveType (root_dir)); | ||||
|   if (drive_type () == DRIVE_REMOTE | ||||
|       || (drive_type () == DRIVE_UNKNOWN | ||||
| 	  && (root_dir[0] == '\\' && root_dir[1] == '\\'))) | ||||
|     is_remote_drive (true); | ||||
|   else | ||||
|     is_remote_drive_storage = 0; | ||||
|     is_remote_drive (false); | ||||
|  | ||||
|   if (!GetVolumeInformation (root_dir_storage, NULL, 0, &serial_storage, NULL, &flags_storage, | ||||
| 				 name_storage, sizeof (name_storage))) | ||||
|   if (!GetVolumeInformation (root_dir, NULL, 0, &status.serial, NULL, | ||||
|   			     &status.flags, fsname, sizeof (fsname))) | ||||
|     { | ||||
|       debug_printf ("Cannot get volume information (%s), %E", root_dir_storage); | ||||
|       name_storage[0] = '\0'; | ||||
|       sym_opt_storage = flags_storage = serial_storage = 0; | ||||
|       debug_printf ("Cannot get volume information (%s), %E", root_dir); | ||||
|       flags () = 0; | ||||
|       has_buggy_open (false); | ||||
|       has_ea (false); | ||||
|       flags () = serial () = 0; | ||||
|       return false; | ||||
|     } | ||||
|   /* FIXME: Samba by default returns "NTFS" in file system name, but | ||||
| @@ -406,10 +409,34 @@ fs_info::update (const char *win32_path) | ||||
|    * distinguish between samba and real ntfs, it should be implemented | ||||
|    * here. | ||||
|    */ | ||||
|   sym_opt_storage = (!is_remote_drive_storage && strcmp (name_storage, "NTFS") == 0) ? PC_CHECK_EA : 0; | ||||
|   has_ea (!is_remote_drive () && strcmp (fsname, "NTFS") == 0); | ||||
|   has_acls ((flags () & FS_PERSISTENT_ACLS) | ||||
| 	    && (allow_smbntsec || !is_remote_drive ())); | ||||
|   is_fat (strncasematch (fsname, "FAT", 3)); | ||||
|   /* Known file systems with buggy open calls. Further explanation | ||||
|      in fhandler.cc (fhandler_disk_file::open). */ | ||||
|   has_buggy_open (!strcmp (fsname, "SUNWNFS")); | ||||
|  | ||||
|   if (idx < MAX_FS_INFO_CNT && drive_type_storage != DRIVE_REMOVABLE) | ||||
|     fsinfo[idx] = *this; | ||||
|   /* Only append non-removable drives to the global fsinfo storage */ | ||||
|   if (drive_type () != DRIVE_REMOVABLE && drive_type () != DRIVE_CDROM | ||||
|       && idx < MAX_FS_INFO_CNT) | ||||
|     { | ||||
|       LONG exc_cnt; | ||||
|       while ((exc_cnt = InterlockedExchange (&fsinfo_cnt, -1)) == -1) | ||||
| 	low_priority_sleep (0); | ||||
|       if (exc_cnt < MAX_FS_INFO_CNT) | ||||
| 	{ | ||||
| 	  /* Check if another thread has already appended that very drive */ | ||||
| 	  while (idx < exc_cnt) | ||||
| 	    { | ||||
| 	      if (fsinfo[idx++].name_hash == name_hash) | ||||
| 		goto done; | ||||
| 	    } | ||||
| 	  fsinfo[exc_cnt++] = *this; | ||||
| 	} | ||||
|      done: | ||||
|       InterlockedExchange (&fsinfo_cnt, exc_cnt); | ||||
|     } | ||||
|   return true; | ||||
| } | ||||
|  | ||||
| @@ -427,7 +454,7 @@ path_conv::fillin (HANDLE h) | ||||
|       fileattr = local.dwFileAttributes; | ||||
|       fs.serial () = local.dwVolumeSerialNumber; | ||||
|     } | ||||
|     fs.drive_type () = DRIVE_UNKNOWN; | ||||
|     fs.drive_type (DRIVE_UNKNOWN); | ||||
| } | ||||
|  | ||||
| void | ||||
| @@ -492,12 +519,7 @@ path_conv::check (const char *src, unsigned opt, | ||||
|   fileattr = INVALID_FILE_ATTRIBUTES; | ||||
|   case_clash = false; | ||||
|   memset (&dev, 0, sizeof (dev)); | ||||
|   fs.root_dir ()[0] = '\0'; | ||||
|   fs.name ()[0] = '\0'; | ||||
|   fs.flags () = fs.serial () = 0; | ||||
|   fs.sym_opt () = 0; | ||||
|   fs.drive_type () = 0; | ||||
|   fs.is_remote_drive () = 0; | ||||
|   fs.clear (); | ||||
|   normalized_path = NULL; | ||||
|  | ||||
|   if (!(opt & PC_NULLEMPTY)) | ||||
| @@ -624,7 +646,7 @@ path_conv::check (const char *src, unsigned opt, | ||||
| 	      goto out; | ||||
| 	    } | ||||
|  | ||||
| 	  symlen = sym.check (full_path, suff, opt | fs.sym_opt ()); | ||||
| 	  symlen = sym.check (full_path, suff, opt | fs.has_ea ()); | ||||
|  | ||||
| 	  if (sym.minor || sym.major) | ||||
| 	    { | ||||
| @@ -794,31 +816,15 @@ out: | ||||
|  | ||||
|   if (dev.devn == FH_FS) | ||||
|     { | ||||
|       if (!fs.update (path)) | ||||
| 	{ | ||||
| 	  fs.root_dir ()[0] = '\0'; | ||||
| 	  set_has_acls (false);		// already implied but... | ||||
| 	  set_has_buggy_open (false);	// ditto | ||||
| 	} | ||||
|       else | ||||
|       if (fs.update (path)) | ||||
| 	{ | ||||
| 	  set_isdisk (); | ||||
| 	  debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)", | ||||
| 			fs.root_dir (), this->path, fs.flags () & FS_PERSISTENT_ACLS); | ||||
| 	  if (!(fs.flags () & FS_PERSISTENT_ACLS) || (!allow_smbntsec && fs.is_remote_drive ())) | ||||
| 	    set_has_acls (false); | ||||
| 	  else | ||||
| 	    { | ||||
| 	      set_has_acls (true); | ||||
| 	      if (allow_ntsec && wincap.has_security ()) | ||||
| 	  debug_printf ("this->path(%s), has_acls(%d)", path, fs.has_acls ()); | ||||
| 	  if (fs.has_acls () && allow_ntsec && wincap.has_security ()) | ||||
| 	    set_exec (0);  /* We really don't know if this is executable or not here | ||||
| 			      but set it to not executable since it will be figured out | ||||
| 			      later by anything which cares about this. */ | ||||
| 	} | ||||
| 	  /* Known file systems with buggy open calls. Further explanation | ||||
| 	     in fhandler.cc (fhandler_disk_file::open). */ | ||||
| 	  set_has_buggy_open (strcmp (fs.name (), "SUNWNFS") == 0); | ||||
| 	} | ||||
|       if (exec_state () != dont_know_if_executable) | ||||
| 	/* ok */; | ||||
|       else if (isdir ()) | ||||
| @@ -2657,7 +2663,7 @@ symlink_worker (const char *topath, const char *frompath, bool use_winsym, | ||||
| #endif | ||||
| 	  SetFileAttributes (win32_path, attr); | ||||
|  | ||||
| 	  if (!isdevice && win32_path.fs_fast_ea ()) | ||||
| 	  if (!isdevice && win32_path.fs_has_ea ()) | ||||
| 	    set_symlink_ea (win32_path, topath); | ||||
| 	  res = 0; | ||||
| 	} | ||||
|   | ||||
| @@ -65,29 +65,52 @@ enum path_types | ||||
|   PATH_TEXT =	      0x02000000, | ||||
|   PATH_ISDISK =	      0x04000000, | ||||
|   PATH_HAS_SYMLINKS = 0x10000000, | ||||
|   PATH_HASBUGGYOPEN = 0x20000000, | ||||
|   PATH_SOCKET =       0x40000000, | ||||
|   PATH_HASACLS =      0x80000000 | ||||
|   PATH_SOCKET =       0x40000000 | ||||
| }; | ||||
|  | ||||
| class symlink_info; | ||||
| struct fs_info | ||||
| { | ||||
|   char name_storage[CYG_MAX_PATH]; | ||||
|   char root_dir_storage[CYG_MAX_PATH]; | ||||
|  private: | ||||
|   __ino64_t name_hash; | ||||
|   DWORD flags_storage; | ||||
|   DWORD serial_storage; | ||||
|   DWORD sym_opt_storage; /* additional options to pass to symlink_info resolver */ | ||||
|   bool is_remote_drive_storage; | ||||
|   DWORD drive_type_storage; | ||||
|   inline char* name () const {return (char *) name_storage;} | ||||
|   inline char* root_dir () const {return (char *) root_dir_storage;} | ||||
|   inline DWORD& flags () {return flags_storage;}; | ||||
|   inline DWORD& serial () {return serial_storage;}; | ||||
|   inline DWORD& sym_opt () {return sym_opt_storage;}; | ||||
|   inline bool& is_remote_drive () {return is_remote_drive_storage;}; | ||||
|   inline DWORD& drive_type () {return drive_type_storage;}; | ||||
|   struct status_flags | ||||
|   { | ||||
|     DWORD flags;  /* Volume flags */ | ||||
|     DWORD serial; /* Volume serial number */ | ||||
|     unsigned is_remote_drive : 1; | ||||
|     unsigned has_buggy_open  : 1; | ||||
|     unsigned has_ea          : 1; | ||||
|     unsigned has_acls        : 1; | ||||
|     unsigned is_fat          : 1; | ||||
|     unsigned drive_type      : 3; | ||||
|   } status; | ||||
|  public: | ||||
|   void clear () | ||||
|   { | ||||
|     name_hash = 0; | ||||
|     flags () = serial () = 0; | ||||
|     is_remote_drive (false); | ||||
|     has_buggy_open (false); | ||||
|     has_ea (false); | ||||
|     has_acls (false); | ||||
|     is_fat (false); | ||||
|     drive_type (false); | ||||
|   } | ||||
|   inline DWORD& flags () {return status.flags;}; | ||||
|   inline DWORD& serial () {return status.serial;}; | ||||
|   void is_remote_drive (bool b) { status.is_remote_drive = b; } | ||||
|   bool is_remote_drive () const { return status.is_remote_drive; } | ||||
|   void has_buggy_open (bool b) { status.has_buggy_open = b; } | ||||
|   bool has_buggy_open () const { return status.has_buggy_open; } | ||||
|   void is_fat (bool b) { status.is_fat = b; } | ||||
|   bool is_fat () const { return status.is_fat; } | ||||
|   void has_ea (bool b) { status.has_ea = b; } | ||||
|   int has_ea () const { return status.has_ea ? PC_CHECK_EA : 0; } | ||||
|   void has_acls (bool b) { status.has_acls = b; } | ||||
|   bool has_acls () const { return status.has_acls; } | ||||
|   void drive_type (DWORD d) { status.is_remote_drive = d; } | ||||
|   DWORD drive_type () const { return status.drive_type; } | ||||
|  | ||||
|   bool update (const char *); | ||||
| }; | ||||
|  | ||||
| @@ -105,11 +128,11 @@ class path_conv | ||||
|   bool case_clash; | ||||
|  | ||||
|   int isdisk () const { return path_flags & PATH_ISDISK;} | ||||
|   bool& isremote () {return fs.is_remote_drive ();} | ||||
|   int has_acls () const {return path_flags & PATH_HASACLS;} | ||||
|   bool isremote () {return fs.is_remote_drive ();} | ||||
|   int has_acls () const {return fs.has_acls (); } | ||||
|   int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;} | ||||
|   int hasgood_inode () const {return path_flags & PATH_HASACLS;}  // Not strictly correct | ||||
|   int has_buggy_open () const {return path_flags & PATH_HASBUGGYOPEN;} | ||||
|   int hasgood_inode () const {return has_acls ();}  // Not strictly correct | ||||
|   int has_buggy_open () const {return fs.has_buggy_open ();} | ||||
|   bool isencoded () {return path_flags & PATH_ENC;} | ||||
|   int binmode () const | ||||
|   { | ||||
| @@ -148,8 +171,6 @@ class path_conv | ||||
|   void set_has_symlinks () {path_flags |= PATH_HAS_SYMLINKS;} | ||||
|   void set_isdisk () {path_flags |= PATH_ISDISK; dev.devn = FH_FS;} | ||||
|   void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTEXEC;} | ||||
|   void set_has_acls (int x = 1) {path_flags |= x ? PATH_HASACLS : PATH_NOTHING;} | ||||
|   void set_has_buggy_open (int x = 1) {path_flags |= x ? PATH_HASBUGGYOPEN : PATH_NOTHING;} | ||||
|  | ||||
|   void check (const char *src, unsigned opt = PC_SYM_FOLLOW, | ||||
| 	      const suffix_info *suffixes = NULL)  __attribute__ ((regparm(3))); | ||||
| @@ -185,11 +206,10 @@ class path_conv | ||||
|   DWORD file_attributes () {return fileattr;} | ||||
|   DWORD drive_type () {return fs.drive_type ();} | ||||
|   DWORD fs_flags () {return fs.flags ();} | ||||
|   bool fs_fast_ea () {return !!(fs.sym_opt () & PC_CHECK_EA);} | ||||
|   bool fs_has_ea () {return fs.has_ea ();} | ||||
|   bool fs_is_fat () {return fs.is_fat ();} | ||||
|   void set_path (const char *p) {strcpy (path, p);} | ||||
|   const char * root_dir () const { return fs.root_dir (); } | ||||
|   DWORD volser () { return fs.serial (); } | ||||
|   const char *volname () {return fs.name (); } | ||||
|   void fillin (HANDLE h); | ||||
|   inline size_t size () | ||||
|   { | ||||
|   | ||||
| @@ -41,7 +41,7 @@ fhandler_pipe::lseek (_off64_t offset, int whence) | ||||
| } | ||||
|  | ||||
| void | ||||
| fhandler_pipe::set_close_on_exec (int val) | ||||
| fhandler_pipe::set_close_on_exec (bool val) | ||||
| { | ||||
|   fhandler_base::set_close_on_exec (val); | ||||
|   if (guard) | ||||
| @@ -230,12 +230,12 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode, bool fif | ||||
|       fhs[1]->init (w, GENERIC_WRITE, binmode); | ||||
|       if (mode & O_NOINHERIT) | ||||
|        { | ||||
| 	 fhs[0]->set_close_on_exec_flag (1); | ||||
| 	 fhs[1]->set_close_on_exec_flag (1); | ||||
| 	 fhs[0]->close_on_exec (true); | ||||
| 	 fhs[1]->close_on_exec (true); | ||||
|        } | ||||
|  | ||||
|       fhs[0]->read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); | ||||
|       fhs[0]->set_need_fork_fixup (); | ||||
|       fhs[0]->need_fork_fixup (true); | ||||
|       ProtectHandle1 (fhs[0]->read_state, read_state); | ||||
|  | ||||
|       res = 0; | ||||
| @@ -312,7 +312,7 @@ _pipe (int filedes[2], unsigned int psize, int mode) | ||||
|     { | ||||
|       cygheap_fdnew fdin; | ||||
|       cygheap_fdnew fdout (fdin, false); | ||||
|       fhs[0]->set_r_no_interrupt (1); | ||||
|       fhs[0]->uninterruptible_io (true); | ||||
|       fdin = fhs[0]; | ||||
|       fdout = fhs[1]; | ||||
|       filedes[0] = fdin; | ||||
|   | ||||
| @@ -335,7 +335,7 @@ set_bits (select_record *me, fd_set *readfds, fd_set *writefds, | ||||
|     { | ||||
|       UNIX_FD_SET (me->fd, writefds); | ||||
|       if (me->except_on_write && me->fh->is_socket ()) | ||||
| 	((fhandler_socket *) me->fh)->set_connect_state (connected); | ||||
| 	((fhandler_socket *) me->fh)->connect_state (connected); | ||||
|       ready++; | ||||
|     } | ||||
|   if ((me->except_selected || me->except_on_write) && me->except_ready) | ||||
| @@ -344,7 +344,7 @@ set_bits (select_record *me, fd_set *readfds, fd_set *writefds, | ||||
| 	{ | ||||
| 	  UNIX_FD_SET (me->fd, writefds); | ||||
| 	  if (me->fh->is_socket ()) | ||||
| 	    ((fhandler_socket *) me->fh)->set_connect_state (connected); | ||||
| 	    ((fhandler_socket *) me->fh)->connect_state (connected); | ||||
| 	} | ||||
|       if (me->except_selected) | ||||
| 	UNIX_FD_SET (me->fd, exceptfds); | ||||
| @@ -1400,9 +1400,9 @@ fhandler_socket::select_write (select_record *s) | ||||
|       s->cleanup = socket_cleanup; | ||||
|     } | ||||
|   s->peek = peek_socket; | ||||
|   s->write_ready = saw_shutdown_write () || is_unconnected (); | ||||
|   s->write_ready = saw_shutdown_write () || connect_state () == unconnected; | ||||
|   s->write_selected = true; | ||||
|   if (is_connect_pending ()) | ||||
|   if (connect_state () == connect_pending) | ||||
|     { | ||||
|       s->except_ready = saw_shutdown_write () || saw_shutdown_read (); | ||||
|       s->except_on_write = true; | ||||
|   | ||||
| @@ -185,7 +185,7 @@ handle (int n, int direction) | ||||
|  | ||||
|   if (!fh) | ||||
|     return INVALID_HANDLE_VALUE; | ||||
|   if (fh->get_close_on_exec ()) | ||||
|   if (fh->close_on_exec ()) | ||||
|     return INVALID_HANDLE_VALUE; | ||||
|   if (direction == 0) | ||||
|     return fh->get_handle (); | ||||
|   | ||||
| @@ -424,7 +424,7 @@ readv (int fd, const struct iovec *const iov, const int iovcnt) | ||||
|       syscall_printf ("readv (%d, %p, %d) %sblocking, sigcatchers %d", | ||||
| 		      fd, iov, iovcnt, wait ? "" : "non", sigcatchers); | ||||
|  | ||||
|       if (wait && (!cfd->is_slow () || cfd->get_r_no_interrupt ())) | ||||
|       if (wait && (!cfd->is_slow () || cfd->uninterruptible_io ())) | ||||
| 	debug_printf ("no need to call ready_for_read"); | ||||
|       else if (!cfd->ready_for_read (fd, wait)) | ||||
| 	{ | ||||
| @@ -1617,7 +1617,7 @@ _cygwin_istext_for_stdio (int fd) | ||||
|     } | ||||
| #endif | ||||
|  | ||||
|   if (cfd->get_w_binary () || cfd->get_r_binary ()) | ||||
|   if (cfd->wbinary () || cfd->rbinary ()) | ||||
|     { | ||||
|       syscall_printf ("fd %d: opened as binary", fd); | ||||
|       return 0; | ||||
| @@ -1681,9 +1681,9 @@ setmode (int fd, int mode) | ||||
|      interfaces should not use setmode.  */ | ||||
|  | ||||
|   int res; | ||||
|   if (cfd->get_w_binary () && cfd->get_r_binary ()) | ||||
|   if (cfd->wbinary () && cfd->rbinary ()) | ||||
|     res = O_BINARY; | ||||
|   else if (cfd->get_w_binset () && cfd->get_r_binset ()) | ||||
|   else if (cfd->wbinset () && cfd->rbinset ()) | ||||
|     res = O_TEXT;	/* Specifically set O_TEXT */ | ||||
|   else | ||||
|     res = 0; | ||||
| @@ -1793,6 +1793,8 @@ get_osfhandle (int fd) | ||||
| extern "C" int | ||||
| statfs (const char *fname, struct statfs *sfs) | ||||
| { | ||||
|   char root_dir[CYG_MAX_PATH]; | ||||
|  | ||||
|   if (!sfs) | ||||
|     { | ||||
|       set_errno (EFAULT); | ||||
| @@ -1800,7 +1802,8 @@ statfs (const char *fname, struct statfs *sfs) | ||||
|     } | ||||
|  | ||||
|   path_conv full_path (fname, PC_SYM_FOLLOW | PC_FULL); | ||||
|   const char *root = full_path.root_dir (); | ||||
|   strncpy (root_dir, full_path, CYG_MAX_PATH); | ||||
|   const char *root = rootdir (root_dir); | ||||
|  | ||||
|   syscall_printf ("statfs %s", root); | ||||
|  | ||||
|   | ||||
| @@ -49,11 +49,10 @@ public: | ||||
|   int ntty; | ||||
|   DWORD last_ctrl_c;	// tick count of last ctrl-c | ||||
|  | ||||
|   bool initialized () const { return status.initialized; } | ||||
|   void initialize () { status.initialized = 1; } | ||||
|   bool is_initialized () { return status.initialized; } | ||||
|   void set_rstcons () { status.rstcons = 1; } | ||||
|   void clear_rstcons () { status.rstcons = 1; } | ||||
|   bool needs_rstcons () { return status.rstcons; } | ||||
|   bool rstcons () const { return status.rstcons; } | ||||
|   void rstcons (bool b) { status.rstcons = b; } | ||||
|  | ||||
|   tty_min (int t = -1, pid_t s = -1) : sid (s), ntty (t) {} | ||||
|   void setntty (int n) {ntty = n;} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user