feat: export Linux Open File Description (OFD) lock constants (sqlite#255)
feat: export Linux Open File Description (OFD) lock constants
Adds support for Linux Open File Description (OFD) locks (F_OFD_GETLK = 36,
F_OFD_SETLK = 37, F_OFD_SETLKW = 38) to enable file-descriptor-scoped
POSIX locking in downstream packages like modernc.org/sqlite.
-
Exports
F_OFD_GETLK,F_OFD_SETLK, andF_OFD_SETLKWinfcntl/fcntl_linux_amd64.gowith C header provenance comments matchingccgo -headeroutput. -
Updates
genheaders.goto prepend#define _GNU_SOURCE 1when generatingfcntlheaders. Because LinuxF_OFD_*constants are guarded by#ifdef __USE_GNUin<bits/fcntl-linux.h>, defining_GNU_SOURCEensures these constants are not stripped during future regenerations.Note
While running
ccgo -headerwith_GNU_SOURCEon<fcntl.h>exposes ~123 additional Linux/GNU extension symbols (such asO_TMPFILE,O_PATH,SPLICE_F_*,FALLOC_FL_*, andF_SEAL_*), we intentionally cherry-picked only the threeF_OFD_*constants intofcntl_linux_amd64.goto keep the diff minimal and avoid slurping in unrelated API surface. -
Adds
internal/overlay/musl/src/fcntl/fcntl.cas a musl overlay to route the new OFD commands throughSYS_fcntlwith(void *)argpointer casting and cancellation point handling (syscall_cp).
For reviewer convenience, the exact diff of the overlay against upstream musl's
src/fcntl/fcntl.c is:
--- a/src/fcntl/fcntl.c
+++ b/src/fcntl/fcntl.c
@@ -15,1 +15,1 @@
- if (cmd == F_SETLKW) return syscall_cp(SYS_fcntl, fd, cmd, (void *)arg);
+ if (cmd == F_SETLKW || cmd == F_OFD_SETLKW) return syscall_cp(SYS_fcntl, fd, cmd, (void *)arg);
@@ -41,2 +41,4 @@
case F_SETLK:
case F_GETLK:
+ case F_OFD_SETLK:
+ case F_OFD_GETLK:
case F_GETOWN_EX:Related Merge Requests & Issues:
- Companion Windows build fix needed to compile all targets (
make build_all_targets) and test fixtures: !32 (merged) - Main SQLite tracking issue: cznic/sqlite#255