open_by_handle_at on x64
obtain handle for a pathname and open file via a handle
sys_open_by_handle_at(int mountdirfd, struct file_handle *handle, int flags)
| number | 304 (0x130) |
|---|---|
| abi | common |
| kconfig | CONFIG_FHANDLE |
| entry point | sys_open_by_handle_at |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | open_by_handle_at(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 304, the syscall number |
rdi | int mountdirfd |
rsi | struct file_handle *handle |
rdx | 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 342
- arm64 265
- arm 371
- riscv64 265
- ia32 342
- x32 1073742128
- loongarch64 265
- ppc64 346
- ppc 346
- s390x 336
- mips64 5299
- mipsn32 6304
- mipso32 4340
- alpha 498
- arc 265
- blackfin 376, removed in 4.17
- cris 337, removed in 4.17
- csky 265
- hexagon 265
- ia64 1327, removed in 6.7
- m68k 341
- metag 265, removed in 4.17
- microblaze 372
- nds32 265, removed in 5.18
- nios2 265
- openrisc 265
- parisc 326
- score 265, removed in 4.17
- sh 360
- sparc 333
- sparc64 333
- tilegx 265, removed in 4.17
- tilepro 265, removed in 4.17
- xtensa 325
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/open_by_handle_at