cp(1) could use sendfile
Review Request #1311 - Created Dec. 2, 2018 and updated
Change to libcmdutils so that cp(1) uses the sendfile(3ext) interface.
This avoids copying the data between kernel and userspace.
My testing so far includes using this
cpon trees with various file
sizes. I've tested that checksums still match. I've tested error handling
is unchanged when reaching the fs quota. I also booted into a system with this change.
I have not tested this with NFS because I currently don't have such a setup.
libcmdutils:writefile() is also used by
mvin some cases (cross-filesystem move for example) so that should be included in the tests.
Not important, but I'd prefer this be a global variable to allow easier manipulation with mdb.
By using sendfile(), you've changed the state in which
fiwill be left. sendfile() does not modify the file pointer of the input file unlike the previous code.
Do any consumers of
writefile()care? I suspect not but you should check.
Why continue here if a signal is received?
You still need to free srcbuf and targbuf here.
I'd actually be tempted to add an err: label near the bottom of the function and consolidate
(void) close(fi); (void) close(fo); if (S_ISREG(s2p->st_mode)) (void) unlink(targbuf); if (srcbuf != NULL) free(srcbuf); if (targbuf != NULL) free(targbuf); return (1);
which appears three times in this function