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-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.
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;
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);
if ((fh = fds[i]) != NULL)
{
fh->clear_readahead ();
- if (fh->get_close_on_exec ())
+ if (fh->close_on_exec ())
{
if (fh->archetype)
fh->close ();
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);
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;
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
{
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)
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");
}
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)
{
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)
creation_distribution = CREATE_NEW;
if (flags & O_APPEND)
- set_append_p ();
+ append_mode (true);
/* These flags are host dependent. */
shared = wincap.shared ();
/* 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);
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;
}
else
len = copied_chars;
- if (get_r_binary () || len <= 0)
+ if (rbinary () || len <= 0)
goto out;
/* Scan buffer and turn \r\n into \n */
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;
}
{
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;
}
}
- if (get_w_binary ())
+ if (wbinary ())
{
debug_printf ("binary write");
res = raw_write (ptr, len);
/* 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
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
{
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
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))
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:
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)
}
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);
}
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");
}
struct dirent;
struct iovec;
-enum connect_state
+enum conn_state
{
unconnected = 0,
connect_pending = 1,
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 */
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;
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 get_w_binset () { return status.wbinset; }
- bool get_r_binset () { return status.rbinset; }
+ bool wbinary () const { return status.wbinset ? status.wbinary : 1; }
+ bool rbinary () const { return status.rbinset ? status.rbinary : 1; }
- 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 wbinset () const { return status.wbinset; }
+ bool rbinset () const { return status.rbinset; }
- 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 ()
? O_BINARY : O_TEXT));
}
- int get_default_fmode (int flags);
+ 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 get_r_no_interrupt () { return status.uninterruptible_io; }
- void set_r_no_interrupt (bool b) { status.uninterruptible_io = 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_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);
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;
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; }
+
+ bool saw_shutdown_read () const { return status.saw_shutdown_read; }
+ bool saw_shutdown_write () const { return status.saw_shutdown_write; }
- void set_shutdown_read () { status.sock_saw_shut_rd = 1;}
- void set_shutdown_write () { status.sock_saw_shut_wr = 1;}
+ void saw_shutdown_read (bool b) { status.saw_shutdown_read = b;}
+ void saw_shutdown_write (bool b) { status.saw_shutdown_write = b;}
- 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; }
+ 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);
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 ();
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);}
{}
} 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);
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&);
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 ();
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);
_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; }
};
_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);
membuffer = NULL;
if (!cygnativeformat)
cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE);
- set_nohandle (true);
+ nohandle (true);
set_open_status ();
return 1;
}
{
/* 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);
void
fhandler_console::set_input_state ()
{
- if (tc->needs_rstcons ())
+ if (tc->rstcons ())
input_tcsetattr (0, &tc->ti);
}
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,
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);
#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
res, t, flags, t->c_lflag, t->c_iflag);
}
- tc->clear_rstcons ();
+ tc->rstcons (false);
return res;
}
}
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);
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);
if (get_io_handle ())
{
- if (get_nohandle ())
+ if (nohandle ())
return fstat_by_name (buf);
else
return fstat_by_handle (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)
/* 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
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. */
res = dir;
- if (pc.isencoded ())
- set_encoded ();
}
syscall_printf ("%p = opendir (%s)", res, get_name ());
}
/* 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);
{ /* 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 */
if (i == 0)
{
read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
- set_need_fork_fixup ();
+ need_fork_fixup (true);
}
}
CloseHandle (hp);
if (!res)
goto out;
- set_nohandle (true);
+ nohandle (true);
const char *path;
if (!res)
goto out;
- set_nohandle (true);
+ nohandle (true);
const char *path;
path = get_name () + proc_len + 1;
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;
}
fhandler_dev_raw::fhandler_dev_raw ()
: fhandler_base (), status ()
{
- set_need_fork_fixup ();
+ need_fork_fixup (true);
}
fhandler_dev_raw::~fhandler_dev_raw (void)
fhandler_serial::fhandler_serial ()
: fhandler_base (), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid)
{
- set_need_fork_fixup ();
+ need_fork_fixup (true);
}
void
(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 ();
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)
{
/* 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;
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);
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
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);
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)
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)
{
{
/* 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)
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;
}
if (res)
set_winsock_errno ();
else
- set_connect_state (connected);
+ connect_state (connected);
return res;
}
((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
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;
*(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);
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);
}
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);
}
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;
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
}
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)
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
}
}
}
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);
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;
}
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;
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);
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;
}
}
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);
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;
}
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]; }
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;
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
if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s))
{
*fd2p = newfd;
- ((fhandler_socket *) fd2p)->set_connect_state (connected);
+ ((fhandler_socket *) fd2p)->connect_state (connected);
}
else
{
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
if (newfd >= 0 && fdsock (newfd, tcp_dev, fd2s))
{
- ((fhandler_socket *) fd2p)->set_connect_state (connected);
+ ((fhandler_socket *) fd2p)->connect_state (connected);
*fd2p = newfd;
}
else
((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);
((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;
#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)
{
}
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
* 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;
-
- if (idx < MAX_FS_INFO_CNT && drive_type_storage != DRIVE_REMOVABLE)
- fsinfo[idx] = *this;
+ 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"));
+
+ /* 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;
}
fileattr = local.dwFileAttributes;
fs.serial () = local.dwVolumeSerialNumber;
}
- fs.drive_type () = DRIVE_UNKNOWN;
+ fs.drive_type (DRIVE_UNKNOWN);
}
void
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))
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)
{
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 ())
- 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);
+ 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. */
}
if (exec_state () != dont_know_if_executable)
/* ok */;
#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;
}
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 *);
};
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
{
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)));
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 ()
{
}
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)
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;
{
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;
{
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)
{
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);
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;
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 ();
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))
{
}
#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;
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;
extern "C" int
statfs (const char *fname, struct statfs *sfs)
{
+ char root_dir[CYG_MAX_PATH];
+
if (!sfs)
{
set_errno (EFAULT);
}
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);
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;}