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