]> TLD Linux GIT Repositories - packages/lvm2.git/blob - device-mapper-dmsetup-export.patch
- updated to 2.02.140
[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 @@ -48,6 +48,14 @@ dmsetup \(em low level logical volume ma
11  .
12  .HP
13  .B dmsetup
14 +.de CMD_EXPORT
15 +.  BR export
16 +.  RI [ device_name ]
17 +..
18 +.CMD_EXPORT
19 +.
20 +.HP
21 +.B dmsetup
22  .de CMD_HELP
23  .  BR help
24  .  RB [ \-c | \-C | \-\-columns ]
25 @@ -629,6 +637,11 @@ device. Device names on output can be cu
26  \fBdevname\fP (map name for device-mapper devices, equal to blkdevname otherwise).
27  .
28  .HP
29 +.CMD_EXPORT
30 +.br
31 +Outputs information in key/value format to be imported by other programs.
32 +.
33 +.HP
34  .CMD_HELP
35  .br
36  Outputs a summary of the commands available, optionally including
37 Index: LVM2.2.02.98/tools/dmsetup.c
38 ===================================================================
39 --- LVM2.2.02.98.orig/tools/dmsetup.c
40 +++ LVM2.2.02.98/tools/dmsetup.c
41 @@ -2194,6 +2194,93 @@ out:
42         return r;
43  }
44  
45 +static int _export(CMD_ARGS)
46 +{
47 +       int r = 0;
48 +       struct dm_task *dmt = NULL;
49 +       void *next = NULL;
50 +       uint64_t start, length;
51 +       char *target_type = NULL;
52 +       char *params;
53 +       const char *name = NULL;
54 +       const char *uuid = NULL;
55 +       struct dm_info info;
56 +
57 +       if (names)
58 +               name = names->name;
59 +       else if (argc == 2)
60 +               name = argv[1];
61 +
62 +       if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
63 +               goto out;
64 +
65 +       if (!_set_task_device(dmt, name, 0))
66 +               goto out;
67 +
68 +       if (!dm_task_run(dmt))
69 +               goto out;
70 +
71 +       if (!dm_task_get_info(dmt, &info) || !info.exists)
72 +               goto out;
73 +
74 +       if (!name)
75 +               name = dm_task_get_name(dmt);
76 +
77 +       uuid = dm_task_get_uuid(dmt);
78 +       printf("DM_NAME=%s\n", name);
79 +
80 +       if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
81 +               printf("DM_UUID=%s\n", uuid);
82 +
83 +       if (!info.exists) {
84 +               printf("DM_STATE=NOTPRESENT\n");
85 +               goto out;
86 +       }
87 +
88 +       printf("DM_STATE=%s\n",
89 +              info.suspended ? "SUSPENDED" :
90 +              (info.read_only ? "READONLY" : "ACTIVE"));
91 +
92 +       if (!info.live_table && !info.inactive_table)
93 +               printf("DM_TABLE_STATE=NONE\n");
94 +       else
95 +               printf("DM_TABLE_STATE=%s%s%s\n",
96 +                      info.live_table ? "LIVE" : "",
97 +                      info.live_table && info.inactive_table ? "/" : "",
98 +                      info.inactive_table ? "INACTIVE" : "");
99 +
100 +       if (info.open_count != -1)
101 +               printf("DM_OPENCOUNT=%d\n", info.open_count);
102 +
103 +       printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr);
104 +
105 +       printf("DM_MAJOR=%d\n", info.major);
106 +       printf("DM_MINOR=%d\n", info.minor);
107 +
108 +       if (info.target_count != -1)
109 +               printf("DM_TARGET_COUNT=%d\n", info.target_count);
110 +
111 +       /* export all table types */
112 +       next = dm_get_next_target(dmt, next, &start, &length,
113 +                                 &target_type, &params);
114 +       if (target_type) {
115 +               printf("DM_TARGET_TYPES=%s", target_type);
116 +               while (next) {
117 +                       next = dm_get_next_target(dmt, next, &start, &length,
118 +                                                 &target_type, &params);
119 +                       if (target_type)
120 +                               printf(",%s", target_type);
121 +               }
122 +               printf("\n");
123 +       }
124 +
125 +       r = 1;
126 +      out:
127 +       if (dmt)
128 +               dm_task_destroy(dmt);
129 +       return r;
130 +}
131 +
132  /* Show target names and their version numbers */
133  static int _targets(CMD_ARGS)
134  {
135 @@ -5155,6 +5242,7 @@ static struct command _dmsetup_commands[
136         {"deps", "[-o <options>] [<device>]", 0, -1, 1, 0, _deps},
137         {"stats", "<command> [<options>] [<devices>]", 1, -1, 1, 1, _stats},
138         {"status", "[<device>] [--noflush] [--target <target_type>]", 0, -1, 1, 0, _status},
139 +       {"export", "[<device>]", 0, 1, 1, 0, _export},
140         {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, 0, _status},
141         {"wait", "<device> [<event_nr>] [--noflush]", 0, 2, 0, 0, _wait},
142         {"mknodes", "[<device>]", 0, -1, 1, 0, _mknodes},