Skip to contentSkip to conversation

BSD partitions

PATCH New [email protected] 1 participant 1 message Jan 11, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 BSD partitions

Since 2.2.0-pre1 we have some broken code in check_and_add_bsd_partition. It was fixed a little in 2.2.2, but it is still broken.
Now that people complained I sent a fixed version to Alan and Marcelo.

However, the actual job of check_and_add_bsd_partition() has nothing to do with BSD or msdos, so I removed the "_bsd" and moved it to check.c, and also changed its function a bit.

Andries

linux/fs/partitions/check.c renamed from linux-2.5.2-pre11/linux/fs/partitions/check.c +25 -0
diff -u --recursive --new-file ../linux-2.5.2-pre11/linux/fs/partitions/check.c ./linux/fs/partitions/check.c
@@ -480,3 +480,28 @@
 
 	return 0;
 }
+
+/*
+ * Make sure that a proposed subpartition is strictly contained inside
+ * the parent partition.  If all is well, call add_gd_partition().
+ */
+int
+check_and_add_subpartition(struct gendisk *hd, int super_minor, int minor,
+			   int sub_start, int sub_size)
+{
+	int start = hd->part[super_minor].start_sect;
+	int size = hd->part[super_minor].nr_sects;
+
+	if (start == sub_start && size == sub_size) {
+		/* full parent partition, we have it already */
+		return 0;
+	}
+
+	if (start <= sub_start && start+size >= sub_start+sub_size) {
+		add_gd_partition(hd, minor, sub_start, sub_size);
+		return 1;
+	}
+
+	printk("bad subpartition - ignored\n");
+	return 0;
+}
linux/fs/partitions/check.h renamed from linux-2.5.2-pre11/linux/fs/partitions/check.h +6 -0
diff -u --recursive --new-file ../linux-2.5.2-pre11/linux/fs/partitions/check.h ./linux/fs/partitions/check.h
@@ -7,4 +7,10 @@
  */
 void add_gd_partition(struct gendisk *hd, int minor, int start, int size);
 
+/*
+ * check_and_add_subpartition does the same for subpartitions
+ */
+int check_and_add_subpartition(struct gendisk *hd, int super_minor,
+			       int minor, int sub_start, int sub_size);
+
 extern int warn_no_part;
linux/fs/partitions/msdos.c renamed from linux-2.5.2-pre11/linux/fs/partitions/msdos.c +9 -47

75 lines not on this page · raw message