util-linux/util-linux-2.12a-mountbylabel-dm.patch

64 lines
1.5 KiB
Diff
Raw Normal View History

--- util-linux-2.12a/mount/mount_by_label.c.old 2004-08-11 22:25:06.000000000 +0100
+++ util-linux-2.12a/mount/mount_by_label.c 2004-08-11 22:25:21.000000000 +0100
@@ -17,6 +17,8 @@
* - Added JFS v2 format support
* 2002-07-26 Luciano Chavez <lnx1138@us.ibm.com>
* - Added EVMS support
+ * 2004-08-11 Alasdair Kergon <agk@redhat.com>
+ * - Added LVM2/device-mapper support
*/
#include <stdio.h>
@@ -38,6 +40,7 @@
#define VG_DIR "/proc/lvm/VGs"
#define EVMS_VOLUME_NAME_SIZE 127
#define PROC_EVMS_VOLUMES "/proc/evms/volumes"
+#define DEVICEMAPPERDIR "/dev/mapper"
static struct uuidCache_s {
struct uuidCache_s *next;
@@ -101,6 +104,34 @@
closedir(vg_dir);
}
+/* LVM2/device-mapper support */
+static void
+uuidcache_init_dm(void) {
+ char lvm_device[PATH_MAX];
+ DIR *d;
+ struct dirent *lv_iter;
+ char uuid[16], *label;
+
+ if (!(d = opendir(DEVICEMAPPERDIR))) {
+ if (errno != ENOENT)
+ perror("mount (init_dm)");
+ return;
+ }
+
+ while ((lv_iter = readdir(d))) {
+ if (!strcmp(lv_iter->d_name, "control") ||
+ !strcmp(lv_iter->d_name, ".") ||
+ !strcmp(lv_iter->d_name, ".."))
+ continue;
+ snprintf(lvm_device, sizeof(lvm_device), "%s/%s",
+ DEVICEMAPPERDIR, lv_iter->d_name);
+ if (!get_label_uuid(strdup(lvm_device), &label, uuid))
+ uuidcache_addentry(strdup(lvm_device),
+ label, uuid);
+ }
+ closedir(d);
+}
+
static int
uuidcache_init_evms(void) {
FILE *procvol;
@@ -250,6 +281,8 @@
fclose(procpt);
uuidcache_init_lvm();
+
+ uuidcache_init_dm();
}
#define UUID 1