From 48501af98f3cdf0115a469ee8d773cf74c42958d Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Fri, 14 Mar 2014 13:16:25 +0000 Subject: [PATCH] AArch64: Fix flock64 for LP64. On LP64 systems F_GETLK64, F_SETLK64 and F_SETLKW64 definitions should map onto the F_GETLK, F_SETLK and F_SETLKW definitions, respectively. LP64 also doesn't have a struct flock64. Change-Id: Ibdfed9645d9e946999acd6efa8b96ea6238ed5bf Signed-off-by: Marcus Oakland Signed-off-by: Serban Constantinescu --- libc/include/fcntl.h | 14 ++++++++++++++ tests/fcntl_test.cpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 779a089f0..cd68154f7 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -37,6 +37,20 @@ __BEGIN_DECLS +#ifdef __LP64__ +/* LP64 kernels don't have flock64 because their flock is 64-bit. */ +struct flock64 { + short l_type; + short l_whence; + off64_t l_start; + off64_t l_len; + pid_t l_pid; +}; +#define F_GETLK64 F_GETLK +#define F_SETLK64 F_SETLK +#define F_SETLKW64 F_SETLKW +#endif + #ifndef O_ASYNC #define O_ASYNC FASYNC #endif diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp index 4aac46823..725ac4a4c 100644 --- a/tests/fcntl_test.cpp +++ b/tests/fcntl_test.cpp @@ -116,3 +116,19 @@ TEST(fcntl, fallocate) { ASSERT_EQ(0, fstat(tf.fd, &sb)); ASSERT_EQ(4, sb.st_size); } + +TEST(fcntl, f_getlk64) { + int fd = open64("/proc/version", O_RDONLY); + ASSERT_TRUE(fd != -1); + + struct flock64 check_lock; + check_lock.l_type = F_WRLCK; + check_lock.l_start = 0; + check_lock.l_whence = SEEK_SET; + check_lock.l_len = 0; + + int rc = fcntl(fd, F_GETLK64, &check_lock); + ASSERT_EQ(0, rc); + + close(fd); +}