Page MenuHomeFreeBSD

savecore: bail on write error even when decompressing

Authored by rlibby on Dec 10 2020, 8:31 PM.



gcc complained about the impossibility of the test nw < 0 in
DoRegularFile where nw is unsigned. Looking further, this was
preventing code from logging an error writing to the output file while

Test Plan

Tested by doing a zstd dump and then trying to savecore -u it to a
too-small tmpfs fs. Before this patch, savecore "succeeds" (exits 0)
but leaves a truncated core file. After this patch, savecore fails
(exits 1).

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This revision is now accepted and ready to land.Dec 10 2020, 10:16 PM

Should we also add an fflush/fsync? We are now successfully failing--because we get an error early enough, but that is not guaranteed. Waiting for savecore to fsync could slow it down slightly, but that seems okay, given how rare this usually is.