name_to_handle_at on x64
obtain handle for a pathname and open file via a handle
sys_name_to_handle_at(int dfd, const char *name, struct file_handle *handle, void *mnt_id, int flag)
| number | 303 (0x12f) |
|---|---|
| abi | common |
| kconfig | CONFIG_FHANDLE |
| entry point | sys_name_to_handle_at |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | name_to_handle_at(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 303, the syscall number |
rdi | int dfd |
rsi | const char *name |
rdx | struct file_handle *handle |
r10 | void *mnt_id |
r8 | int flag |
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 341
- arm64 264
- arm 370
- riscv64 264
- ia32 341
- x32 1073742127
- loongarch64 264
- ppc64 345
- ppc 345
- s390x 335
- mips64 5298
- mipsn32 6303
- mipso32 4339
- alpha 497
- arc 264
- blackfin 375, removed in 4.17
- cris 336, removed in 4.17
- csky 264
- hexagon 264
- ia64 1326, removed in 6.7
- m68k 340
- metag 264, removed in 4.17
- microblaze 371
- nds32 264, removed in 5.18
- nios2 264
- openrisc 264
- parisc 325
- score 264, removed in 4.17
- sh 359
- sparc 332
- sparc64 332
- tilegx 264, removed in 4.17
- tilepro 264, removed in 4.17
- xtensa 324
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/name_to_handle_at