Re: grub2 confusion

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

 



On Thu, Oct 06, 2011 at 05:05:06PM -0600, Eric Blake wrote:
> 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.

I think that in this particular case you are overdoing that concern.
These are small files and real writes are in blocks and not
characters.

> rename(2) (via mv(1), if both files are on the 
> same device) is.  Any solution that does not use rename(2) is flawed, 

Only with this caveat that the current use of mv in grub2-mkconfig
is not only flawed but also clearly completely broken.  If you want
to keep 'mv' then you first have to use 'readlink' on a target and
replace that target if readlink returns a non-empty string.  Why
not after all?  Something like that

    while target="$(readlink ${grub_cfg})" ; do
	grub_cfg="${target}"
    done

in case you would have multilevel symlinks.

     Michal
-- 
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