flock on x64
apply or remove an advisory lock on an open file
sys_flock(unsigned int fd, unsigned int cmd)
| number | 73 (0x49) |
|---|---|
| abi | common |
| entry point | sys_flock |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | flock(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 73, the syscall number |
rdi | unsigned int fd |
rsi | unsigned int cmd |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 143
- arm64 32
- arm 143
- riscv64 32
- ia32 143
- x32 1073741897
- loongarch64 32
- ppc64 143
- ppc 143
- s390x 143
- mips64 5071
- mipsn32 6071
- mipso32 4143
- alpha 131
- arc 32
- blackfin 143, removed in 4.17
- cris 143, removed in 4.17
- csky 32
- frv 143, removed in 4.17
- hexagon 32
- ia64 1145, removed in 6.7
- m32r 143, removed in 4.17
- m68k 143
- metag 32, removed in 4.17
- microblaze 143
- mn10300 143, removed in 4.17
- nds32 32, removed in 5.18
- nios2 32
- openrisc 32
- parisc 143
- score 32, removed in 4.17
- sh 143
- sparc 131
- sparc64 131
- tilegx 32, removed in 4.17
- tilepro 32, removed in 4.17
- xtensa 56
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/flock