Skip to content

Commit 90d3082

Browse files
committed
Support fcntl F_GETLEASE/F_SETLEASE
Resolves #3932
1 parent 2ec5b8b commit 90d3082

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ set(BASIC_TESTS
10611061
fatal_sigsegv_thread
10621062
x86/fault_in_code_page
10631063
fcntl_dupfd
1064+
fcntl_lease
10641065
fcntl_misc
10651066
fcntl_notify
10661067
fcntl_owner_ex

src/kernel_abi.h

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ struct FcntlConstants {
175175
OFD_SETLK = 37,
176176
OFD_SETLKW = 38,
177177
// Other Linux-specific operations
178+
SETLEASE = 0x400,
179+
GETLEASE = 0x400 + 1,
178180
NOTIFY = 0x400 + 2,
179181
DUPFD_CLOEXEC = 0x400 + 6,
180182
SETPIPE_SZ = 0x400 + 7,

src/record_syscall.cc

+2
Original file line numberDiff line numberDiff line change
@@ -3969,6 +3969,8 @@ static Switchable rec_prepare_syscall_arch(RecordTask* t,
39693969
case Arch::GET_SEALS:
39703970
case Arch::SET_RW_HINT:
39713971
case Arch::SET_FILE_RW_HINT:
3972+
case Arch::SETLEASE:
3973+
case Arch::GETLEASE:
39723974
break;
39733975

39743976
case Arch::SETFD:

src/test/fcntl_lease.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
2+
3+
#include "util.h"
4+
5+
int main(void) {
6+
int fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0600);
7+
test_assert(fd >= 0);
8+
int ret = fcntl(fd, F_SETLEASE, F_WRLCK);
9+
test_assert(!ret);
10+
ret = fcntl(fd, F_GETLEASE);
11+
test_assert(ret == F_WRLCK);
12+
13+
atomic_puts("EXIT-SUCCESS");
14+
return 0;
15+
}

0 commit comments

Comments
 (0)