[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Making loop-device flexible in the script mkbimage
From: |
Mats Erik Andersson |
Subject: |
Making loop-device flexible in the script mkbimage |
Date: |
Thu, 19 Oct 2006 16:17:50 +0200 (CEST) |
Dear Maintainers,
since several months there has been a bugreport
#352731
in the BTS of Debian, to the effect that
mkbimage of grub 0.95 and 0.97
uses a fixed loop-device /dev/loop1 and could
potentially
be harmful by destrying anything that already involves
this particular device. The elementary solution is to
prepare oneself with "temp=`losetup -f`". This very
same method is implemented in the attached patch.
Please,consider incorporating it. I see only one
minor timing problem with this solution: between
temp_loop=$(losetup -f)
and
losetup $lo_options $temp_loop $image
there is a minute time window available to steal
the allotted loop-device. The danger of prescribing
/dev/loop1 seems, however, to be more serious.
The Debian maintainers of grub have not mentioned
any reason not to let you people have a first
opportunity to implement a remedy, hence this email.
I would at this time like to point out a true bug:
there is no texinfo on the grub-shell command "dump",
although it is used in some script of the grub-source.
Best regards
Mats Erik Andersson
address@hidden
# dev-loop_indep_mkbimage.diff
#
# The dependency of a loop-device is made dynamic,
# instead of statically using /dev/loop1.
#
# Mats Erik Andersson <address@hidden>
#
diff -Naur grub-0.97.orig/util/mkbimage grub-0.97.patched/util/mkbimage
--- grub-0.97.orig/util/mkbimage 2004-07-24 20:57:31.000000000 +0200
+++ grub-0.97.patched/util/mkbimage 2006-10-06 12:57:21.609356256 +0200
@@ -149,9 +149,10 @@
if [ "$offset" = "0" ] ; then
mkfs.$fs -F $image
elif [ `id -u` = "0" ] ; then
- losetup $lo_options /dev/loop1 $image
- mkfs.$fs /dev/loop1
- losetup -d /dev/loop1
+ temp_loop=$(losetup -f)
+ losetup $lo_options $temp_loop $image
+ mkfs.$fs $temp_loop
+ losetup -d $temp_loop
else
error must_be_root
fi
@@ -185,13 +186,14 @@
$cp ${image}1/$file ${image}:$file
done
elif [ "`id -u`" = "0" ] ; then
- losetup $lo_options /dev/loop1 $image
+ temp_loop=$(losetup -f)
+ losetup $lo_options $temp_loop $image
mkdir ${image}.mnt
- mount -t $fs /dev/loop1 ${image}.mnt
+ mount -t $fs $temp_loop ${image}.mnt
cp -a ${image}1/* ${image}.mnt/ && sync
umount ${image}.mnt
rmdir ${image}.mnt
- losetup -d /dev/loop1
+ losetup -d $temp_loop
else
error must_be_root
fi
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Making loop-device flexible in the script mkbimage,
Mats Erik Andersson <=