forked from pool/util-linux
66 lines
1.6 KiB
Diff
66 lines
1.6 KiB
Diff
Index: util-linux-ng-2.12r+2.13pre7/mount/mount_by_label.c
|
|
===================================================================
|
|
--- util-linux-ng-2.12r+2.13pre7.orig/mount/mount_by_label.c
|
|
+++ util-linux-ng-2.12r+2.13pre7/mount/mount_by_label.c
|
|
@@ -18,6 +18,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>
|
|
@@ -39,6 +41,7 @@
|
|
#define VG_DIR "/proc/lvm/VGs"
|
|
#define EVMS_VOLUME_NAME_SIZE 127
|
|
#define PROC_EVMS_VOLUMES "/proc/evms/volumes"
|
|
+#define DEVICEMAPPERDIR "/dev/mapper"
|
|
|
|
extern char *progname;
|
|
|
|
@@ -104,6 +107,34 @@ uuidcache_init_lvm(void) {
|
|
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;
|
|
@@ -256,6 +287,8 @@ uuidcache_init(void) {
|
|
fclose(procpt);
|
|
|
|
uuidcache_init_lvm();
|
|
+
|
|
+ uuidcache_init_dm();
|
|
}
|
|
|
|
#define UUID 1
|