truncate on x64
truncate a file to a specified length
sys_truncate(const char *path, long length)
| number | 76 (0x4c) |
|---|---|
| abi | common |
| entry point | sys_truncate |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | truncate(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 76, the syscall number |
rdi | const char *path |
rsi | long length |
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 92
- arm64 45
- arm 92
- riscv64 45
- ia32 92
- x32 1073741900
- loongarch64 45
- ppc64 92
- ppc 92
- s390x 92
- mips64 5074
- mipsn32 6074
- mipso32 4092
- alpha 129
- blackfin 92, removed in 4.17
- cris 92, removed in 4.17
- frv 92, removed in 4.17
- ia64 1097, removed in 6.7
- m32r 92, removed in 4.17
- m68k 92
- microblaze 92
- mn10300 92, removed in 4.17
- parisc 92
- score 1048, removed in 4.17
- sh 92
- sparc 129
- sparc64 129
- tilegx 45, removed in 4.17
- xtensa 22
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/truncate