Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-12-22 19:45:15 +0300
committerCorinna Vinschen <corinna@vinschen.de>2005-12-22 19:45:15 +0300
commit52792a770dd5c40202ea98917b8af384b60da83c (patch)
treee9317162611e0445c04cd46dfddca71a2c752070
parentdb55f91dc081407404559ebe50f126fed048800e (diff)
* fhandler.h (fhandler_base::issymlink): New method.
* syscalls.cc (open): Handle O_NOFOLLOW flag. * include/fcntl.h (_FNOFOLLOW): New define. (O_NOFOLLOW): Ditto. * include/cygwin/version.h: Bump API minor number.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/fhandler.h1
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/include/fcntl.h2
-rw-r--r--winsup/cygwin/syscalls.cc9
5 files changed, 21 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5a97111dd..b5ce9988b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2005-12-22 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler.h (fhandler_base::issymlink): New method.
+ * syscalls.cc (open): Handle O_NOFOLLOW flag.
+ * include/fcntl.h (_FNOFOLLOW): New define.
+ (O_NOFOLLOW): Ditto.
+ * include/cygwin/version.h: Bump API minor number.
+
2005-12-22 Christopher Faylor <cgf@timesys.com>
* pinfo.cc (winpids::add): Increment nelem when winpid is true since we
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 0456ceca1..86c318156 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -363,6 +363,7 @@ class fhandler_base
virtual bool is_slow () {return 0;}
bool is_auto_device () {return isdevice () && !dev ().isfs ();}
bool is_fs_special () {return pc.is_fs_special ();}
+ bool issymlink () {return pc.issymlink ();}
bool device_access_denied (int) __attribute__ ((regparm (2)));
int fhaccess (int flags) __attribute__ ((regparm (2)));
friend class fhandler_fifo;
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 048b06e9d..d284a0772 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -283,12 +283,13 @@ details. */
147: Eliminate problematic d_ino from dirent structure. unsetenv now returns
int, as per linux.
148: Add open(2) flags O_SYNC, O_RSYNC, O_DSYNC and O_DIRECT.
+ 149: Add open(2) flag O_NOFOLLOW.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 148
+#define CYGWIN_VERSION_API_MINOR 149
/* 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 33b0692b3..6e50b3304 100644
--- a/winsup/cygwin/include/fcntl.h
+++ b/winsup/cygwin/include/fcntl.h
@@ -16,8 +16,10 @@ details. */
/* sys/fcntl defines values up to 0x40000 (O_NOINHERIT). */
#define _FDIRECT 0x80000
+#define _FNOFOLLOW 0x100000
#define O_DIRECT _FDIRECT
+#define O_NOFOLLOW _FNOFOLLOW
#define O_DSYNC _FSYNC
#define O_RSYNC _FSYNC
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index cdfce29af..9c938d572 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -597,8 +597,15 @@ open (const char *unix_path, int flags, ...)
if (fd >= 0)
{
- if (!(fh = build_fh_name (unix_path, NULL, PC_SYM_FOLLOW)))
+ if (!(fh = build_fh_name (unix_path, NULL, (flags & O_NOFOLLOW) ?
+ PC_SYM_NOFOLLOW : PC_SYM_FOLLOW)))
res = -1; // errno already set
+ else if ((flags & O_NOFOLLOW) && fh->issymlink ())
+ {
+ delete fh;
+ res = -1;
+ set_errno (ELOOP);
+ }
else if (((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) && fh->exists ())
{
delete fh;