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

Bug#697017: [PATCH initramfs-tools 2/3] parse_numeric: Add support for 20-bit minor numbers in 'root' parameter



Linux supports 32-bit device numbers in the format 0xmmmMMMmm, where
each m is a hex digit of the minor number and each M is a hex digit of
the major number.

Currently parse_lilo only works if the top 3 digits are 0 (or absent).
Shift and mask the upper bits correctly.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 scripts/functions | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/functions b/scripts/functions
index 2da6173..adcfefa 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -121,8 +121,8 @@ parse_numeric() {
 	*)
 		# [A-Fa-f0-9]*
 		value=$(( 0x${1} ))
-		minor=$(( ${value} % 256 ))
-		major=$(( ${value} / 256 ))
+		minor=$(( (${value} & 0xff) | (${value} >> 12) & 0xfff00 ))
+		major=$(( (${value} >> 8) & 0xfff ))
 		;;
 	esac
 

-- 
Ben Hutchings
Life would be so much easier if we could look at the source code.

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


Reply to: