dm-verity: fix exceptional cases of creating dm-verity metadata 23/259223/5 accepted/tizen/unified/20210604.120735 submit/tizen/20210603.041836
authorINSUN PYO <insun.pyo@samsung.com>
Wed, 2 Jun 2021 11:50:06 +0000 (20:50 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Thu, 3 Jun 2021 02:14:24 +0000 (11:14 +0900)
Iot-headless uses btrfs filesystem for root partition.
tune2fs does not work with btrfs filesystem.

Change-Id: I43080e3b960e199c95fde2b3cbb7d175d28c1c9d

scripts/verityctl

index 0b3cb73f25179ad3611099dd56ebf17fe81ca944..cf7015ed5698d3213da28f91054acd0b3318ebeb 100755 (executable)
@@ -30,11 +30,19 @@ format()
        then
                IMG_PATH=/tmp
 
+               # Only support ext4 filesystem
+               FS_TYPE=`/bin/lsblk -n -o FSTYPE $IMG_FILE`
+               if [ x"$FS_TYPE" != x"ext4" ]
+               then
+                       echo "$IMG_FILE is not ext4 filesystem"
+                       exit 0
+               fi
+
                block_count=`/sbin/tune2fs -l $IMG_FILE | grep "Block count" | gawk '{print $3}'`
                block_size=`/sbin/tune2fs -l $IMG_FILE | grep "Block size" | gawk '{print $3}'`
 
                ((meta_offset=$block_count * $block_size))
-               part_block_size=`lsblk -rbno SIZE $IMG_FILE`
+               part_block_size=`/bin/lsblk -rbno SIZE $IMG_FILE`
 
                echo "partition size: $part_block_size"
                echo "meta data offset: $meta_offset"
@@ -126,7 +134,7 @@ create()
        ((meta_sign_offset=$meta_offset + 256))
 
        # The meta location is after the partition size. (After resizefs)
-       part_block_size=`lsblk -rbno SIZE $ROOTFS`
+       part_block_size=`/bin/lsblk -rbno SIZE $ROOTFS`
        if [ $part_block_size -lt $hash_offset ]
        then
                echo "$ROOTFS does not have dm-verity meta data"