From 650c05fd5496661231cda1435598f8c2364e08f3 Mon Sep 17 00:00:00 2001 From: madduck Date: Sat, 16 Sep 2006 11:02:22 +0000 Subject: rewrote Sesse's patch and added debug output for now --- debian/changelog | 11 +++ .../patches/50-superblock-partition-limit.dpatch | 89 +++++++++++++++------- 2 files changed, 72 insertions(+), 28 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 0a59ae24..675a5114 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +mdadm (2.5.3.git200608202239-5~unreleased.2) UNRELEASED; urgency=medium + + * Modified the patch responsible for pruning parent devices so that + superblocks at the end of a disk do not get interpreted twice. It now + makes less assumptions about the exact output of /proc/partitions and + should thus be more robust (now closes: #385951). + * Added debugging output. + * Keeping medium urgency. + + -- martin f. krafft Thu, 14 Sep 2006 11:16:39 +0200 + mdadm (2.5.3.git200608202239-4) unstable; urgency=medium * Correct error related to an unbound variable in postinst. diff --git a/debian/patches/50-superblock-partition-limit.dpatch b/debian/patches/50-superblock-partition-limit.dpatch index 299c5d87..9259240a 100755 --- a/debian/patches/50-superblock-partition-limit.dpatch +++ b/debian/patches/50-superblock-partition-limit.dpatch @@ -6,9 +6,9 @@ @DPATCH@ diff -urNad mdadm.git~/config.c mdadm.git/config.c ---- mdadm.git~/config.c 2006-08-11 10:53:20.000000000 +0200 -+++ mdadm.git/config.c 2006-09-13 10:38:55.000000000 +0200 -@@ -222,7 +222,8 @@ +--- mdadm.git~/config.c 2006-09-14 20:10:13.000000000 +0200 ++++ mdadm.git/config.c 2006-09-14 20:10:24.000000000 +0200 +@@ -222,28 +222,87 @@ mddev_dev_t load_partitions(void) { FILE *f = fopen("/proc/partitions", "r"); @@ -18,34 +18,67 @@ diff -urNad mdadm.git~/config.c mdadm.git/config.c mddev_dev_t rv = NULL; if (f == NULL) { fprintf(stderr, Name ": cannot open /proc/partitions\n"); -@@ -230,7 +231,7 @@ + return NULL; } - while (fgets(buf, 1024, f)) { - int major, minor; +- while (fgets(buf, 1024, f)) { +- int major, minor; - char *name, *mp; ++ while (!feof(f) && fgets(buf, 1024, f)) { ++ unsigned long major, minor, iter; + char *name, *kernel_name, *mp, *ptr; mddev_dev_t d; - buf[1023] = '\0'; -@@ -244,6 +245,46 @@ +- buf[1023] = '\0'; +- if (buf[0] != ' ') +- continue; ++ /* ++ * All partition lines start with a space. ++ */ ++ if (buf[0] != ' ') continue; ++ ++ /* ++ * Chop at the end of each line. ++ */ ++ ptr = strchr(buf, '\n'); ++ if (ptr) *ptr = '\0'; ++ ++ fprintf(stderr, "Read line: %s\n", buf); ++ ++ /* ++ * Extract the major and minor numbers and obtain the device node name. ++ * 10 is the max number of digits expected in a major/minor number ++ * (32bit). ++ */ + major = strtoul(buf, &mp, 10); +- if (mp == buf || *mp != ' ') +- continue; ++ if (mp == buf || *mp != ' ') continue; + minor = strtoul(mp, NULL, 10); + name = map_dev(major, minor, 1); - if (!name) - continue; +- if (!name) +- continue; ++ if (!name) continue; + -+ /* -+ * We want the name exactly as it comes from -+ * /proc/partitions; this makes sure we do not get -+ * confused by weird LVM names and the like. -+ */ -+ kernel_name = buf + 22; /* will be safe until we reach 10TB */ -+ while (isdigit(*kernel_name) || isspace(*kernel_name)) { /* just to be sure */ -+ ++kernel_name; -+ } ++ /* ++ * Get the kernel name, which is the forth of the space-separated fields. ++ */ ++ mp = buf; ++ while (isspace(*(++mp))); ++ for (iter = 0; iter < 3; ++iter) { ++ while (!isspace(*(++mp))); ++ while (isspace(*(++mp))); ++ } ++ ++ /* ++ * Now the cursor is at the beginning to the kernel name, so we point ++ * there and terminate the string on the first space character. ++ */ ++ kernel_name = mp; ++ while (!isspace(*(++mp))); ++ *mp = '\0'; + -+ /* Chop the trailing newline. */ -+ ptr = strchr(kernel_name, '\n'); -+ if (ptr) -+ *ptr = '\0'; ++ fprintf(stderr, "Parsed: mj=%lu, mn=%lu, n=%s, k=%s\n", major, minor, name, kernel_name); + + /* + * Check if this could be a partition of the previous device @@ -56,12 +89,12 @@ diff -urNad mdadm.git~/config.c mdadm.git/config.c + strncmp(kernel_name, last_device_name, strlen(last_device_name)) == 0 && + isdigit(kernel_name[strlen(kernel_name) - 1])) { + /* -+ * The previous device has a partition table, so delete -+ * it so it isn't scanned for a superblock. This makes -+ * sure we don't get confused when a partition with an -+ * md superblock lives very close to the end of a -+ * disk. ++ * The previous device appears to have a partition table, so delete it ++ * so it isn't scanned for a superblock. This makes sure we don't get ++ * confused when a partition with an md superblock lives very close to ++ * the end of a disk. + */ ++ fprintf(stderr, "Pruning: %s\n", last_device_name); + d = rv->next; + free(rv->devname); + free(rv); -- cgit v1.2.3