]> git.pld-linux.org Git - packages/lvm2.git/blame - device-mapper-dmsetup-export.patch
- disable lvmetad for now
[packages/lvm2.git] / device-mapper-dmsetup-export.patch
CommitLineData
78cc64d1
ER
1diff --git a/dmsetup/dmsetup.c b/dmsetup/dmsetup.c
2index 25f14a6..b693008 100644
9a00e98a
ER
3--- a/tools/dmsetup.c
4+++ b/tools/dmsetup.c
78cc64d1
ER
5@@ -995,6 +995,94 @@ static int _status(int argc, char **argv
6 return r;
7 }
8
9+static int _export(int argc, char **argv, void *data)
10+{
11+ int r = 0;
12+ struct dm_task *dmt = NULL;
13+ void *next = NULL;
14+ uint64_t start, length;
15+ char *target_type = NULL;
16+ char *params;
17+ struct dm_names *names = (struct dm_names *) data;
18+ const char *name = NULL;
19+ const char *uuid = NULL;
20+ struct dm_info info;
21+
22+ if (data)
23+ name = names->name;
24+ else if (argc == 2)
25+ name = argv[1];
26+
27+ if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
28+ goto out;
29+
30+ if (!_set_task_device(dmt, name, 0))
31+ goto out;
32+
33+ if (!dm_task_run(dmt))
34+ goto out;
35+
36+ if (!dm_task_get_info(dmt, &info) || !info.exists)
37+ goto out;
38+
39+ if (!name)
40+ name = dm_task_get_name(dmt);
41+
42+ uuid = dm_task_get_uuid(dmt);
43+ printf("DM_NAME=%s\n", name);
44+
45+ if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
46+ printf("DM_UUID=%s\n", uuid);
47+
48+ if (!info.exists) {
49+ printf("DM_STATE=NOTPRESENT\n");
50+ goto out;
51+ }
52+
53+ printf("DM_STATE=%s\n",
54+ info.suspended ? "SUSPENDED" :
55+ (info.read_only ? " READONLY" : "ACTIVE"));
56+
57+ if (!info.live_table && !info.inactive_table)
58+ printf("DM_TABLE_STATE=NONE\n");
59+ else
60+ printf("DM_TABLE_STATE=%s%s%s\n",
61+ info.live_table ? "LIVE" : "",
62+ info.live_table && info.inactive_table ? "/" : "",
63+ info.inactive_table ? "INACTIVE" : "");
64+
65+ if (info.open_count != -1)
66+ printf("DM_OPENCOUNT=%d\n", info.open_count);
67+
68+ printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr);
69+
70+ printf("DM_MAJOR=%d\n", info.major);
71+ printf("DM_MINOR=%d\n", info.minor);
72+
73+ if (info.target_count != -1)
74+ printf("DM_TARGET_COUNT=%d\n", info.target_count);
75+
76+ /* export all table types */
77+ next = dm_get_next_target(dmt, next, &start, &length,
78+ &target_type, &params);
79+ if (target_type) {
80+ printf("DM_TARGET_TYPES=%s", target_type);
81+ while (next) {
82+ next = dm_get_next_target(dmt, next, &start, &length,
83+ &target_type, &params);
84+ if (target_type)
85+ printf(",%s", target_type);
86+ }
87+ printf("\n");
88+ }
89+
90+ r = 1;
91+ out:
92+ if (dmt)
93+ dm_task_destroy(dmt);
94+ return r;
95+}
96+
97 /* Show target names and their version numbers */
98 static int _targets(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused)))
99 {
100@@ -1699,6 +1787,7 @@ static struct command _commands[] = {
6e7a47a9
AM
101 {"info", "[<device>]", 0, -1, 1, _info},
102 {"deps", "[<device>]", 0, -1, 1, _deps},
103 {"status", "[<device>] [--target <target_type>]", 0, -1, 1, _status},
104+ {"export", "[<device>]", 0, -1, 1, _export},
105 {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, _status},
106 {"wait", "<device> [<event_nr>]", 0, 2, 0, _wait},
107 {"mknodes", "[<device>]", 0, -1, 1, _mknodes},
78cc64d1
ER
108diff --git a/man/dmsetup.8 b/man/dmsetup.8
109index 5b2ed9f..c4524aa 100644
9a00e98a
ER
110--- a/man/dmsetup.8.in
111+++ b/man/dmsetup.8.in
94530879
JR
112@@ -39,6 +39,9 @@ dmsetup \- low level logical volume mana
113 .RI [ device_name ]
114 .RE
78cc64d1
ER
115 .br
116+.B dmsetup export
e8344586 117+.RI [ device_name ]
78cc64d1 118+.br
94530879
JR
119 .B dmsetup load
120 .I device_name
121 .RB [ \-\-table
122@@ -138,6 +141,12 @@ device_name in subsequent dmsetup comman
123 /dev/mapper/<device-name>.
78cc64d1 124 See below for information on the table format.
94530879
JR
125 .br
126+.TP
127+.B export
e8344586 128+.RI [ device_name ]
78cc64d1
ER
129+.br
130+Outputs information in key/value format to be imported by other programs.
94530879
JR
131+.br
132 .TP
133 .B deps
134 .RB [ \-o
This page took 0.043525 seconds and 4 git commands to generate.