sendfile on x64
transfer data between file descriptors
sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t count)
| number | 40 (0x28) |
|---|---|
| abi | common |
| entry point | sys_sendfile64 |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | sendfile(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 40, the syscall number |
rdi | int out_fd |
rsi | int in_fd |
rdx | loff_t *offset |
r10 | size_t count |
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 187
- arm64 71
- arm 187
- riscv64 71
- ia32 187
- x32 1073741864
- loongarch64 71
- ppc64 186
- ppc 186
- s390x 187
- mips64 5039
- mipsn32 6039
- mipso32 4207
- alpha 370
- blackfin 187, removed in 4.17
- cris 187, removed in 4.17
- frv 187, removed in 4.17
- ia64 1187, removed in 6.7
- m32r 187, removed in 4.17
- m68k 187
- microblaze 187
- mn10300 187, removed in 4.17
- parisc 122
- score 1046, removed in 4.17
- sh 187
- sparc 39
- sparc64 39
- tilegx 71, removed in 4.17
- xtensa 113
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/sendfile