fchmod on x64
change permissions of a file
sys_fchmod(unsigned int fd, umode_t mode)
| number | 91 (0x5b) |
|---|---|
| abi | common |
| entry point | sys_fchmod |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | fchmod(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 91, the syscall number |
rdi | unsigned int fd |
rsi | umode_t mode |
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 94
- arm64 52
- arm 94
- riscv64 52
- ia32 94
- x32 1073741915
- loongarch64 52
- ppc64 94
- ppc 94
- s390x 94
- mips64 5089
- mipsn32 6089
- mipso32 4094
- alpha 124
- arc 52
- blackfin 94, removed in 4.17
- cris 94, removed in 4.17
- csky 52
- frv 94, removed in 4.17
- hexagon 52
- ia64 1099, removed in 6.7
- m32r 94, removed in 4.17
- m68k 94
- metag 52, removed in 4.17
- microblaze 94
- mn10300 94, removed in 4.17
- nds32 52, removed in 5.18
- nios2 52
- openrisc 52
- parisc 94
- score 52, removed in 4.17
- sh 94
- sparc 124
- sparc64 124
- tilegx 52, removed in 4.17
- tilepro 52, removed in 4.17
- xtensa 52
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/fchmod