|
|
f96e0b |
From ac3bee8949b5edab8797d75c5e1b3f176c904a4a Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Thu, 11 Apr 2013 00:08:27 +0200
|
|
|
f96e0b |
Subject: [PATCH 277/482] Fix missing PVs if they don't contain
|
|
|
f96e0b |
"interesting" LV. Closes #38677. Fix few warining messages and leaks
|
|
|
f96e0b |
while on it.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 5 +++
|
|
|
f96e0b |
grub-core/disk/diskfilter.c | 12 ++-----
|
|
|
f96e0b |
grub-core/kern/emu/hostdisk.c | 4 ++-
|
|
|
f96e0b |
util/getroot.c | 79 +++++++++++++++++++++++++++++++++++++++++++
|
|
|
f96e0b |
4 files changed, 89 insertions(+), 11 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index fd9c082..602fc9b 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,3 +1,8 @@
|
|
|
f96e0b |
+2013-04-11 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ Fix missing PVs if they don't contain "interesting" LV. Closes #38677.
|
|
|
f96e0b |
+ Fix few warining messages and leaks while on it.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
2013-04-09 Andrey Borzenkov <arvidjaar@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
* autogen.sh: Use "-h", not "-f", to test for existence of symbolic
|
|
|
f96e0b |
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
|
|
|
f96e0b |
index 2ff47e9..c4eb97e 100644
|
|
|
f96e0b |
--- a/grub-core/disk/diskfilter.c
|
|
|
f96e0b |
+++ b/grub-core/disk/diskfilter.c
|
|
|
f96e0b |
@@ -199,16 +199,8 @@ scan_disk (const char *name, int accept_diskfilter)
|
|
|
f96e0b |
scan_depth--;
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- if (scan_disk_partition_iter (disk, 0, (void *) name))
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- scan_depth--;
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- if (grub_partition_iterate (disk, scan_disk_partition_iter, (void *) name))
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- scan_depth--;
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ scan_disk_partition_iter (disk, 0, (void *) name);
|
|
|
f96e0b |
+ grub_partition_iterate (disk, scan_disk_partition_iter, (void *) name);
|
|
|
f96e0b |
grub_disk_close (disk);
|
|
|
f96e0b |
scan_depth--;
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c
|
|
|
f96e0b |
index 62a579b..4a5eee0 100644
|
|
|
f96e0b |
--- a/grub-core/kern/emu/hostdisk.c
|
|
|
f96e0b |
+++ b/grub-core/kern/emu/hostdisk.c
|
|
|
f96e0b |
@@ -431,7 +431,7 @@ grub_util_get_dm_node_linear_info (const char *dev,
|
|
|
f96e0b |
uint64_t length, start;
|
|
|
f96e0b |
char *target, *params;
|
|
|
f96e0b |
char *ptr;
|
|
|
f96e0b |
- int major, minor;
|
|
|
f96e0b |
+ int major = 0, minor = 0;
|
|
|
f96e0b |
int first = 1;
|
|
|
f96e0b |
grub_disk_addr_t partstart = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -497,6 +497,8 @@ grub_util_get_dm_node_linear_info (const char *dev,
|
|
|
f96e0b |
|
|
|
f96e0b |
dm_task_destroy (dmt);
|
|
|
f96e0b |
first = 0;
|
|
|
f96e0b |
+ if (!dm_is_dm_major (major))
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
if (first)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
diff --git a/util/getroot.c b/util/getroot.c
|
|
|
f96e0b |
index 654d1e1..f65fd1e 100644
|
|
|
f96e0b |
--- a/util/getroot.c
|
|
|
f96e0b |
+++ b/util/getroot.c
|
|
|
f96e0b |
@@ -243,6 +243,13 @@ exec_pipe (char **argv, int *fd)
|
|
|
f96e0b |
else if (mdadm_pid == 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
/* Child. */
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* Close fd's. */
|
|
|
f96e0b |
+#ifdef HAVE_DEVICE_MAPPER
|
|
|
f96e0b |
+ dm_lib_release ();
|
|
|
f96e0b |
+#endif
|
|
|
f96e0b |
+ grub_diskfilter_fini ();
|
|
|
f96e0b |
+
|
|
|
f96e0b |
/* Ensure child is not localised. */
|
|
|
f96e0b |
setenv ("LC_ALL", "C", 1);
|
|
|
f96e0b |
|
|
|
f96e0b |
@@ -1315,6 +1322,76 @@ grub_util_get_dev_abstraction (const char *os_dev)
|
|
|
f96e0b |
return GRUB_DEV_ABSTRACTION_NONE;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+pull_lvm_by_command (const char *os_dev)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ char *argv[6];
|
|
|
f96e0b |
+ int fd;
|
|
|
f96e0b |
+ pid_t pid;
|
|
|
f96e0b |
+ FILE *mdadm;
|
|
|
f96e0b |
+ char *buf = NULL;
|
|
|
f96e0b |
+ size_t len = 0;
|
|
|
f96e0b |
+ char *vgname;
|
|
|
f96e0b |
+ const char *iptr;
|
|
|
f96e0b |
+ char *optr;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (strncmp (os_dev, "/dev/mapper/", sizeof ("/dev/mapper/") - 1)
|
|
|
f96e0b |
+ != 0)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ vgname = xmalloc (strlen (os_dev + sizeof ("/dev/mapper/") - 1) + 1);
|
|
|
f96e0b |
+ for (iptr = os_dev + sizeof ("/dev/mapper/") - 1, optr = vgname; *iptr; )
|
|
|
f96e0b |
+ if (*iptr != '-')
|
|
|
f96e0b |
+ *optr++ = *iptr++;
|
|
|
f96e0b |
+ else if (iptr[0] == '-' && iptr[1] == '-')
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ iptr += 2;
|
|
|
f96e0b |
+ *optr++ = '-';
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ else
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ *optr = '\0';
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* execvp has inconvenient types, hence the casts. None of these
|
|
|
f96e0b |
+ strings will actually be modified. */
|
|
|
f96e0b |
+ argv[0] = (char *) "vgs";
|
|
|
f96e0b |
+ argv[1] = (char *) "--options";
|
|
|
f96e0b |
+ argv[2] = (char *) "pv_name";
|
|
|
f96e0b |
+ argv[3] = (char *) "--noheadings";
|
|
|
f96e0b |
+ argv[4] = vgname;
|
|
|
f96e0b |
+ argv[5] = NULL;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ pid = exec_pipe (argv, &fd;;
|
|
|
f96e0b |
+ free (vgname);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (!pid)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* Parent. Read mdadm's output. */
|
|
|
f96e0b |
+ mdadm = fdopen (fd, "r");
|
|
|
f96e0b |
+ if (! mdadm)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_util_warn (_("Unable to open stream from %s: %s"),
|
|
|
f96e0b |
+ "vgs", strerror (errno));
|
|
|
f96e0b |
+ goto out;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ while (getline (&buf, &len, mdadm) > 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ char *ptr;
|
|
|
f96e0b |
+ for (ptr = buf; ptr < buf + 2 && *ptr == ' '; ptr++);
|
|
|
f96e0b |
+ if (*ptr == '\0')
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+ *(ptr + strlen (ptr) - 1) = '\0';
|
|
|
f96e0b |
+ grub_util_pull_device (ptr);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+out:
|
|
|
f96e0b |
+ close (fd);
|
|
|
f96e0b |
+ waitpid (pid, NULL, 0);
|
|
|
f96e0b |
+ free (buf);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
#ifdef __linux__
|
|
|
f96e0b |
static char *
|
|
|
f96e0b |
get_mdadm_uuid (const char *os_dev)
|
|
|
f96e0b |
@@ -1538,6 +1615,8 @@ grub_util_pull_device (const char *os_dev)
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
|
|
|
f96e0b |
case GRUB_DEV_ABSTRACTION_LVM:
|
|
|
f96e0b |
+ pull_lvm_by_command (os_dev);
|
|
|
f96e0b |
+ /* Fallthrough in case that lvm-tools are unavailable. */
|
|
|
f96e0b |
case GRUB_DEV_ABSTRACTION_LUKS:
|
|
|
f96e0b |
#ifdef HAVE_DEVICE_MAPPER
|
|
|
f96e0b |
{
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|