Skip to contentSkip to conversation

Enable /dev/mapper/dm-[0-9]-* scanning

PATCH In review Oleg Solovyov 3 participants 8 messages May 10, 2018 – May 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Enable /dev/mapper/dm-[0-9]-* scanning

This code was modified because the original code skips any device with basename starts with /dm-[0-9]/
e.g. if the root device path is //dev/mapper/dm-0-luks/ it won't be detected by grub-probe and "root=" parameter in grub.cfg will be empty and the system will be unbootable unless you manually edit grub.cfg

BUG: https://savannah.gnu.org/bugs/?53697
Quoted 5 lines
grub/grub-core/osdep/unix/getroot.c +0 -0
index 4bf37b0..2964dcd 100644
@@ -433,7 +433,8 @@ grub_find_device (const char *dir, dev_t dev)
Quoted 9 lines

           ent->d_name[1] == 'm' &&
           ent->d_name[2] == '-' &&
           ent->d_name[3] >= '0' &&
-          ent->d_name[3] <= '9')
+          ent->d_name[3] <= '9' &&
+          ent->d_name[4] == '\0')
         continue;
 #endif

PS
I don't know what to do in case of //dev/dm-[0-9]+$/ yet

#1 lore raw
Quoted 17 lines · Oleg Solovyov

This code was modified because the original code skips any device with basename starts with /dm-[0-9]/
e.g. if the root device path is //dev/mapper/dm-0-luks/ it won't be detected by grub-probe and "root=" parameter in grub.cfg will be empty and the system will be unbootable unless you manually edit grub.cfg

BUG: https://savannah.gnu.org/bugs/?53697
Quoted 9 lines
grub/grub-core/osdep/unix/getroot.c +0 -0
index 4bf37b0..2964dcd 100644
@@ -433,7 +433,8 @@ grub_find_device (const char *dir, dev_t dev)

???????? ?????????? ent->d_name[1] == 'm' &&
???????? ?????????? ent->d_name[2] == '-' &&
???????? ?????????? ent->d_name[3] >= '0' &&

Quoted 8 lines
Quoted 6 lines

-?????? ?????????? ent->d_name[3] <= '9')
+?????? ?????????? ent->d_name[3] <= '9' &&
+?????? ?????????? ent->d_name[4] == '\0')
???????? ?????? continue;
??#endif

PS
I don't know what to do in case of //dev/dm-[0-9]+$/ yet

Your solution is not reliable. What about /dev/dm-10? I think that you should add check for /dev directory. This should work much better.

Additionally, please use git format-patch/send-email to create and send patches. And do not forget about SOB (Signed-off-by).

Good example is here: http://lists.gnu.org/archive/html/grub-devel/2018-04/msg00055.html

Daniel

#2 lore raw

PATCH 1/1 Enable /dev/mapper/dm-[0-9]-* scanning

Thanks for review
New version is attached

From 19e3f13632a20a0b1be12b6d6ff4c52ba4f3b4d6 Mon Sep 17 00:00:00 2001
From: Oleg Solovyov <[email protected]>
Date: Fri, 11 May 2018 13:55:46 +0300
Subject: [PATCH] Don't skip /dev/mapper/dm-* devices

This patch ensures that grub-probe will find the root device placed in /dev/mapper/dm-[0-9]+-.*
e.g. device named /dev/mapper/dm-0-luks will be found and grub.cfg will be updated properly, enabling the system to boot.

---
 grub/grub-core/osdep/unix/getroot.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
