r161 - in mdadm/trunk/debian: . patches

madduck at users.alioth.debian.org madduck at users.alioth.debian.org
Wed Sep 13 08:39:44 UTC 2006


Author: madduck
Date: 2006-09-13 08:39:44 +0000 (Wed, 13 Sep 2006)
New Revision: 161

Added:
   mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch
Modified:
   mdadm/trunk/debian/changelog
Log:
  * Add patch by Steinar H. Gunderson to ensure mdadm does not interpret
    a superblock as belonging to a device when it's actually part of
    a partition on that device (closes: #385951).


Modified: mdadm/trunk/debian/changelog
===================================================================
--- mdadm/trunk/debian/changelog	2006-09-13 08:36:26 UTC (rev 160)
+++ mdadm/trunk/debian/changelog	2006-09-13 08:39:44 UTC (rev 161)
@@ -1,8 +1,10 @@
 mdadm (2.5.3.git200608202239-3) unstable; urgency=medium
 
-  * Urgency medium because an RC bug is being fixed:
-    Add versioned dependency to debconf. #385994
-    TODO still!
+  * Urgency medium because of RC bugs.
+  * Add versioned dependency to debconf (closes: #385994).
+  * Add patch by Steinar H. Gunderson to ensure mdadm does not interpret
+    a superblock as belonging to a device when it's actually part of
+    a partition on that device (closes: #385951).
   * Do not override the superblock default version in mdadm.conf to prevent
     creation of superblocks that the kernel can't handle (closes: #384614).
   * Added a note to alert people that the warning about arrays not listed in

Added: mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch
===================================================================
--- mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch	                        (rev 0)
+++ mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch	2006-09-13 08:39:44 UTC (rev 161)
@@ -0,0 +1,76 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 50-superblock-partition-limit.dpatch by martin f. krafft <madduck at debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at 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 @@
+ mddev_dev_t load_partitions(void)
+ {
+ 	FILE *f = fopen("/proc/partitions", "r");
+-	char buf[1024];
++	char buf[1024], last_device_name[1024];
++	int last_major = -1;
+ 	mddev_dev_t rv = NULL;
+ 	if (f == NULL) {
+ 		fprintf(stderr, Name ": cannot open /proc/partitions\n");
+@@ -230,7 +231,7 @@
+ 	}
+ 	while (fgets(buf, 1024, f)) {
+ 		int major, minor;
+-		char *name, *mp;
++		char *name, *kernel_name, *mp, *ptr;
+ 		mddev_dev_t d;
+ 
+ 		buf[1023] = '\0';
+@@ -244,6 +245,46 @@
+ 		name = map_dev(major, minor, 1);
+ 		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;
++		}
++
++		/* Chop the trailing newline. */
++		ptr = strchr(kernel_name, '\n');
++		if (ptr)
++			*ptr = '\0';
++
++		/* 
++		 * Check if this could be a partition of the previous device
++		 * (the disk _always_ comes just before the first partition, cf.
++		 * /usr/src/linux/fs/partitions/check.c)
++		 */
++		if (major == last_major && strlen(kernel_name) > strlen(last_device_name) &&
++		    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.
++			 */
++			d = rv->next;
++			free(rv->devname);
++			free(rv);
++			rv = d;
++		}
++
++		last_major = major;
++		strcpy(last_device_name, kernel_name);
++
+ 		d = malloc(sizeof(*d));
+ 		d->devname = strdup(name);
+ 		d->next = rv;


Property changes on: mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch
___________________________________________________________________
Name: svn:executable
   + *




More information about the pkg-mdadm-commits mailing list