This sample code copies a file using sendfile(2) call works just fine on 2.2.x and 2.4.x kernels. On 2.5.x kernels (not sure starting which version) it stopped working. Program terminates with EINVAL error. $ ./sendfile sendfile: Invalid argument Is this expected behaviour ? that sendfile(2) on 2.5.4x linux kernel requires socket as an output fd paramter ? Was it ever legal to copy file(s) on filesystem using sendfile(2) ? (which was kindda nice feature ... )