diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-12-14 19:38:22 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-12-14 19:38:22 +0300 |
commit | ba31e832be0bba89d8848aaea6e6eebbe7c56355 (patch) | |
tree | bf1d14a289bc179027fb597a8ee04174f1ab7015 /winsup/cygwin | |
parent | e3d14af155fb84890a32fad7f7706967ac5bc7d9 (diff) |
* fhandler.cc (ACCFLAGS): Remove macro.
(fhandler_base::get_default_fmode): Use O_ACCMODE instead of ACCFLAGS
and or'ed read/write flags.
(fhandler_base::open_9x): Use O_ACCMODE instead of or'ed read/write
flags.
(fhandler_base::open): Ditto.
* fhandler_disk_file.cc (fhandler_base::open_fs): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::open): Ditto.
* fhandler_raw.cc (fhandler_dev_raw::open): Ditto.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 12 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 22 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_mem.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_raw.cc | 2 |
5 files changed, 27 insertions, 15 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2591eab4d..179891cf3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,17 @@ 2005-12-14 Corinna Vinschen <corinna@vinschen.de> + * fhandler.cc (ACCFLAGS): Remove macro. + (fhandler_base::get_default_fmode): Use O_ACCMODE instead of ACCFLAGS + and or'ed read/write flags. + (fhandler_base::open_9x): Use O_ACCMODE instead of or'ed read/write + flags. + (fhandler_base::open): Ditto. + * fhandler_disk_file.cc (fhandler_base::open_fs): Ditto. + * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. + * fhandler_raw.cc (fhandler_dev_raw::open): Ditto. + +2005-12-14 Corinna Vinschen <corinna@vinschen.de> + * fhandler.cc (fhandler_base::open_9x): Handle O_SYNC and O_DIRECT flags. (fhandler_base::open): Ditto. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 0a119c845..e1686e1cf 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -298,7 +298,6 @@ written: return bytes_written; } -#define ACCFLAGS(x) (x & (O_RDONLY | O_WRONLY | O_RDWR)) int fhandler_base::get_default_fmode (int flags) { @@ -306,11 +305,11 @@ fhandler_base::get_default_fmode (int flags) if (perfile_table) { size_t nlen = strlen (get_name ()); - unsigned accflags = ACCFLAGS (flags); + unsigned accflags = (flags & O_ACCMODE); for (__cygwin_perfile *pf = perfile_table; pf->name; pf++) - if (!*pf->name && ACCFLAGS (pf->flags) == accflags) + if (!*pf->name && (pf->flags & O_ACCMODE) == accflags) { - fmode = pf->flags & ~(O_RDONLY | O_WRONLY | O_RDWR); + fmode = pf->flags & ~O_ACCMODE; break; } else @@ -319,9 +318,10 @@ fhandler_base::get_default_fmode (int flags) const char *stem = get_name () + nlen - pflen; if (pflen > nlen || (stem != get_name () && !isdirsep (stem[-1]))) continue; - else if (ACCFLAGS (pf->flags) == accflags && strcasematch (stem, pf->name)) + else if ((pf->flags & O_ACCMODE) == accflags + && strcasematch (stem, pf->name)) { - fmode = pf->flags & ~(O_RDONLY | O_WRONLY | O_RDWR); + fmode = pf->flags & ~O_ACCMODE; break; } } @@ -459,9 +459,9 @@ fhandler_base::open_9x (int flags, mode_t mode) access = GENERIC_READ | FILE_WRITE_ATTRIBUTES; break; default: - if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY) + if ((flags & O_ACCMODE) == O_RDONLY) access = GENERIC_READ; - else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY) + else if ((flags & O_ACCMODE) == O_WRONLY) access = GENERIC_WRITE; else access = GENERIC_READ | GENERIC_WRITE; @@ -524,7 +524,7 @@ fhandler_base::open_9x (int flags, mode_t mode) { if (pc.isdir ()) { - if (flags & (O_WRONLY | O_RDWR)) + if ((flags & O_ACCMODE) != O_RDONLY) set_errno (EISDIR); else nohandle (true); @@ -603,9 +603,9 @@ fhandler_base::open (int flags, mode_t mode) break; default: create_options = 0; - if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY) + if ((flags & O_ACCMODE) == O_RDONLY) access = GENERIC_READ; - else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY) + else if ((flags & O_ACCMODE) == O_WRONLY) access = GENERIC_WRITE | FILE_READ_ATTRIBUTES; else access = GENERIC_READ | GENERIC_WRITE; diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 51c4972ae..5b684e5e7 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -956,7 +956,7 @@ fhandler_base::open_fs (int flags, mode_t mode) /* Unfortunately NT allows to open directories for writing, but that's disallowed according to SUSv3. */ - if (pc.isdir () && (flags & (O_WRONLY | O_RDWR))) + if (pc.isdir () && (flags & O_ACCMODE) != O_RDONLY) { set_errno (EISDIR); return 0; diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc index c0d865d28..24d681d4e 100644 --- a/winsup/cygwin/fhandler_mem.cc +++ b/winsup/cygwin/fhandler_mem.cc @@ -88,12 +88,12 @@ fhandler_dev_mem::open (int flags, mode_t) NULL, NULL); ACCESS_MASK section_access; - if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY) + if ((flags & O_ACCMODE) == O_RDONLY) { set_access (GENERIC_READ); section_access = SECTION_MAP_READ; } - else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY) + else if ((flags & O_ACCMODE) == O_WRONLY) { set_access (GENERIC_WRITE); section_access = SECTION_MAP_READ | SECTION_MAP_WRITE; diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 0cfb51e6c..77ee252bc 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -84,7 +84,7 @@ fhandler_dev_raw::open (int flags, mode_t) flags |= O_BINARY; /* Write-only doesn't work well with raw devices */ - if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY) + if ((flags & O_ACCMODE) == O_WRONLY) flags = ((flags & ~O_WRONLY) | O_RDWR); int res = fhandler_base::open (flags, 0); |