]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Support lockf at offset 0 with size 0 or 1.
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 19 Nov 2018 19:22:30 +0000 (20:22 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 19 Nov 2018 19:22:30 +0000 (20:22 +0100)
* sysdeps/mach/hurd/f_setlk.c: Include <unistd.h>.
(__f_setlk): When whence is SEEK_CUR, use __lseek64 to convert it to
SEEK_SET.

ChangeLog
sysdeps/mach/hurd/f_setlk.c

index fdd7bf308104d6ed833ded4deb1f4bb0a2c0d2ca..bb2824c715b6e1eab435898124ea80b4a7b4b9e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-19  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+       * sysdeps/mach/hurd/f_setlk.c: Include <unistd.h>.
+       (__f_setlk): When whence is SEEK_CUR, use __lseek64 to convert it to
+       SEEK_SET.
+
 2018-11-19  Mao Han  <han_mao@c-sky.com>
 
        * scripts/config.guess: Update to version 2018-08-29.
index 718af67e3280c788c45b406d188b5f0e64a54784..edfb292dbf1c1a9fd188bb7553e4cb90cb73e075 100644 (file)
@@ -19,6 +19,7 @@
 #include <sys/types.h>
 #include <sys/file.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <errno.h>
 
 /* XXX
@@ -45,6 +46,18 @@ __f_setlk (int fd, int type, int whence, __off64_t start, __off64_t len, int wai
   if (cmd != LOCK_UN && wait == 0)
     cmd |= LOCK_NB;
 
+  if (whence == SEEK_CUR)
+    {
+      /* In case the target position is 0, we can support it below.  */
+      __off64_t cur = __lseek64 (fd, 0, SEEK_CUR);
+
+      if (cur >= 0)
+       {
+         start = cur + start;
+         whence = SEEK_SET;
+       }
+    }
+
   switch (whence)
     {
     case SEEK_SET: