stat on x64
get file status
sys_newstat(const char *filename, struct stat *statbuf)
| number | 4 (0x4) |
|---|---|
| abi | common |
| entry point | sys_newstat |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | stat(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 4, the syscall number |
rdi | const char *filename |
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 106
- arm 106
- ia32 106
- x32 1073741828
- ppc64 106
- ppc 106
- s390x 106
- mips64 5004
- mipsn32 6004
- mipso32 4106
- alpha 67
- blackfin 106, removed in 4.17
- cris 106, removed in 4.17
- frv 106, removed in 4.17
- ia64 1210, removed in 6.7
- m32r 106, removed in 4.17
- m68k 106
- microblaze 106
- mn10300 106, removed in 4.17
- parisc 18
- score 1049, removed in 4.17
- sh 106
- sparc 38
- sparc64 38
- xtensa 46
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/stat