-
-
usr/src/lib/libcmdutils/common/writefile.c (Diff revision 1) Not important, but I'd prefer this be a global variable to allow easier manipulation with mdb.
-
usr/src/lib/libcmdutils/common/writefile.c (Diff revision 1) By using sendfile(), you've changed the state in which
fi
will 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. -
usr/src/lib/libcmdutils/common/writefile.c (Diff revision 1) Why continue here if a signal is received?
-
usr/src/lib/libcmdutils/common/writefile.c (Diff revision 1) 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
cp(1) could use sendfile
Review Request #1311 — Created Dec. 2, 2018 and updated
Information | |
---|---|
wiedi | |
illumos-gate | |
Reviewers | |
general | |
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
cp
on 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.
-
-
usr/src/lib/libcmdutils/common/writefile.c (Diff revision 1) You should be able to send the entire file with a single call to sendfile(). Ditch the loop.