Skip to contentSkip to conversation

dracut: write initramfs to temp file then move into place

PATCH In review [email protected] 2 participants 2 messages Feb 21, 2013 – Feb 22, 2013 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dracut: write initramfs to temp file then move into place

From: "Lars R. Damerow" <[email protected]>

We've been finding cases where multiple instances of dracut can be launched simultaneously, resulting in a corrupted initramfs file. This patch makes dracut write the initramfs to a new file, then move it into place atomically.

---
 dracut.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
dracut.sh +3 -2
index 31cf2a5..da96aaa 100755
@@ -1103,10 +1103,11 @@ fi
 rm -f "$outfile"
 dinfo "*** Creating image file ***"
 if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
-    $compress > "$outfile"; ); then
-    dfatal "dracut: creation of $outfile failed"
+    $compress > "$outfile.$$"; ); then
+    dfatal "dracut: creation of $outfile.$$ failed"
     exit 1
 fi
+mv $outfile.$$ $outfile
 dinfo "*** Creating image file done ***"
 
 dinfo "Wrote $outfile:"
Signature · 1 line
1.8.0

A message that is not in the archive (sent off-list or not yet received): 1361482823-30898-1-git-send-email-lars-3XmpO8hA3EAAvxtiuMwx3w@public.gmane.org

#2 lore raw

Am 21.02.2013 22:40, schrieb [email protected]:

Quoted 18 lines

From: "Lars R. Damerow" <[email protected]>

We've been finding cases where multiple instances of dracut can be launched simultaneously, resulting in a corrupted initramfs file. This patch makes dracut write the initramfs to a new file, then move it into place atomically.

---
 dracut.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
dracut.sh +0 -0
index 31cf2a5..da96aaa 100755
@@ -1103,10 +1103,11 @@ fi
 rm -f "$outfile"
 dinfo "*** Creating image file ***"
 if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \

dracut.sh fi · line 1113

Quoted 10 lines
dracut.sh +3 -2
-    $compress > "$outfile"; ); then
-    dfatal "dracut: creation of $outfile failed"
+    $compress > "$outfile.$$"; ); then
+    dfatal "dracut: creation of $outfile.$$ failed"
     exit 1
 fi
+mv $outfile.$$ $outfile
 dinfo "*** Creating image file done ***"
 
 dinfo "Wrote $outfile:"

Yes, right!
Thanks for the patch!