]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Abstract out vol_id vs. blkid usage
authorVictor Lowther <victor.lowther@gmail.com>
Wed, 19 Aug 2009 20:51:54 +0000 (15:51 -0500)
committerVictor Lowther <victor.lowther@gmail.com>
Thu, 20 Aug 2009 03:21:07 +0000 (22:21 -0500)
Since different distros may or may not use vol_id in udev, and blkid
is generally replacing vol_id, abstract them out into a function which
tries to use vol_id first and blkid second, on the assumption that
blkid can take over for vol_id if vol_id is no longer there.

dracut-functions
modules.d/90crypt/check
modules.d/90dmraid/check
modules.d/90lvm/check
modules.d/90mdraid/check

index 1df20456c3f168b7f0fa1f504408fb29b0d2c417..655d311f60360c8bf9ee6d1e4c1381e82b626e00 100755 (executable)
@@ -48,6 +48,17 @@ derror() {
     [[ -w $dracutlogfile ]] && echo "E: $@" >>"$dracutlogfile"
 }
 
+get_fs_type() (
+    if [[ -x /lib/udev/vol_id ]]; then
+       eval /usr/udev/vol_id --export $1
+       echo $ID_FS_TYPE
+    elif find_binary >/dev/null; then
+       blkid -o value -s TYPE $1
+    else
+       return 1
+    fi
+)
+
 # finds the major:minor of the block device backing the root filesystem.
 find_root_block_device() {
     local rootdev blkdev fs type opts misc
index edd450d99568cf0fc0eb3a7844dcecef65c86850..07c53f9f704268f0dcae658dc534d175fb822c20 100755 (executable)
@@ -9,7 +9,7 @@ which cryptsetup >/dev/null 2>&1 || exit 1
 
 . $dracutfunctions
 
-is_crypt() { /lib/udev/vol_id /dev/block/$1 |grep -q crypto_LUKS; }
+is_crypt() { [[ $(get_fs_type /dev/block/$1) = crypto_LUKS ]]; }
 
 [[ $1 = '-h' ]] && {
     rootdev=$(find_root_block_device)
index 7008f811dac0895340ae8d8465c90d5b317afc6d..4dd9d7a3ad8c5073341c64b51ec5ccad7f907bb0 100755 (executable)
@@ -6,7 +6,7 @@ which dmraid >/dev/null 2>&1 || exit 1
 
 . $dracutfunctions
 
-is_dmraid() { /lib/udev/vol_id /dev/block/$1 |grep -v linux_raid_member | \
+is_dmraid() { get_fs_type /dev/block/$1 |grep -v linux_raid_member | \
     grep -q _raid_member; }
 
 [[ $1 = '-h' ]] && {
index 3e6a990755abb74dd623335e23842235e02bad60..e57d60f04cf2d13c5dfff1ce37682035346ad314 100755 (executable)
@@ -5,7 +5,7 @@ which lvm >/dev/null 2>&1 || exit 1
 
 . $dracutfunctions
 
-is_lvm() { /lib/udev/vol_id /dev/block/$1 |grep -q LVM2_member; }
+is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; }
 
 [[ $1 = '-h' ]] && {
     rootdev=$(find_root_block_device)
@@ -15,7 +15,7 @@ is_lvm() { /lib/udev/vol_id /dev/block/$1 |grep -q LVM2_member; }
        check_block_and_slaves is_lvm "$rootdev" || exit 1
     else
        # root is not on a block device, use the shotgun approach
-       blkid | grep -q lvm2pv || exit 1
+       blkid | grep -q LVM2_member || exit 1
     fi
 }
 
index d002bdc333bbb6639cb944bb1d8caaad136c52bf..5bffd36a1fb81e612f23c28aec22a5f3df3b0453 100755 (executable)
@@ -5,7 +5,7 @@ which mdadm >/dev/null 2>&1 || exit 1
 
 . $dracutfunctions
 
-is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
+is_mdraid() { get_fs_type /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
 
 [[ $1 = '-h' ]] && {
     rootdev=$(find_root_block_device)