From d1718e7d2bedd4089cadfb66c288e14c43ffa1c5 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 22 Jun 2012 22:11:23 +0200 Subject: [PATCH] * util/getroot.c (grub_find_root_devices_from_mountinfo): Handle btrfs subvolumes. --- ChangeLog | 5 +++++ util/getroot.c | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c12da1a0c..e2d5e0f0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-06-22 Vladimir Serbinenko + + * util/getroot.c (grub_find_root_devices_from_mountinfo): Handle btrfs + subvolumes. + 2012-06-22 Vladimir Serbinenko Implement flow control for http. diff --git a/util/getroot.c b/util/getroot.c index cbcd3aa5f..e103fb6c1 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -651,7 +651,21 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) { ret = grub_find_root_devices_from_btrfs (dir); if (relroot) - *relroot = strdup (entries[i].enc_root); + { + char *ptr; + *relroot = xmalloc (strlen (entries[i].enc_root) + + 2 + strlen (dir)); + ptr = stpcpy (*relroot, entries[i].enc_root); + if (strlen (dir) > strlen (entries[i].enc_path)) + { + while (ptr > *relroot && *(ptr - 1) == '/') + ptr--; + if (dir[strlen (entries[i].enc_path)] != '/') + *ptr++ = '/'; + ptr = stpcpy (ptr, dir + strlen (entries[i].enc_path)); + } + *ptr = 0; + } } if (!ret) {