fchdir on x64
change working directory
sys_fchdir(unsigned int fd)
| number | 81 (0x51) |
|---|---|
| abi | common |
| entry point | sys_fchdir |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | fchdir(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 81, the syscall number |
rdi | unsigned int fd |
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 133
- arm64 50
- arm 133
- riscv64 50
- ia32 133
- x32 1073741905
- loongarch64 50
- ppc64 133
- ppc 133
- s390x 133
- mips64 5079
- mipsn32 6079
- mipso32 4133
- alpha 13
- arc 50
- blackfin 133, removed in 4.17
- cris 133, removed in 4.17
- csky 50
- frv 133, removed in 4.17
- hexagon 50
- ia64 1035, removed in 6.7
- m32r 133, removed in 4.17
- m68k 133
- metag 50, removed in 4.17
- microblaze 133
- mn10300 133, removed in 4.17
- nds32 50, removed in 5.18
- nios2 50
- openrisc 50
- parisc 133
- score 50, removed in 4.17
- sh 133
- sparc 176
- sparc64 176
- tilegx 50, removed in 4.17
- tilepro 50, removed in 4.17
- xtensa 42
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/fchdir