]>
Commit | Line | Data |
---|---|---|
5545a732 JR |
1 | --- util-linux-2.12a/mount/mount_by_label.c.old 2004-08-11 22:25:06.000000000 +0100 |
2 | +++ util-linux-2.12a/mount/mount_by_label.c 2004-08-11 22:25:21.000000000 +0100 | |
3 | @@ -17,6 +17,8 @@ | |
4 | * - Added JFS v2 format support | |
5 | * 2002-07-26 Luciano Chavez <lnx1138@us.ibm.com> | |
6 | * - Added EVMS support | |
7 | + * 2004-08-11 Alasdair Kergon <agk@redhat.com> | |
8 | + * - Added LVM2/device-mapper support | |
9 | */ | |
10 | ||
11 | #include <stdio.h> | |
12 | @@ -38,6 +40,7 @@ | |
13 | #define VG_DIR "/proc/lvm/VGs" | |
14 | #define EVMS_VOLUME_NAME_SIZE 127 | |
15 | #define PROC_EVMS_VOLUMES "/proc/evms/volumes" | |
16 | +#define DEVICEMAPPERDIR "/dev/mapper" | |
17 | ||
18 | static struct uuidCache_s { | |
19 | struct uuidCache_s *next; | |
20 | @@ -101,6 +104,34 @@ | |
21 | closedir(vg_dir); | |
22 | } | |
23 | ||
24 | +/* LVM2/device-mapper support */ | |
25 | +static void | |
26 | +uuidcache_init_dm(void) { | |
27 | + char lvm_device[PATH_MAX]; | |
28 | + DIR *d; | |
29 | + struct dirent *lv_iter; | |
30 | + char uuid[16], *label; | |
31 | + | |
32 | + if (!(d = opendir(DEVICEMAPPERDIR))) { | |
33 | + if (errno != ENOENT) | |
34 | + perror("mount (init_dm)"); | |
35 | + return; | |
36 | + } | |
37 | + | |
38 | + while ((lv_iter = readdir(d))) { | |
39 | + if (!strcmp(lv_iter->d_name, "control") || | |
40 | + !strcmp(lv_iter->d_name, ".") || | |
41 | + !strcmp(lv_iter->d_name, "..")) | |
42 | + continue; | |
43 | + snprintf(lvm_device, sizeof(lvm_device), "%s/%s", | |
44 | + DEVICEMAPPERDIR, lv_iter->d_name); | |
45 | + if (!get_label_uuid(strdup(lvm_device), &label, uuid)) | |
46 | + uuidcache_addentry(strdup(lvm_device), | |
47 | + label, uuid); | |
48 | + } | |
49 | + closedir(d); | |
50 | +} | |
51 | + | |
52 | static int | |
53 | uuidcache_init_evms(void) { | |
54 | FILE *procvol; | |
55 | @@ -250,6 +281,8 @@ | |
56 | fclose(procpt); | |
57 | ||
58 | uuidcache_init_lvm(); | |
59 | + | |
60 | + uuidcache_init_dm(); | |
61 | } | |
62 | ||
63 | #define UUID 1 |