renameat2 on x64
change the name or location of a file
sys_renameat2(int olddfd, const char *oldname, int newdfd, const char *newname, unsigned int flags)
| number | 316 (0x13c) |
|---|---|
| abi | common |
| entry point | sys_renameat2 |
| since | Linux 3.15 |
| man page | renameat2(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 316, the syscall number |
rdi | int olddfd |
rsi | const char *oldname |
rdx | int newdfd |
r10 | const char *newname |
r8 | unsigned int flags |
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 353
- arm64 276
- arm 382
- riscv64 276
- ia32 353
- x32 1073742140
- loongarch64 276
- ppc64 357
- ppc 357
- s390x 347
- mips64 5311
- mipsn32 6315
- mipso32 4351
- alpha 510
- arc 276
- blackfin 387, removed in 4.17
- cris 354, removed in 4.17
- csky 276
- hexagon 276
- ia64 1338, removed in 6.7
- m68k 351
- metag 276, removed in 4.17
- microblaze 383
- nds32 276, removed in 5.18
- nios2 276
- openrisc 276
- parisc 337
- score 276, removed in 4.17
- sh 371
- sparc 345
- sparc64 345
- tilegx 276, removed in 4.17
- tilepro 276, removed in 4.17
- xtensa 336
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/renameat2