* 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.
This commit is contained in:
Corinna Vinschen 2005-12-14 16:38:22 +00:00
parent e3d14af155
commit ba31e832be
5 changed files with 27 additions and 15 deletions

View File

@ -1,3 +1,15 @@
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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);