getdents on x64
get directory entries
sys_getdents(unsigned int fd, struct linux_dirent *dirent, unsigned int count)
| number | 78 (0x4e) |
|---|---|
| abi | common |
| entry point | sys_getdents |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | getdents(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 78, the syscall number |
rdi | unsigned int fd |
rsi | struct linux_dirent *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 141
- arm 141
- ia32 141
- x32 1073741902
- ppc64 141
- ppc 141
- s390x 141
- mips64 5076
- mipsn32 6076
- mipso32 4141
- alpha 305
- blackfin 141, removed in 4.17
- cris 141, removed in 4.17
- frv 141, removed in 4.17
- ia64 1144, removed in 6.7
- m32r 141, removed in 4.17
- m68k 141
- microblaze 141
- mn10300 141, removed in 4.17
- parisc 141
- score 1065, removed in 4.17
- sh 141
- sparc 174
- sparc64 174
- xtensa 59
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/getdents