From 64d6e1d43e0b749f8eb2dc58ceeb592b9154d6e1 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 11 Feb 2009 16:06:39 +0000 Subject: [PATCH] * syscalls.cc (open): Handle O_DIRECTORY flag. * include/fcntl.h: Add SUSv4 flags O_DIRECTORY, O_EXEC and O_SEARCH. * include/cygwin/version.h: Bump API minor number. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/include/fcntl.h | 7 ++++++- winsup/cygwin/syscalls.cc | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3215b0ced..cf0972087 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-02-11 Corinna Vinschen + + * syscalls.cc (open): Handle O_DIRECTORY flag. + * include/fcntl.h: Add SUSv4 flags O_DIRECTORY, O_EXEC and O_SEARCH. + * include/cygwin/version.h: Bump API minor number. + 2009-02-09 Corinna Vinschen * fhandler_floppy.cc (fhandler_dev_floppy::open): Fix format. Add diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 362edc1ee..da7658dc3 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -342,12 +342,13 @@ details. */ 191: Export glob_pattern_p 192: CW_SETERRNO added 193: Export wcstok. + 194: fcntl.h flags O_DIRECTORY, O_EXEC and O_SEARCH added. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 193 +#define CYGWIN_VERSION_API_MINOR 194 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/include/fcntl.h b/winsup/cygwin/include/fcntl.h index 3e88f35f4..0ef798815 100644 --- a/winsup/cygwin/include/fcntl.h +++ b/winsup/cygwin/include/fcntl.h @@ -1,6 +1,6 @@ /* fcntl.h - Copyright 1996, 1998, 2001, 2005, 2006 Red Hat, Inc. + Copyright 1996, 1998, 2001, 2005, 2006, 2009 Red Hat, Inc. This file is part of Cygwin. @@ -17,11 +17,16 @@ details. */ /* sys/fcntl defines values up to 0x40000 (O_NOINHERIT). */ #define _FDIRECT 0x80000 #define _FNOFOLLOW 0x100000 +#define _FDIRECTORY 0x200000 +#define _FEXECSRCH 0x400000 #define O_DIRECT _FDIRECT #define O_NOFOLLOW _FNOFOLLOW #define O_DSYNC _FSYNC #define O_RSYNC _FSYNC +#define O_DIRECTORY _FDIRECTORY +#define O_EXEC _FEXECSRCH +#define O_SEARCH _FEXECSRCH #define POSIX_FADV_NORMAL 0 #define POSIX_FADV_SEQUENTIAL 1 diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index c68599246..af26e008b 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -969,6 +969,12 @@ open (const char *unix_path, int flags, ...) res = -1; set_errno (ELOOP); } + else if ((flags & O_DIRECTORY) && !fh->pc.isdir ()) + { + delete fh; + res = -1; + set_errno (ENOTDIR); + } else if (((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) && fh->exists ()) { delete fh; -- 2.43.5