Sunday, January 9, 2022

[SOLVED] Copy file without using standard library function in C

Issue

How can I copy a file without using standard C library functions in Linux? In other words, I would like to copy a file directly with system calls. Is it possible?


Solution

file directly with system calls. Is it possible?

In pseudocode, using sendfile:

int in = open("input", ...);
fstatat(in, &stat);
int out = open("output", ...);
sendfile(in, out, NULL, stat.st_size);


Answered By - KamilCuk