grub/grub-core/osdep/unix/getroot.c +4 -2
index 4bf37b0..41d6574 100644
@@ -428,8 +428,10 @@ grub_find_device (const char *dir, dev_t dev)
 	{
 #ifdef __linux__
 	  /* Skip device names like /dev/dm-0, which are short-hand aliases
-	     to more descriptive device names, e.g. those under /dev/mapper */
-	  if (ent->d_name[0] == 'd' &&
+	     to more descriptive device names, e.g. those under /dev/mapper
+	     Also, don't skip devices under /dev/mapper */
+	  if (strcmp (dir, "/dev") == 0 &&
+	      ent->d_name[0] == 'd' &&
 	      ent->d_name[1] == 'm' &&
 	      ent->d_name[2] == '-' &&
 	      ent->d_name[3] >= '0' &&
Signature · 1 line
2.10.2
Reviewed-by on v1 1/1
#3 lore raw
Quoted 8 lines · Oleg Solovyov

Thanks for review
New version is attached

From 19e3f13632a20a0b1be12b6d6ff4c52ba4f3b4d6 Mon Sep 17 00:00:00 2001
From: Oleg Solovyov <[email protected]>
Date: Fri, 11 May 2018 13:55:46 +0300
Subject: [PATCH] Don't skip /dev/mapper/dm-* devices

Quoted 6 lines

This patch ensures that grub-probe will find the root device placed in /dev/mapper/dm-[0-9]+-.*
e.g. device named /dev/mapper/dm-0-luks will be found and grub.cfg will be updated properly, enabling the system to boot.

If there are no objections I will apply this patch in a week or so.

Next time please use "git send-email" to send the patches.

Daniel

#4 lore raw

Anybody?

14.05.2018 20:13, Daniel Kiper пишет:

Quoted 27 lines · Oleg Solovyov
Quoted 8 lines

Thanks for review
New version is attached

From 19e3f13632a20a0b1be12b6d6ff4c52ba4f3b4d6 Mon Sep 17 00:00:00 2001
From: Oleg Solovyov <[email protected]>
Date: Fri, 11 May 2018 13:55:46 +0300
Subject: [PATCH] Don't skip /dev/mapper/dm-* devices

Quoted 6 lines

This patch ensures that grub-probe will find the root device placed in /dev/mapper/dm-[0-9]+-.*
e.g. device named /dev/mapper/dm-0-luks will be found and grub.cfg will be updated properly, enabling the system to boot.

If there are no objections I will apply this patch in a week or so.

Next time please use "git send-email" to send the patches.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
Quoted 2 lines · On Tue, 29 May 2018, 13:58 Oleg Solovyov, <[email protected]> wrote:

Anybody?

Why do you need this? Normally the same devices should be under /dev/mapper. Using dm-X will mess up some other code most likely

Quoted 37 lines

14.05.2018 20:13, Daniel Kiper пишет:

Quoted 19 lines · Oleg Solovyov
Quoted 8 lines

Thanks for review
New version is attached

From 19e3f13632a20a0b1be12b6d6ff4c52ba4f3b4d6 Mon Sep 17 00:00:00 2001
From: Oleg Solovyov <[email protected]>
Date: Fri, 11 May 2018 13:55:46 +0300
Subject: [PATCH] Don't skip /dev/mapper/dm-* devices

Quoted 6 lines

This patch ensures that grub-probe will find the root device placed in /dev/mapper/dm-[0-9]+-.*
e.g. device named /dev/mapper/dm-0-luks will be found and grub.cfg will be updated properly, enabling the system to boot.

If there are no objections I will apply this patch in a week or so.

Quoted 8 lines

Next time please use "git send-email" to send the patches.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw

29.05.2018 16:50, Vladimir 'phcoder' Serbinenko пишет:

Quoted 9 lines

On Tue, 29 May 2018, 13:58 Oleg Solovyov, <[email protected] <mailto:[email protected]>> wrote:

Anybody?

Why do you need this? Normally the same devices should be under /dev/mapper. Using dm-X will mess up some other code most likely

What happens if you have /dev/mapper/dm-0-luks symlinked to /dev/dm-0? This device will be skipped because basename starts with dm-0 There's no checking whether device is under /dev/mapper or not yet.

Quoted 50 lines


    14.05.2018 20:13, Daniel Kiper пишет:
    > On Fri, May 11, 2018 at 02:32:48PM +0300, Oleg Solovyov wrote:
    >> Thanks for review
    >> New version is attached
    >>
    >> From 19e3f13632a20a0b1be12b6d6ff4c52ba4f3b4d6 Mon Sep 17
    00:00:00 2001
    >> From: Oleg Solovyov <[email protected]
    <mailto:[email protected]>>
    >> Date: Fri, 11 May 2018 13:55:46 +0300
    >> Subject: [PATCH] Don't skip /dev/mapper/dm-* devices
    >>
    >> This patch ensures that grub-probe will find the root device
    placed in
    >> /dev/mapper/dm-[0-9]+-.*
    >> e.g. device named /dev/mapper/dm-0-luks will be found and
    grub.cfg will
    >> be updated properly, enabling the system to boot.
    >>
    >> Signed-off-by: Oleg Solovyov <[email protected]
    <mailto:[email protected]>>
    > Reviewed-by: Daniel Kiper <[email protected]
    <mailto:[email protected]>>
    >
    > If there are no objections I will apply this patch in a week or so.
    >
    > Next time please use "git send-email" to send the patches.
    >
    > Daniel
    >
    > _______________________________________________
    > Grub-devel mailing list
    > [email protected] <mailto:[email protected]>
    > https://lists.gnu.org/mailman/listinfo/grub-devel


    _______________________________________________
    Grub-devel mailing list
    [email protected] <mailto:[email protected]>
    https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
Quoted 6 lines · Oleg Solovyov

29.05.2018 16:50, Vladimir 'phcoder' Serbinenko ??????????:

Quoted 5 lines

On Tue, 29 May 2018, 13:58 Oleg Solovyov, <[email protected] <mailto:[email protected]>> wrote:

Quoted 7 lines
Quoted 4 lines

Anybody?

Why do you need this? Normally the same devices should be under /dev/mapper. Using dm-X will mess up some other code most likely

What happens if you have /dev/mapper/dm-0-luks symlinked to /dev/dm-0? This device will be skipped because basename starts with dm-0 There's no checking whether device is under /dev/mapper or not yet.

I have just pushed the patch. Sorry for delay but I was traveling recently.

Daniel