Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-fs/device-mapper/files: device-mapper-1.02.27-export-format.diff
Date: Sat, 28 Jun 2008 09:10:55
Message-Id: E1KCWSH-00018g-Hx@stork.gentoo.org
1 robbat2 08/06/28 09:10:49
2
3 Added: device-mapper-1.02.27-export-format.diff
4 Log:
5 Version bump, dep for the latest lvm2.
6 (Portage version: 2.2_rc1/cvs/Linux 2.6.26-rc4-00103-g1beee8d x86_64)
7
8 Revision Changes Path
9 1.1 sys-fs/device-mapper/files/device-mapper-1.02.27-export-format.diff
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/device-mapper/files/device-mapper-1.02.27-export-format.diff?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/device-mapper/files/device-mapper-1.02.27-export-format.diff?rev=1.1&content-type=text/plain
13
14 Index: device-mapper-1.02.27-export-format.diff
15 ===================================================================
16 diff -Nuar --exclude '*.rej' --exclude '*.orig' device-mapper.1.02.27.orig/dmsetup/dmsetup.c device-mapper.1.02.27/dmsetup/dmsetup.c
17 --- device-mapper.1.02.27.orig/dmsetup/dmsetup.c 2008-06-24 15:53:47.000000000 -0700
18 +++ device-mapper.1.02.27/dmsetup/dmsetup.c 2008-06-28 01:53:56.048598048 -0700
19 @@ -108,6 +108,7 @@
20 enum {
21 READ_ONLY = 0,
22 COLS_ARG,
23 + EXPORT_ARG,
24 EXEC_ARG,
25 FORCE_ARG,
26 GID_ARG,
27 @@ -142,7 +143,8 @@
28 DR_TASK = 1,
29 DR_INFO = 2,
30 DR_DEPS = 4,
31 - DR_TREE = 8 /* Complete dependency tree required */
32 + DR_TREE = 8, /* Complete dependency tree required */
33 + DR_TABLE = 0x10, /* table is required, not just info */
34 } report_type_t;
35
36 static int _switches[NUM_SWITCHES];
37 @@ -1126,8 +1128,13 @@
38 name = argv[1];
39 }
40
41 - if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
42 - return 0;
43 + if (_report_type & DR_TABLE ) {
44 + if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
45 + return 0;
46 + } else {
47 + if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
48 + return 0;
49 + }
50
51 if (!_set_task_device(dmt, name, 0))
52 goto out;
53 @@ -1591,6 +1598,16 @@
54 return dm_report_field_uint32(rh, field, &value);
55 }
56
57 +static int _int_disp(struct dm_report *rh,
58 + struct dm_pool *mem __attribute((unused)),
59 + struct dm_report_field *field, const void *data,
60 + void *private __attribute((unused)))
61 +{
62 + const int value = *(const int *)data;
63 +
64 + return dm_report_field_int(rh, field, &value);
65 +}
66 +
67 static int _dm_name_disp(struct dm_report *rh,
68 struct dm_pool *mem __attribute((unused)),
69 struct dm_report_field *field, const void *data,
70 @@ -1702,6 +1719,66 @@
71 }
72
73
74 +static int _dm_info_cleartext_status_disp(struct dm_report *rh,
75 + struct dm_pool *mem __attribute((unused)),
76 + struct dm_report_field *field, const void *data,
77 + void *private __attribute((unused)))
78 +{
79 + const char *buf = "NOTPRESENT";
80 + const struct dm_info *info = data;
81 +
82 + if (info->exists) {
83 + if (info->suspended)
84 + buf = "SUSPENDED";
85 + else
86 + buf = info->read_only ? " READONLY" : "ACTIVE";
87 + }
88 +
89 + return dm_report_field_string(rh, field, &buf);
90 +}
91 +
92 +static int _dm_info_target_types_disp(struct dm_report *rh,
93 + struct dm_pool *mem __attribute((unused)),
94 + struct dm_report_field *field, const void *data,
95 + void *private __attribute((unused)))
96 +{
97 + char buf[1024];
98 + char *dest = buf;
99 + int remains = sizeof(buf);
100 + int written;
101 + const char *s = buf;
102 + struct dm_task *dmt = (struct dm_task *) data;
103 + void *next = NULL;
104 + uint64_t start, length;
105 + char *target_type = NULL;
106 + char *params;
107 +
108 +
109 + buf[0] = '\0';
110 +
111 + next = dm_get_next_target(dmt, next, &start, &length,
112 + &target_type, &params);
113 + if (target_type) {
114 + written = snprintf(dest, remains, "%s", target_type);
115 + dest += written;
116 + remains -= written;
117 +
118 + while (remains > 0 && next) {
119 + next = dm_get_next_target(dmt, next, &start, &length,
120 + &target_type, &params);
121 + if (target_type) {
122 + written = snprintf(dest, remains, ",%s", target_type);
123 + dest += written;
124 + remains -= written;
125 + }
126 + }
127 + }
128 +
129 + buf[sizeof(buf)-1] = '\0';
130 +
131 + return dm_report_field_string(rh, field, &s);
132 +}
133 +
134 static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
135 struct dm_report_field *field, const void *data,
136 void *private)
137 @@ -1925,6 +2002,7 @@
138 { DR_INFO, "Mapped Device Information", "", _info_get_obj },
139 { DR_DEPS, "Mapped Device Relationship Information", "", _deps_get_obj },
140 { DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj },
141 + { DR_TABLE, "Mapped Device Table", "", _task_get_obj },
142 { 0, "", "", NULL },
143 };
144
145 @@ -1944,6 +2022,7 @@
146 FIELD_F(TASK, NUM, "RAhead", 6, dm_read_ahead, "read_ahead", "Read ahead in sectors.")
147
148 FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "attr", "(L)ive, (I)nactive, (s)uspended, (r)ead-only, read-(w)rite.")
149 +FIELD_F(INFO, STR, "State", 1, dm_info_cleartext_status, "status", "State as cleartext.")
150 FIELD_F(INFO, STR, "Tables", 6, dm_info_table_loaded, "tables_loaded", "Which of the live and inactive table slots are filled.")
151 FIELD_F(INFO, STR, "Suspended", 9, dm_info_suspended, "suspended", "Whether the device is suspended.")
152 FIELD_F(INFO, STR, "Read-only", 9, dm_info_read_only, "readonly", "Whether the device is read-only or writeable.")
153 @@ -1954,6 +2033,11 @@
154 FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "segments", "Number of segments in live table, if present.")
155 FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "events", "Number of most recent event.")
156
157 +FIELD_O(INFO, dm_info, NUM, "RO", read_only, 2, int, "read_only", "Read only.")
158 +FIELD_O(INFO, dm_info, NUM, "Ex", exists, 2, int, "exists", "Exists.")
159 +FIELD_O(INFO, dm_info, NUM, "Susp", suspended, 4, int, "suspended", "Suspended.")
160 +FIELD_O(INFO, dm_info, NUM, "tab_live", live_table, 8, int, "table_live", "Live table.")
161 +FIELD_O(INFO, dm_info, NUM, "tab_inact", inactive_table, 9, int, "table_inactive", "Inactive table.")
162 FIELD_O(DEPS, dm_deps, NUM, "#Devs", count, 5, int32, "device_count", "Number of devices used by this one.")
163 FIELD_F(TREE, STR, "DevNames", 8, dm_deps_names, "devs_used", "List of names of mapped devices used by this one.")
164 FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers of devices used by this one.")
165 @@ -1961,6 +2045,7 @@
166 FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count", "Number of mapped devices referencing this one.")
167 FIELD_F(TREE, STR, "RefNames", 8, dm_tree_parents_names, "names_using_dev", "List of names of mapped devices using this one.")
168 FIELD_F(TREE, STR, "RefDevNos", 9, dm_tree_parents_devs, "devnos_using_dev", "List of device numbers of mapped devices using this one.")
169 +FIELD_F(TABLE, STR, "Targettypes", 32, dm_info_target_types, "target_types", "Used target types.")
170 {0, 0, 0, 0, "", "", NULL, NULL},
171 /* *INDENT-ON* */
172 };
173 @@ -1971,13 +2056,15 @@
174 #undef FIELD_F
175
176 static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
177 +static const char *default_export_options = "name,major,minor,status,read_only,exists,suspended,table_live,table_inactive,open,segments,events,uuid,target_types";
178
179 static int _report_init(struct command *c)
180 {
181 - char *options = (char *) default_report_options;
182 + char *default_options = (char *) default_report_options;
183 + char *options;
184 const char *keys = "";
185 const char *separator = " ";
186 - int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
187 + int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0, export = 0;
188 int quoted = 1, columns_as_rows = 0;
189 uint32_t flags = 0;
190 size_t len = 0;
191 @@ -2004,6 +2091,15 @@
192 field_prefixes = 1;
193 }
194
195 + if (_switches[EXPORT_ARG]) {
196 + default_options = (char *) default_export_options;
197 + separator = "\n";
198 + aligned = 0;
199 + headings = 0;
200 + export = 1;
201 + }
202 +
203 + options = default_options;
204 if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) {
205 if (*_string_args[OPTIONS_ARG] != '+')
206 options = _string_args[OPTIONS_ARG];
207 @@ -2055,6 +2151,9 @@
208 if (columns_as_rows)
209 flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS;
210
211 + if (export)
212 + flags |= DM_REPORT_OUTPUT_EXPORT;
213 +
214 if (!(_report = dm_report_init(&_report_type,
215 _report_types, _report_fields,
216 options, separator, flags, keys, NULL)))
217 @@ -2133,7 +2232,8 @@
218 fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n"
219 " [-r|--readonly] [--noopencount] [--nolockfs]\n"
220 " [--readahead [+]<sectors>|auto|none]\n"
221 - " [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
222 + " [-c|-C|--columns] [-e|--export]\n"
223 + " [-o <fields>] [-O|--sort <sort_fields>]\n"
224 " [--nameprefixes] [--noheadings] [--separator <separator>]\n\n");
225 for (i = 0; _commands[i].name; i++)
226 fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
227 @@ -2484,6 +2584,7 @@
228 static struct option long_options[] = {
229 {"readonly", 0, &ind, READ_ONLY},
230 {"columns", 0, &ind, COLS_ARG},
231 + {"export", 0, &ind, EXPORT_ARG},
232 {"exec", 1, &ind, EXEC_ARG},
233 {"force", 0, &ind, FORCE_ARG},
234 {"gid", 1, &ind, GID_ARG},
235 @@ -2566,12 +2667,16 @@
236
237 optarg = 0;
238 optind = OPTIND_INIT;
239 - while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:O:ru:Uv",
240 + while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCefGj:m:Mno:O:ru:Uv",
241 long_options, NULL)) != -1) {
242 if (c == ':' || c == '?')
243 return 0;
244 if (c == 'c' || c == 'C' || ind == COLS_ARG)
245 _switches[COLS_ARG]++;
246 + if (c == 'e' || ind == EXPORT_ARG) {
247 + _switches[EXPORT_ARG]++;
248 + _switches[COLS_ARG]++;
249 + }
250 if (c == 'f' || ind == FORCE_ARG)
251 _switches[FORCE_ARG]++;
252 if (c == 'r' || ind == READ_ONLY)
253 diff -Nuar --exclude '*.rej' --exclude '*.orig' device-mapper.1.02.27.orig/lib/libdevmapper.h device-mapper.1.02.27/lib/libdevmapper.h
254 --- device-mapper.1.02.27.orig/lib/libdevmapper.h 2008-06-24 15:53:48.000000000 -0700
255 +++ device-mapper.1.02.27/lib/libdevmapper.h 2008-06-28 01:54:55.588111461 -0700
256 @@ -742,6 +742,7 @@
257 #define DM_REPORT_OUTPUT_FIELD_NAME_PREFIX 0x00000008
258 #define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010
259 #define DM_REPORT_OUTPUT_COLUMNS_AS_ROWS 0x00000020
260 +#define DM_REPORT_OUTPUT_EXPORT 0x00000040
261
262 struct dm_report *dm_report_init(uint32_t *report_types,
263 const struct dm_report_object_type *types,
264 diff -Nuar --exclude '*.rej' --exclude '*.orig' device-mapper.1.02.27.orig/lib/libdm-report.c device-mapper.1.02.27/lib/libdm-report.c
265 --- device-mapper.1.02.27.orig/lib/libdm-report.c 2008-06-24 17:10:36.000000000 -0700
266 +++ device-mapper.1.02.27/lib/libdm-report.c 2008-06-28 01:56:39.778466634 -0700
267 @@ -13,6 +13,7 @@
268 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
269 */
270
271 +#include <ctype.h>
272 #include "libdevmapper.h"
273 #include "list.h"
274 #include "log.h"
275 @@ -808,6 +809,8 @@
276 uint32_t align;
277 const char *repstr;
278 char buf[4096];
279 + const char *fname;
280 + char tmp_char;
281
282 if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
283 if (!(field_id = strdup(rh->fields[field->props->field_num].id))) {
284 @@ -838,6 +841,25 @@
285 return 0;
286 }
287 }
288 + if (rh->flags & DM_REPORT_OUTPUT_EXPORT) {
289 + fname = rh->fields[field->props->field_num].id;
290 + if (!dm_pool_grow_object(rh->mem, "DM_", strlen("DM_"))) {
291 + log_error("dm_report: Unable to extend output line");
292 + return 0;
293 + }
294 + while (fname && fname[0]) {
295 + tmp_char = toupper(fname[0]);
296 + if (!dm_pool_grow_object(rh->mem, &tmp_char, 1)) {
297 + log_error("dm_report: Unable to extend output line");
298 + return 0;
299 + }
300 + fname++;
301 + }
302 + if (!dm_pool_grow_object(rh->mem, "=", strlen("="))) {
303 + log_error("dm_report: Unable to extend output line");
304 + return 0;
305 + }
306 + }
307
308 repstr = field->report_string;
309 width = field->props->width;
310
311
312
313 --
314 gentoo-commits@l.g.o mailing list