On Tue, Oct 13, 2009 at 06:59:11PM -0000, Jordan wrote:
> However, it looks like grub-editenv is still not atomic: If you run
> "grub-editenv /boot/grub/grubenv set foo=bar" the first thing it does in
> create_env_blk_file() is call fopen( "/boot/grub/grubenv", "wb" )
> truncating the actual file, not a temporary version. So if grub-editenv
> crashes between the fopen() and the fwrite() ( admittedly only two real
> lines of code ) or somehow fopen() succeeds but fwrite() fails, you will
> be left with a zero byte file.
I indeed noticed the same thing a couple of weeks ago, and fixed it
upstream for GRUB 1.97~beta4. :-)
2009-10-01 Colin Watson <email address hidden>
* util/grub-editenv.c (create_envblk_file): Write new block with a
.new suffix and then rename it into place, to ensure atomic
creation.
On Tue, Oct 13, 2009 at 06:59:11PM -0000, Jordan wrote: env_blk_ file() is call fopen( "/boot/ grub/grubenv" , "wb" )
> However, it looks like grub-editenv is still not atomic: If you run
> "grub-editenv /boot/grub/grubenv set foo=bar" the first thing it does in
> create_
> truncating the actual file, not a temporary version. So if grub-editenv
> crashes between the fopen() and the fwrite() ( admittedly only two real
> lines of code ) or somehow fopen() succeeds but fwrite() fails, you will
> be left with a zero byte file.
I indeed noticed the same thing a couple of weeks ago, and fixed it
upstream for GRUB 1.97~beta4. :-)
2009-10-01 Colin Watson <email address hidden>
* util/grub-editenv.c (create_ envblk_ file): Write new block with a
.new suffix and then rename it into place, to ensure atomic
creation.