Re: grub2 confusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/06/2011 05:01 PM, Michael Schwendt wrote:
>>> you would not notice any troubles.
>>
>> Umm, yes you would.  That's not atomic, and risks leaving things in an
>> inconsistent state.
>>
>> http://www.flamingspork.com/talks/2007/06/eat_my_data.odp
>> http://www.pixelbeat.org/docs/unix_file_replacement.html
>
> cp -f ${grub_cfg}.new ${grub_cfg} ; rm -f ${grub_cfg}.new
>
> Better?

No.  cp is not atomic.  rename(2) (via mv(1), if both files are on the 
same device) is.  Any solution that does not use rename(2) is flawed, 
because an ill-timed power-outage will leave the file in an inconsistent 
state.  What you want is that ${grub_cfg} _always_ exists, and is either 
the unchanged original, or atomically the contents of the new 
replacement.  Anything else is a recipe for disaster, for something as 
important as the files that control how you boot your machine.

> I assume you are not concerned about the removal of the temporary
> local file in the second step,

Not as much as I am that ${grub_cfg} always exist, and always have valid 
contents.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-- 
test mailing list
test@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: 
https://admin.fedoraproject.org/mailman/listinfo/test


[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]

  Powered by Linux