[readonly/geninitrd/BUSYBOX: 10/113] - losetup is not needed anymore for ext2 filesystem creation

draenog draenog at pld-linux.org
Sat Nov 2 19:10:52 CET 2013


commit f5d71bb25b15ae50e9d3170d31cf08d6f8096202
Author: Jacek Konieczny <jajcus at pld-linux.org>
Date:   Thu Nov 16 09:15:49 2000 +0000

    - losetup is not needed anymore for ext2 filesystem creation
    
    
    svn-id: @1162

 geninitrd | 36 +++++-------------------------------
 1 file changed, 5 insertions(+), 31 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 8fc11e1..a58caf4 100755
--- a/geninitrd
+++ b/geninitrd
@@ -205,8 +205,8 @@ fi
 
 case "$FS" in
 	ext2)
-		if [ ! -x /sbin/losetup ]; then
-			echo "losetup is missing"
+		if [ ! -x /sbin/mke2fs ]; then
+			echo "mke2fs is missing"
 			exit 1
 		fi
 		;;
@@ -349,37 +349,12 @@ fi
 if [ "$FS" = "ext2" ] ; then
 	dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGESIZE 2> /dev/null
 
-	if [ -e /dev/.devfsd ]; then
-		LOOPDEV=/dev/loop/
-	else
-		LOOPDEV=/dev/loop
-	fi
-
-	for devnum in 0 1 2 3 4 5 6 7 8; do
-	    if losetup ${LOOPDEV}${devnum} $IMAGE 2>/dev/null ; then break; fi
-	done
-
-	if [ "$devnum" = "8" ]; then
-	    rm -rf $MNTPOINT $IMAGE
-	    echo "All of your loopback devices are in use!" >&2
-	    exit 1
-	fi
-
-	LODEV=${LOOPDEV}${devnum}
-
 	# We have to "echo y |" so that it doesn't complain about $IMAGE not
 	# being a block device
-	echo y | mke2fs $LODEV $IMAGESIZE >/dev/null 2>/dev/null
-
-	if [ -n "$verbose" ]; then
-	    echo "Using loopback device $LODEV"
-	fi
+	echo y | mke2fs -F $IMAGE $IMAGESIZE >/dev/null 2>/dev/null
 
 	mkdir -p $MNTPOINT
-	mount -t ext2 $LODEV $MNTPOINT || {
-		echo "Can't get a loopback device"
-		exit 1
-	}
+	mount -o loop -t ext2 $IMAGE $MNTPOINT 
 else
 	mkdir -p $MNTPOINT
 fi
@@ -441,8 +416,7 @@ chmod +x $RCFILE
 
 case "$FS" in
 	ext2)
-		umount $MNTPOINT
-		losetup -d $LODEV
+		umount $IMAGE
 		;;
 	rom)
 		genromfs -f "$IMAGE" -d "$MNTPOINT" -V "PLD initrd for kernel $kernel"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/0999a53e93eedcf489380684b998ce04aaddf11c



More information about the pld-cvs-commit mailing list