sysdeps/mach/hurd/Changelog 2018-12-01 Svante Signell * f_setlk.c: Add support for file-record-lock RPC fixing posix file locking using the flock64 version of struct flock. Replace the __flock() call with __file_record_lock() * fcntl.c: Code moved to f_setlk.c. Don't include * fcntl.h: Removed: Patch not needed any longer. 2014-08-21 Svante Signell * f_setlk.c: Add support for file-record-lock RPC fixing posix file locking using the flock64 version of struct flock. Replace the __flock call with __file_record_lock * fcntl.c: Add support for file-record-lock RPC fixing posix file locking using the flock64 version of struct flock. * bits/fcntl.h: Since MIG cannot mix 32 bit and 64 bit integers define unique numbers for F_GETLK64, F_SETLK64 and F_SETLKW64 to prepare for a flock64 implementation of file record locking in hurd: fixed in glibc-2.28. Index: glibc-2.28-1.1/sysdeps/mach/hurd/fcntl.c =================================================================== --- glibc-2.28-1.1.orig/sysdeps/mach/hurd/fcntl.c +++ glibc-2.28-1.1/sysdeps/mach/hurd/fcntl.c @@ -20,7 +20,6 @@ #include #include #include -#include /* XXX for LOCK_* */ #include "f_setlk.h" /* Perform file control operations on FD. */ Index: glibc-2.28-1.1/sysdeps/mach/hurd/f_setlk.c =================================================================== --- glibc-2.28-1.1.orig/sysdeps/mach/hurd/f_setlk.c +++ glibc-2.28-1.1/sysdeps/mach/hurd/f_setlk.c @@ -18,21 +18,29 @@ #include #include +#include +#include +#include #include #include #include -/* XXX - We need new RPCs to support POSIX.1 fcntl file locking!! - For the time being we support the whole-file case only, - with all kinds of WRONG WRONG WRONG semantics, - by using flock. This is definitely the Wrong Thing, - but it might be better than nothing (?). */ int __f_setlk (int fd, int type, int whence, __off64_t start, __off64_t len, int wait) { int cmd = 0; - + error_t err; + struct hurd_fd *d; + int result; + __pid_t pid = -1; + struct flock64 *fl64 = NULL; + + fl64->l_type = type; + fl64->l_whence = whence; + fl64->l_start = start; + fl64->l_len = len; + fl64->l_pid = pid; + switch (type) { case F_RDLCK: cmd = LOCK_SH | __LOCK_ATOMIC; break; @@ -78,5 +86,12 @@ __f_setlk (int fd, int type, int whence, return -1; } - return __flock (fd, cmd); + d = _hurd_fd_get (fd); + + if (d == NULL) + return __hurd_fail (EBADF); + + err = HURD_FD_PORT_USE (d, __file_record_lock (port, cmd, fl64)); + result = err ? __hurd_dfail (fd, err) : 0; + return result; }