[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#766920: [PATCH initramfs-tools] hook-functions: Always use /proc/mounts, avoiding mangling of /dev/root



Control: tag -1 patch

I've reproduced the issue and tested that this fixes it.

Ben.
---
lilo may pass the kernel parameter root=XXXX, specifiying a block
device by number in hex.  In this case a block device node is created
with that number at /dev/root.  However, the mount command translates
this back to the block device number.  Avoid this misfeature by always
reading /proc/mounts.

Closes: #766920
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 hook-functions | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/hook-functions b/hook-functions
index 3095290..428a2bb 100644
--- a/hook-functions
+++ b/hook-functions
@@ -277,18 +277,10 @@ dep_add_modules_mount()
 	fi
 
 	# find out block device + fstype
-	eval "$( mount | while read -r dev foo mp foo fs opts rest ; do \
+	eval "$(while read dev mp fs opts rest ; do \
 		[ "$mp" = "$dir" ] && [ "$fs" != "rootfs" ] \
-		&& printf "dev_node='%s'\nFSTYPE='%s'" "$dev" "$fs" \
-		&& break; done)"
-
-	# On failure fallback to /proc/mounts if readable
-	if [ -z "$dev_node" ] && [ -r /proc/mounts ]; then
-		eval "$(while read dev mp fs opts rest ; do \
-			[ "$mp" = "$dir" ] && [ "$fs" != "rootfs" ] \
-			&& printf "dev_node=$dev\nFSTYPE=$fs"\
-			&& break; done < /proc/mounts)"
-	fi
+		&& printf "dev_node=$dev\nFSTYPE=$fs"\
+		&& break; done < /proc/mounts)"
 
 	# Only the root mountpoint has to exist; do nothing if any other
 	# directory is not a mountpoint.
-- 
Ben Hutchings
Larkinson's Law: All laws are basically false.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: