[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#248676: [patch] Detection of LVM and RAID partitions



* Eugeniy Meshcheryakov <eugen@univ.kiev.ua> [2004-05-14 18:15]:
>   With this patch find-partitions will detect LVM and RAID partitions
> first (using patition type), then it will detect filesystem type.

This patch might break partconf, but it showed that it's trivial to
do.  I'll commit the following when SVN is back again, thanks.


Index: partconf.h
===================================================================
--- partconf.h	(revision 15354)
+++ partconf.h	(working copy)
@@ -3,6 +3,7 @@
 
 #include <parted/parted.h>
 #include <stdarg.h>
+#include <stdbool.h>
 
 #define FS_ID_SWAP      "82"
 #define FS_ID_LINUX     "83"
@@ -43,6 +44,6 @@
 int      umount_target(void);
 
 /* find-parts.c */
-int      get_all_partitions(struct partition *parts[], const int max_parts);
+int      get_all_partitions(struct partition *parts[], const int max_parts, bool ignore_fs_type);
 
 #endif /* PARTCONF_H_ */
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 15354)
+++ debian/changelog	(working copy)
@@ -2,6 +2,10 @@
 
   * Colin Watson
     - Make sure the ext2 module is loaded, to support non-ext2 initrds.
+  * Martin Michlmayr
+    - Add an --ignore-fstype argument which will cause existing file
+      systems to be ignored.  This is helpful for LVM and RAID detection
+      by lvmcfg and mdcfg. Closes: #248676
 
  -- Colin Watson <cjwatson@debian.org>  Sun, 18 Apr 2004 19:17:34 +0100
 
Index: find-parts.c
===================================================================
--- find-parts.c	(revision 15354)
+++ find-parts.c	(working copy)
@@ -143,11 +143,11 @@
 #endif
 
 static void
-get_partition_info(struct partition *p, PedPartition *part, PedDevice *dev)
+get_partition_info(struct partition *p, PedPartition *part, PedDevice *dev, bool ignore_fs_type)
 {
     if (PART_SIZE_BYTES(dev, part) > 0)
         p->size = PART_SIZE_BYTES(dev, part);
-    if (part->fs_type != NULL) {
+    if (!ignore_fs_type && part->fs_type != NULL) {
         if (strcmp(part->fs_type->name, "linux-swap") == 0)
             p->fstype = strdup("swap");
         else
@@ -165,7 +165,7 @@
 }
 
 int
-get_all_partitions(struct partition *parts[], const int max_parts)
+get_all_partitions(struct partition *parts[], const int max_parts, bool ignore_fs_type)
 {
     char buf[1024], *ptr, partname[1024], tmp[1024];
     FILE *fp, *fptmp;
@@ -254,7 +254,7 @@
             continue;
         if ((part = ped_disk_next_partition(disk, NULL)) == NULL)
             continue;
-        get_partition_info(p, part, dev);
+        get_partition_info(p, part, dev, ignore_fs_type);
     }
     // Add partitions from all the disks we found
     for (i = 0; i < disc_count; i++) {
@@ -310,7 +310,7 @@
             p->op.filesystem = NULL;
             p->op.mountpoint = NULL;
             p->op.done = 0;
-            get_partition_info(p, part, dev);
+            get_partition_info(p, part, dev, ignore_fs_type);
             parts[part_count++] = p;
         }
     }
@@ -325,8 +325,12 @@
 {
     struct partition *parts[MAX_PARTS];
     int part_count, i;
+    bool ignore_fs_type = false;
 
-    if ((part_count = get_all_partitions(parts, MAX_PARTS)) <= 0)
+    if (argc == 2 && strcmp(argv[1], "--ignore-fstype") == 0) {
+        ignore_fs_type = true;
+    }
+    if ((part_count = get_all_partitions(parts, MAX_PARTS, ignore_fs_type)) <= 0)
         return 1;
     for (i = 0; i < part_count; i++) {
         printf("%s\t%s\t%s\n",
Index: partconf.c
===================================================================
--- partconf.c	(revision 15354)
+++ partconf.c	(working copy)
@@ -612,7 +612,7 @@
         debconf_go(debconf);
         return 1;
     }
-    if ((part_count = get_all_partitions(parts, MAX_PARTS)) <= 0) {
+    if ((part_count = get_all_partitions(parts, MAX_PARTS, false)) <= 0) {
         debconf_input(debconf, "critical", "partconf/no-partitions");
         debconf_go(debconf);
         return 1;

-- 
Martin Michlmayr
tbm@cyrius.com



Reply to: