]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: linkat: support Linux-specific AT_EMPTY_PATH flag
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 7 Jan 2019 18:36:37 +0000 (19:36 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 7 Jan 2019 18:36:37 +0000 (19:36 +0100)
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
newlib/libc/include/sys/_default_fcntl.h
winsup/cygwin/release/2.12.0
winsup/cygwin/syscalls.cc
winsup/doc/new-features.xml

index 2dc0068c95318c948a146da2bf614dec281cd3ad..0647e590f45d63a137c4afee6b3d5e20217d7d94 100644 (file)
@@ -166,6 +166,7 @@ extern "C" {
 #define AT_SYMLINK_NOFOLLOW     2
 #define AT_SYMLINK_FOLLOW       4
 #define AT_REMOVEDIR            8
+#define AT_EMPTY_PATH          16
 #endif
 
 #if __BSD_VISIBLE
index c9e63a6ba70fc72fc390ed768c42d0e13469700e..81a55b58d7e0871344a74f357674a73a91fb061a 100644 (file)
@@ -22,6 +22,8 @@ What's new:
 
 - Support Linux-specific open(2) flag O_PATH.
 
+- Support Linux-specific linkat(2) flag AT_EMPTY_PATH.
+
 
 What changed:
 -------------
index d6f81cab97476cac2253de8fc8286185adeee178..cb62a6242fee943e128ceff6d771c3fcc3148800 100644 (file)
@@ -4812,13 +4812,29 @@ linkat (int olddirfd, const char *oldpathname,
   tmp_pathbuf tp;
   __try
     {
-      if (flags & ~AT_SYMLINK_FOLLOW)
+      if (flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH))
        {
          set_errno (EINVAL);
          __leave;
        }
       char *oldpath = tp.c_get ();
-      if (gen_full_path_at (oldpath, olddirfd, oldpathname))
+      /* AT_EMPTY_PATH with an empty oldpathname is equivalent to
+
+          linkat(AT_FDCWD, "/proc/self/fd/<olddirfd>", newdirfd,
+                 newname, AT_SYMLINK_FOLLOW);
+
+        Convert the request accordingly. */
+      if ((flags & AT_EMPTY_PATH) && oldpathname && oldpathname[0] == '\0')
+       {
+         if (olddirfd == AT_FDCWD)
+           {
+             set_errno (EPERM);
+             __leave;
+           }
+         __small_sprintf (oldpath, "/proc/%d/fd/%d", myself->pid, olddirfd);
+         flags = AT_SYMLINK_FOLLOW;
+       }
+      else if (gen_full_path_at (oldpath, olddirfd, oldpathname))
        __leave;
       char *newpath = tp.c_get ();
       if (gen_full_path_at (newpath, newdirfd, newpathname))
index b55e031bc7993b75fe22aa57737c518429a8d372..f84a9c44385480a4ba5514965631a2d527f2efe7 100644 (file)
@@ -41,6 +41,10 @@ Support for exFAT.
 Support Linux-specific open(2) flag O_PATH.
 </para></listitem>
 
+<listitem><para>
+- Support Linux-specific linkat(2) flag AT_EMPTY_PATH.
+</para></listitem>
+
 <listitem><para>
 clock_nanosleep, pthread_condattr_setclock and timer_create now support
 all clocks, except CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID.
This page took 0.041505 seconds and 5 git commands to generate.