getdents64 on x64
get directory entries
sys_getdents64(unsigned int fd, struct linux_dirent64 *dirent, unsigned int count)
| number | 217 (0xd9) |
|---|---|
| abi | common |
| entry point | sys_getdents64 |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | getdents64(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 217, the syscall number |
rdi | unsigned int fd |
rsi | struct linux_dirent64 *dirent |
rdx | unsigned int count |
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 220
- arm64 61
- arm 217
- riscv64 61
- ia32 220
- x32 1073742041
- loongarch64 61
- ppc64 202
- ppc 202
- s390x 220
- mips64 5308
- mipsn32 6299
- mipso32 4219
- alpha 377
- arc 61
- blackfin 220, removed in 4.17
- cris 220, removed in 4.17
- csky 61
- frv 220, removed in 4.17
- hexagon 61
- ia64 1214, removed in 6.7
- m32r 220, removed in 4.17
- m68k 220
- metag 61, removed in 4.17
- microblaze 220
- mn10300 220, removed in 4.17
- nds32 61, removed in 5.18
- nios2 61
- openrisc 61
- parisc 201
- score 61, removed in 4.17
- sh 220
- sparc 154
- sparc64 154
- tilegx 61, removed in 4.17
- tilepro 61, removed in 4.17
- xtensa 60
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/getdents64