[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Ok to commit LVM2 patch ?
From: |
Sven Luther |
Subject: |
Ok to commit LVM2 patch ? |
Date: |
Sun, 28 Nov 2004 21:03:12 +0100 |
User-agent: |
Mutt/1.5.6+20040907i |
Hello,
Since i got no reply to my list of debian patches i sent indirectly earlier, i
will send mail here for each of them, asking if it is ok to commit or not.
Here is the lvm2 patch :
#! /bin/sh -e
## lvm2.dpatch by Andres Salomon <address@hidden>
##
## DP: Find LVM2 devices by looking in /dev/mapper
## DP: Closes: #247174
. $(dirname $0)/DPATCH
@DPATCH@
diff -urN parted-1.6.9.orig/libparted/linux.c parted-1.6.9/libparted/linux.c
--- parted-1.6.9.orig/libparted/linux.c 2004-05-05 14:41:23.000000000 +0100
+++ parted-1.6.9/libparted/linux.c 2004-05-05 14:45:53.000000000 +0100
@@ -24,6 +24,7 @@
#include <parted/linux.h>
#include <ctype.h>
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
@@ -1356,6 +1357,68 @@
return *pos == 0;
}
+ static int
+_probe_lvm_major ()
+{
+ FILE* proc_devices;
+ int major, result = 0;
+ char buf [512];
+ char dev_name [32];
+
+ /* Obtain the major number for lvm devices; this is listed in
+ * /proc/devices, under the device-mapper entry.
+ */
+
+ proc_devices = fopen ("/proc/devices", "r");
+ if (!proc_devices)
+ return 0;
+
+ while (fgets (buf, 512, proc_devices)) {
+ if (sscanf (buf, "%d %31s", &major, dev_name) == 2
+ && strcmp (dev_name, "device-mapper") == 0) {
+ result = major;
+ break;
+ }
+ }
+ fclose (proc_devices);
+
+ return result;
+}
+
+static int
+_probe_lvm_devices ()
+{
+ DIR* mapper_dir;
+ struct dirent* dent;
+ char buf [512]; /* readdir(3) claims d_name[256] */
+ struct stat st;
+ int lvm_major;
+
+ lvm_major = _probe_lvm_major ();
+ if (!lvm_major)
+ return 0;
+
+ mapper_dir = opendir ("/dev/mapper");
+ if (!mapper_dir)
+ return 0;
+
+ /* Search the /dev/mapper directory for devices w/ the same major
+ * number that was returned from _probe_lvm_major().
+ */
+ while ((dent = readdir (mapper_dir))) {
+ if (strcmp (dent->d_name, ".") == 0 ||
+ strcmp (dent->d_name, "..") == 0)
+ continue;
+
+ snprintf (buf, sizeof (buf), "/dev/mapper/%s", dent->d_name);
+ if (stat (buf, &st) == 0 && (major (st.st_rdev) == lvm_major))
+ _ped_device_probe (buf);
+ }
+ closedir (mapper_dir);
+
+ return 1;
+}
+
static int
_probe_proc_partitions ()
{
@@ -1442,6 +1505,12 @@
_probe_devfs_devices ();
else
_probe_standard_devices ();
+
+ /* LVM2 devices aren't listed in /proc/partitions; or, if they are,
+ * they're listed as dm-X. So, instead of relying on that, we do
+ * our own checks.
+ */
+ _probe_lvm_devices ();
}
static char*
Comments on this patch ?
Friendly,
Sven Luther
- Ok to commit LVM2 patch ?,
Sven Luther <=