]> TLD Linux GIT Repositories - packages/lvm2.git/blob - device-mapper-dmsetup-export.patch
- move run dir from /run to /var/run so required lvm dir will not vanish
[packages/lvm2.git] / device-mapper-dmsetup-export.patch
1 ---
2  man/dmsetup.8.in |    7 ++++
3  tools/dmsetup.c  |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
4  2 files changed, 95 insertions(+)
5
6 Index: LVM2.2.02.98/man/dmsetup.8.in
7 ===================================================================
8 --- LVM2.2.02.116.orig/man/dmsetup.8.in 2015-01-30 16:19:53.000000000 +0000
9 +++ LVM2.2.02.116/man/dmsetup.8.in      2015-02-03 21:05:01.635601115 +0000
10 @@ -19,6 +19,9 @@ dmsetup \(em low level logical volume ma
11  .IR options ]
12  .RI [ device_name ]
13  .HP
14 +.B dmsetup export
15 +.RI [ device_name ]
16 +.HP
17  .B dmsetup help
18  .RB [ \-c | \-C | \-\-columns ]
19  .HP
20 @@ -309,6 +312,11 @@ device_name in subsequent dmsetup comman
21  \fBblkdevname\fP (block device name),
22  \fBdevname\fP (map name for device-mapper devices, equal to blkdevname otherwise).
23  .HP
24 +.B export
25 +.RI [ device_name ]
26 +.br
27 +Outputs information in key/value format to be imported by other programs.
28 +.HP
29  .B help
30  .RB [ \-c | \-C | \-\-columns ]
31  .br
32 Index: LVM2.2.02.98/tools/dmsetup.c
33 ===================================================================
34 --- LVM2.2.02.98.orig/tools/dmsetup.c
35 +++ LVM2.2.02.98/tools/dmsetup.c
36 @@ -1706,10 +1706,97 @@ static int _status(CMD_ARGS)
37        out:
38         dm_task_destroy(dmt);
39         return r;
40  }
41  
42 +static int _export(CMD_ARGS)
43 +{
44 +       int r = 0;
45 +       struct dm_task *dmt = NULL;
46 +       void *next = NULL;
47 +       uint64_t start, length;
48 +       char *target_type = NULL;
49 +       char *params;
50 +       const char *name = NULL;
51 +       const char *uuid = NULL;
52 +       struct dm_info info;
53 +
54 +       if (names)
55 +               name = names->name;
56 +       else if (argc == 2)
57 +               name = argv[1];
58 +
59 +       if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
60 +               goto out;
61 +
62 +       if (!_set_task_device(dmt, name, 0))
63 +               goto out;
64 +
65 +       if (!dm_task_run(dmt))
66 +               goto out;
67 +
68 +       if (!dm_task_get_info(dmt, &info) || !info.exists)
69 +               goto out;
70 +
71 +       if (!name)
72 +               name = dm_task_get_name(dmt);
73 +
74 +       uuid = dm_task_get_uuid(dmt);
75 +       printf("DM_NAME=%s\n", name);
76 +
77 +       if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
78 +               printf("DM_UUID=%s\n", uuid);
79 +
80 +       if (!info.exists) {
81 +               printf("DM_STATE=NOTPRESENT\n");
82 +               goto out;
83 +       }
84 +
85 +       printf("DM_STATE=%s\n",
86 +              info.suspended ? "SUSPENDED" :
87 +              (info.read_only ? "READONLY" : "ACTIVE"));
88 +
89 +       if (!info.live_table && !info.inactive_table)
90 +               printf("DM_TABLE_STATE=NONE\n");
91 +       else
92 +               printf("DM_TABLE_STATE=%s%s%s\n",
93 +                      info.live_table ? "LIVE" : "",
94 +                      info.live_table && info.inactive_table ? "/" : "",
95 +                      info.inactive_table ? "INACTIVE" : "");
96 +
97 +       if (info.open_count != -1)
98 +               printf("DM_OPENCOUNT=%d\n", info.open_count);
99 +
100 +       printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr);
101 +
102 +       printf("DM_MAJOR=%d\n", info.major);
103 +       printf("DM_MINOR=%d\n", info.minor);
104 +
105 +       if (info.target_count != -1)
106 +               printf("DM_TARGET_COUNT=%d\n", info.target_count);
107 +
108 +       /* export all table types */
109 +       next = dm_get_next_target(dmt, next, &start, &length,
110 +                                 &target_type, &params);
111 +       if (target_type) {
112 +               printf("DM_TARGET_TYPES=%s", target_type);
113 +               while (next) {
114 +                       next = dm_get_next_target(dmt, next, &start, &length,
115 +                                                 &target_type, &params);
116 +                       if (target_type)
117 +                               printf(",%s", target_type);
118 +               }
119 +               printf("\n");
120 +       }
121 +
122 +       r = 1;
123 +      out:
124 +       if (dmt)
125 +               dm_task_destroy(dmt);
126 +       return r;
127 +}
128 +
129  /* Show target names and their version numbers */
130  static int _targets(CMD_ARGS)
131  {
132         int r = 0;
133         struct dm_task *dmt;
134 @@ -3056,10 +3143,11 @@ static struct command _commands[] = {
135         {"ls", "[--target <target_type>] [--exec <command>] [-o <options>] [--tree]", 0, 0, 0, 0, _ls},
136         {"info", "[<device>]", 0, -1, 1, 0, _info},
137         {"deps", "[-o <options>] [<device>]", 0, -1, 1, 0, _deps},
138         {"stats", "<command> [<options>] [<devices>]", 1, -1, 1, 1, _stats},
139         {"status", "[<device>] [--noflush] [--target <target_type>]", 0, -1, 1, 0, _status},
140 +       {"export", "[<device>]", 0, 1, 1, 0, _export},
141         {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, 0, _status},
142         {"wait", "<device> [<event_nr>] [--noflush]", 0, 2, 0, 0, _wait},
143         {"mknodes", "[<device>]", 0, -1, 1, 0, _mknodes},
144         {"mangle", "[<device>]", 0, -1, 1, 0, _mangle},
145         {"udevcreatecookie", "", 0, 0, 0, 0, _udevcreatecookie},