fcntl on x64
manipulate file descriptor
sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
| number | 72 (0x48) |
|---|---|
| abi | common |
| entry point | sys_fcntl |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | fcntl(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 72, the syscall number |
rdi | unsigned int fd |
rsi | unsigned int cmd |
rdx | unsigned long arg |
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 55
- arm64 25
- arm 55
- riscv64 25
- ia32 55
- x32 1073741896
- loongarch64 25
- ppc64 55
- ppc 55
- s390x 55
- mips64 5070
- mipsn32 6070
- mipso32 4055
- alpha 92
- blackfin 55, removed in 4.17
- cris 55, removed in 4.17
- frv 55, removed in 4.17
- ia64 1066, removed in 6.7
- m68k 55
- microblaze 55
- mn10300 55, removed in 4.17
- parisc 55
- score 1052, removed in 4.17
- sh 55
- sparc 92
- sparc64 92
- tilegx 25, removed in 4.17
- xtensa 67
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/fcntl