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