]>
Commit | Line | Data |
---|---|---|
0a81c260 ER |
1 | --- |
2 | man/dmsetup.8.in | 7 ++++ | |
3 | tools/dmsetup.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
4 | 2 files changed, 95 insertions(+) | |
5 | ||
e2727f8c JB |
6 | --- LVM2.2.02.149/man/dmsetup.8.in.orig 2016-04-05 22:16:49.848604442 +0200 |
7 | +++ LVM2.2.02.149/man/dmsetup.8.in 2016-04-06 15:59:35.582595117 +0200 | |
8 | @@ -48,6 +48,14 @@ | |
9 | . | |
d21b6d6f | 10 | .HP |
e2727f8c JB |
11 | .B dmsetup |
12 | +.de CMD_EXPORT | |
13 | +. BR export | |
14 | +. RI [ device_name ] | |
15 | +.. | |
16 | +.CMD_EXPORT | |
17 | +. | |
d21b6d6f | 18 | +.HP |
e2727f8c JB |
19 | +.B dmsetup |
20 | .de CMD_HELP | |
21 | . BR help | |
22 | . RB [ \-c | \-C | \-\-columns ] | |
23 | @@ -629,6 +637,9 @@ | |
d21b6d6f | 24 | \fBdevname\fP (map name for device-mapper devices, equal to blkdevname otherwise). |
e2727f8c | 25 | . |
d21b6d6f | 26 | .HP |
e2727f8c | 27 | +.CMD_EXPORT |
4cb4934b | 28 | +Outputs information in key/value format to be imported by other programs. |
d21b6d6f | 29 | +.HP |
e2727f8c | 30 | .CMD_HELP |
0a81c260 | 31 | .br |
e2727f8c | 32 | Outputs a summary of the commands available, optionally including |
54ec8eef JB |
33 | --- LVM2.2.02.130/tools/dmsetup.c.orig 2015-09-09 18:44:39.471523160 +0200 |
34 | +++ LVM2.2.02.130/tools/dmsetup.c 2015-09-09 18:48:33.918179988 +0200 | |
35 | @@ -2189,6 +2189,93 @@ | |
78cc64d1 ER |
36 | return r; |
37 | } | |
38 | ||
0a81c260 | 39 | +static int _export(CMD_ARGS) |
78cc64d1 ER |
40 | +{ |
41 | + int r = 0; | |
42 | + struct dm_task *dmt = NULL; | |
43 | + void *next = NULL; | |
44 | + uint64_t start, length; | |
45 | + char *target_type = NULL; | |
46 | + char *params; | |
78cc64d1 ER |
47 | + const char *name = NULL; |
48 | + const char *uuid = NULL; | |
49 | + struct dm_info info; | |
50 | + | |
0a81c260 | 51 | + if (names) |
78cc64d1 ER |
52 | + name = names->name; |
53 | + else if (argc == 2) | |
54 | + name = argv[1]; | |
55 | + | |
56 | + if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) | |
57 | + goto out; | |
58 | + | |
59 | + if (!_set_task_device(dmt, name, 0)) | |
60 | + goto out; | |
61 | + | |
62 | + if (!dm_task_run(dmt)) | |
63 | + goto out; | |
64 | + | |
65 | + if (!dm_task_get_info(dmt, &info) || !info.exists) | |
66 | + goto out; | |
67 | + | |
68 | + if (!name) | |
69 | + name = dm_task_get_name(dmt); | |
70 | + | |
71 | + uuid = dm_task_get_uuid(dmt); | |
72 | + printf("DM_NAME=%s\n", name); | |
73 | + | |
74 | + if ((uuid = dm_task_get_uuid(dmt)) && *uuid) | |
75 | + printf("DM_UUID=%s\n", uuid); | |
76 | + | |
77 | + if (!info.exists) { | |
78 | + printf("DM_STATE=NOTPRESENT\n"); | |
79 | + goto out; | |
80 | + } | |
81 | + | |
82 | + printf("DM_STATE=%s\n", | |
83 | + info.suspended ? "SUSPENDED" : | |
0a81c260 | 84 | + (info.read_only ? "READONLY" : "ACTIVE")); |
78cc64d1 ER |
85 | + |
86 | + if (!info.live_table && !info.inactive_table) | |
87 | + printf("DM_TABLE_STATE=NONE\n"); | |
88 | + else | |
89 | + printf("DM_TABLE_STATE=%s%s%s\n", | |
90 | + info.live_table ? "LIVE" : "", | |
91 | + info.live_table && info.inactive_table ? "/" : "", | |
92 | + info.inactive_table ? "INACTIVE" : ""); | |
93 | + | |
94 | + if (info.open_count != -1) | |
95 | + printf("DM_OPENCOUNT=%d\n", info.open_count); | |
96 | + | |
97 | + printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr); | |
98 | + | |
99 | + printf("DM_MAJOR=%d\n", info.major); | |
100 | + printf("DM_MINOR=%d\n", info.minor); | |
101 | + | |
102 | + if (info.target_count != -1) | |
103 | + printf("DM_TARGET_COUNT=%d\n", info.target_count); | |
104 | + | |
105 | + /* export all table types */ | |
106 | + next = dm_get_next_target(dmt, next, &start, &length, | |
107 | + &target_type, ¶ms); | |
108 | + if (target_type) { | |
109 | + printf("DM_TARGET_TYPES=%s", target_type); | |
110 | + while (next) { | |
111 | + next = dm_get_next_target(dmt, next, &start, &length, | |
112 | + &target_type, ¶ms); | |
113 | + if (target_type) | |
114 | + printf(",%s", target_type); | |
115 | + } | |
116 | + printf("\n"); | |
117 | + } | |
118 | + | |
119 | + r = 1; | |
120 | + out: | |
121 | + if (dmt) | |
122 | + dm_task_destroy(dmt); | |
123 | + return r; | |
124 | +} | |
125 | + | |
126 | /* Show target names and their version numbers */ | |
4cb4934b | 127 | static int _targets(CMD_ARGS) |
78cc64d1 | 128 | { |
54ec8eef JB |
129 | @@ -5139,6 +5226,7 @@ |
130 | {"stats", "<command> [<options>] [<devices>]", 1, -1, 1, 1, _stats}, | |
131 | {"status", "[<device>] [--noflush] [--target <target_type>]", 0, -1, 1, 0, _status}, | |
132 | {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, 0, _status}, | |
133 | + {"export", "[<device>]", 0, 1, 1, 0, _export}, | |
134 | {"wait", "<device> [<event_nr>] [--noflush]", 0, 2, 0, 0, _wait}, | |
135 | {"mknodes", "[<device>]", 0, -1, 1, 0, _mknodes}, | |
136 | {"mangle", "[<device>]", 0, -1, 1, 0, _mangle}, |