Browse Source

dmsquash-live-root: determine img type by contents, not name

Currently dmsquash-live-root requires that squashfs images be named
"squashfs.img" and all others be "ext3fs.img" or "rootfs.img".

If we've got a live image in initramfs, this patch will make dracut use
losetup and det_fs to determine the actual filesystem type of the image.

Signed-off-by: Will Woods <wwoods@redhat.com>
master
Will Woods 14 years ago committed by Harald Hoyer
parent
commit
a12db35efa
  1. 15
      modules.d/90dmsquash-live/dmsquash-live-root

15
modules.d/90dmsquash-live/dmsquash-live-root

@ -41,14 +41,23 @@ if [ -n "$check" ]; then
[ -x /bin/plymouth ] && /bin/plymouth --show-splash [ -x /bin/plymouth ] && /bin/plymouth --show-splash
fi fi


# determine filesystem type for a filesystem image
det_img_fs() {
local _img="$1" _loop=$(losetup -f) _fs
losetup $_loop $_img; _fs=$(det_fs $_loop); losetup -d $_loop
echo $_fs
}

for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done
# mount the backing of the live image first # mount the backing of the live image first
mkdir -m 0755 -p /run/initramfs/live mkdir -m 0755 -p /run/initramfs/live
if [ -f $livedev ]; then if [ -f $livedev ]; then
# no mount needed - we've already got the LiveOS image in initramfs # no mount needed - we've already got the LiveOS image in initramfs
case $livedev in # check filesystem type and handle accordingly
*squashfs.img) SQUASHED=$livedev ;; case `det_img_fs $livedev` in
*ext3fs.img|*rootfs.img) FSIMG=$livedev ;; squashfs) SQUASHED=$livedev ;;
auto) die "cannot mount live image (unknown filesystem type)" ;;
*) FSIMG=$livedev ;;
esac esac
else else
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live

Loading…
Cancel
Save