1 diff --git a/dmsetup/dmsetup.c b/dmsetup/dmsetup.c
2 index 25f14a6..b693008 100644
3 --- a/dmsetup/dmsetup.c
4 +++ b/dmsetup/dmsetup.c
5 @@ -995,6 +995,94 @@ static int _status(int argc, char **argv
9 +static int _export(int argc, char **argv, void *data)
12 + struct dm_task *dmt = NULL;
14 + uint64_t start, length;
15 + char *target_type = NULL;
17 + struct dm_names *names = (struct dm_names *) data;
18 + const char *name = NULL;
19 + const char *uuid = NULL;
20 + struct dm_info info;
27 + if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
30 + if (!_set_task_device(dmt, name, 0))
33 + if (!dm_task_run(dmt))
36 + if (!dm_task_get_info(dmt, &info) || !info.exists)
40 + name = dm_task_get_name(dmt);
42 + uuid = dm_task_get_uuid(dmt);
43 + printf("DM_NAME=%s\n", name);
45 + if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
46 + printf("DM_UUID=%s\n", uuid);
49 + printf("DM_STATE=NOTPRESENT\n");
53 + printf("DM_STATE=%s\n",
54 + info.suspended ? "SUSPENDED" :
55 + (info.read_only ? " READONLY" : "ACTIVE"));
57 + if (!info.live_table && !info.inactive_table)
58 + printf("DM_TABLE_STATE=NONE\n");
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" : "");
65 + if (info.open_count != -1)
66 + printf("DM_OPENCOUNT=%d\n", info.open_count);
68 + printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr);
70 + printf("DM_MAJOR=%d\n", info.major);
71 + printf("DM_MINOR=%d\n", info.minor);
73 + if (info.target_count != -1)
74 + printf("DM_TARGET_COUNT=%d\n", info.target_count);
76 + /* export all table types */
77 + next = dm_get_next_target(dmt, next, &start, &length,
78 + &target_type, ¶ms);
80 + printf("DM_TARGET_TYPES=%s", target_type);
82 + next = dm_get_next_target(dmt, next, &start, &length,
83 + &target_type, ¶ms);
85 + printf(",%s", target_type);
93 + dm_task_destroy(dmt);
97 /* Show target names and their version numbers */
98 static int _targets(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused)))
100 @@ -1699,6 +1787,7 @@ static struct command _commands[] = {
101 {"info", "[<device>]", 0, 1, _info},
102 {"deps", "[<device>]", 0, 1, _deps},
103 {"status", "[<device>] [--target <target_type>]", 0, 1, _status},
104 + {"export", "[<device>]", 0, 1, _export},
105 {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, 1, _status},
106 {"wait", "<device> [<event_nr>]", 0, 2, _wait},
107 {"mknodes", "[<device>]", 0, 1, _mknodes},
108 diff --git a/man/dmsetup.8 b/man/dmsetup.8
109 index 5b2ed9f..c4524aa 100644
112 @@ -39,13 +39,16 @@ dmsetup \- low level logical volume mana
114 .I [--target target_type] [--exec command] [--tree [-o options]]
120 .B dmsetup info -c|-C|--columns
121 .I [--noheadings] [--separator separator] [-o fields] [-O|--sort sort_fields]
130 @@ -138,6 +141,10 @@ device_name in subsequent dmsetup comman
131 If successful a device will appear as
132 /dev/device-mapper/<device-name>.
133 See below for information on the table format.
137 +Outputs information in key/value format to be imported by other programs.