From a19cf6e2dba54a16a7e436a031b20cf97df5bc30 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 17 Nov 2011 16:03:24 -0500 Subject: [PATCH] build_image: handle diff mount output Newer versions of util-linux's mount utility will not show: /dev/loop0 on /some/path type ext3 (mount,opts) Instead, it finds out the file backing /dev/loop0 and outputs: /some/file on /some/path type ext3 (mount,opts) This breaks the make_image_bootable helper that attempts to look up the loop device that mount_gpt_image.sh happened to pick. Let's scuttle the idea of parsing `mount` and move directly to what the kernel has to say via /proc/mounts. Hopefully the ABI there should be quite a bit more stable. BUG=None TEST=build_image works with mount from util-linux-2.16 TEST=build_image (before change) fails with mount from util-linux-2.19 TEST=build_image works with mount from util-linux-2.19 Change-Id: I66908800e82ff2e106face9d57773721e400dc2a Reviewed-on: https://gerrit.chromium.org/gerrit/11869 Commit-Ready: Mike Frysinger Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- bin/cros_make_image_bootable | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/cros_make_image_bootable b/bin/cros_make_image_bootable index 476021b58d..3e5f1213f6 100755 --- a/bin/cros_make_image_bootable +++ b/bin/cros_make_image_bootable @@ -175,8 +175,10 @@ make_image_bootable() { # The rootfs should never be mounted rw again after this point without # re-calling make_image_bootable. sudo mount -o remount,ro "${FLAGS_rootfs_mountpoint}" - root_dev=$(mount | grep -- "on ${FLAGS_rootfs_mountpoint} type" | - cut -f1 -d' ' | tail -1) + # Newer `mount` will decode the filename backing the loop device, + # so we need to dig deeper and find the answer ourselves. + root_dev=$(awk -v mnt="${FLAGS_rootfs_mountpoint}" \ + '$2 == mnt { print $1 }' /proc/mounts) # Make the filesystem un-mountable as read-write. # mount_gpt_image.sh will undo this as needed.