fstat on x64
get file status
sys_newfstat(unsigned int fd, struct stat *statbuf)
| number | 5 (0x5) |
|---|---|
| abi | common |
| entry point | sys_newfstat |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | fstat(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 5, the syscall number |
rdi | unsigned int fd |
rsi | struct stat *statbuf |
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 108
- arm64 80
- arm 108
- riscv64 80
- ia32 108
- x32 1073741829
- loongarch64 80
- ppc64 108
- ppc 108
- s390x 108
- mips64 5005
- mipsn32 6005
- mipso32 4108
- alpha 91
- blackfin 108, removed in 4.17
- cris 108, removed in 4.17
- frv 108, removed in 4.17
- ia64 1212, removed in 6.7
- m32r 108, removed in 4.17
- m68k 108
- microblaze 108
- mn10300 108, removed in 4.17
- parisc 28
- score 1051, removed in 4.17
- sh 108
- sparc 62
- sparc64 62
- tilegx 80, removed in 4.17
- xtensa 54
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/fstat