linkat on x64
make a new name for a file
sys_linkat(int olddfd, const char *oldname, int newdfd, const char *newname, int flags)
| number | 265 (0x109) |
|---|---|
| abi | common |
| entry point | sys_linkat |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | linkat(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 265, the syscall number |
rdi | int olddfd |
rsi | const char *oldname |
rdx | int newdfd |
r10 | const char *newname |
r8 | 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 303
- arm64 37
- arm 330
- riscv64 37
- ia32 303
- x32 1073742089
- loongarch64 37
- ppc64 294
- ppc 294
- s390x 296
- mips64 5255
- mipsn32 6259
- mipso32 4296
- alpha 458
- arc 37
- blackfin 303, removed in 4.17
- cris 303, removed in 4.17
- csky 37
- frv 303, removed in 4.17
- hexagon 37
- ia64 1289, removed in 6.7
- m32r 303, removed in 4.17
- m68k 296
- metag 37, removed in 4.17
- microblaze 303
- mn10300 304, removed in 4.17
- nds32 37, removed in 5.18
- nios2 37
- openrisc 37
- parisc 283
- score 37, removed in 4.17
- sh 303
- sparc 292
- sparc64 292
- tilegx 37, removed in 4.17
- tilepro 37, removed in 4.17
- xtensa 293
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/linkat