copy_file_range on x64
Copy a range of data from one file to another
sys_copy_file_range(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags)
| number | 326 (0x146) |
|---|---|
| abi | common |
| entry point | sys_copy_file_range |
| since | Linux 4.5 |
| man page | copy_file_range(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 326, the syscall number |
rdi | int fd_in |
rsi | loff_t *off_in |
rdx | int fd_out |
r10 | loff_t *off_out |
r8 | size_t len |
r9 | 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 377
- arm64 285
- arm 391
- riscv64 285
- ia32 377
- x32 1073742150
- loongarch64 285
- ppc64 379
- ppc 379
- s390x 375
- mips64 5320
- mipsn32 6324
- mipso32 4360
- alpha 519
- arc 285
- csky 285
- hexagon 285
- ia64 1347, removed in 6.7
- m68k 376
- metag 285, removed in 4.17
- microblaze 392
- nds32 285, removed in 5.18
- nios2 285
- openrisc 285
- parisc 346
- score 285, removed in 4.17
- sh 380
- sparc 357
- sparc64 357
- tilegx 285, removed in 4.17
- tilepro 285, removed in 4.17
- xtensa 345
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/copy_file_range