Skip to contentSkip to conversation

grub-install: Improve support for partitioned loop devices.

PATCH In review Mike Gilbert 2 participants 4 messages Jan 26, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub-install: Improve support for partitioned loop devices.

* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect /dev/loopX as being the parent of /dev/loopXpY.

---
 ChangeLog                       |  5 +++++
 grub-core/osdep/linux/getroot.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)
ChangeLog +5 -0
index c93f11f..d5c5c3c 100644
@@ -1,3 +1,8 @@
+2014-01-26  Mike Gilbert <[email protected]>
+	grub-install: Improve support for partitioned loop devices.
+
+	* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect
+	/dev/loopX as being the parent of /dev/loopXpY.
 
 2014-01-25  Andrey Borzenkov <[email protected]>
 
grub-core/osdep/linux/getroot.c +13 -0
index 772de0a..19581d3 100644
@@ -883,6 +883,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st,
 	  *pp = '\0';
 	  return path;
 	}
+
+      /* If this is a loop device */
+      if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9')
+	{
+	  char *pp = p + 4;
+	  while (*pp >= '0' && *pp <= '9')
+	    pp++;
+	  if (*pp == 'p')
+	    *is_part = 1;
+	  /* /dev/loop[0-9]+p[0-9]* */
+	  *pp = '\0';
+	  return path;
+	}
     }
 
   return path;
Signature · 1 line
1.8.5.3
#1 lore raw

В Sat, 25 Jan 2014 20:41:00 -0500
Mike Gilbert <[email protected]> пишет:

Quoted 2 lines

* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect /dev/loopX as being the parent of /dev/loopXpY.

Those devices are normally device-mapper ones (created by kpartx) and grub already detects parent by following device-mapper tree. What exact problem are you trying to solve?

Quoted 42 lines
---
 ChangeLog                       |  5 +++++
 grub-core/osdep/linux/getroot.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)
ChangeLog +5 -0
index c93f11f..d5c5c3c 100644
@@ -1,3 +1,8 @@
+2014-01-26  Mike Gilbert <[email protected]>
+	grub-install: Improve support for partitioned loop devices.
+
+	* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect
+	/dev/loopX as being the parent of /dev/loopXpY.
 
 2014-01-25  Andrey Borzenkov <[email protected]>
 
grub-core/osdep/linux/getroot.c +13 -0
index 772de0a..19581d3 100644
@@ -883,6 +883,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st,
 	  *pp = '\0';
 	  return path;
 	}
+
+      /* If this is a loop device */
+      if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9')
+	{
+	  char *pp = p + 4;
+	  while (*pp >= '0' && *pp <= '9')
+	    pp++;
+	  if (*pp == 'p')
+	    *is_part = 1;
+	  /* /dev/loop[0-9]+p[0-9]* */
+	  *pp = '\0';
+	  return path;
+	}
     }
 
   return path;
#2 lore raw
Quoted 9 lines · Andrey Borzenkov

В Sat, 25 Jan 2014 20:41:00 -0500
Mike Gilbert <[email protected]> пишет:

Quoted 2 lines

* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect /dev/loopX as being the parent of /dev/loopXpY.

Those devices are normally device-mapper ones (created by kpartx) and grub already detects parent by following device-mapper tree. What exact problem are you trying to solve?

The kernel supports partitioned loop devices without device mapper. These can be set up using losetup -P, or by calling partx from util-linux.

#3 lore raw

В Sun, 26 Jan 2014 01:20:09 -0500
Mike Gilbert <[email protected]> пишет:

Quoted 7 lines · Andrey Borzenkov
Quoted 6 lines

В Sat, 25 Jan 2014 20:41:00 -0500
Mike Gilbert <[email protected]> пишет:

Quoted 2 lines

* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect /dev/loopX as being the parent of /dev/loopXpY.

Quoted 7 lines
Quoted 3 lines

Those devices are normally device-mapper ones (created by kpartx) and grub already detects parent by following device-mapper tree. What exact problem are you trying to solve?

The kernel supports partitioned loop devices without device mapper. These can be set up using losetup -P, or by calling partx from util-linux.

Thank you, was not aware of it.