summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-10 13:06:03 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-03-10 13:07:24 +0200
commit7df52204369d587df3dc321f12a1a5408afe66bd (patch)
treeadbcb73eef5b68d9c2dce3186eebd2f043c27bad
parentfbd356ce3a284d5445181f70e0f40572c81da66d (diff)
kflash: Use block device LABEL attribute if PARTLABEL isn't available
If the partition table doesn't support labels, use the filesystem label as a fallback. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rwxr-xr-xkflash.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/kflash.sh b/kflash.sh
index dd3a7d9..e5f59ee 100755
--- a/kflash.sh
+++ b/kflash.sh
@@ -193,8 +193,12 @@ probe_device() {
local part_label=${flash_part[1]}
local part_dev=/dev/${partdev}${part_idx}
- local label=$(blkid ${part_dev} -s PARTLABEL | sed 's/.*PARTLABEL="\([^"]*\)"$/\1/')
- if [[ $label != ${part_label} ]] ; then
+ local label=$(blkid ${part_dev} -o value -s PARTLABEL)
+ if [[ -z "$label" ]] ; then
+ label=$(blkid ${part_dev} -o value -s LABEL)
+ fi
+
+ if [[ "$label" != ${part_label} ]] ; then
echo "Partition ${part_dev} has label '$label', expected '${part_label}'" >&2
return
fi