save: Use dd with the notrunc & fsync and postpone truncation by JoeKar · Pull Request #3814 · micro-editor/micro (original) (raw)
JoeKar changed the title
save: Use save: Use dd with the notrunc and fsync optiondd with the notrunc option
JoeKar changed the title
save: Use save: Use dd with the notrunc optiondd with the notrunc & fsync option and truncate as command
JoeKar changed the title
save: Use save: Use dd with the notrunc & fsync option and truncate as commanddd with the notrunc & fsync and postpone truncation
Using notrunc will stop the overall truncation of the target file done by sudo.
We need to do this because dd, like other coreutils, already truncates the file
on open(). In case we can't store the backup file afterwards we would end up in
a truncated file for which the user has no write permission by default.
Instead we use a second call of dd to perform the necessary truncation
on the command line.
With the fsync option we force the dd process to synchronize the written file
to the underlying device.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})