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.24-export-format.diff
Date: Thu, 07 Feb 2008 01:54:10
Message-Id: E1JMvxn-0002UQ-7L@stork.gentoo.org
1 robbat2 08/02/07 01:54:07
2
3 Added: device-mapper-1.02.24-export-format.diff
4 Log:
5 Version bump, related to bug #207612.
6 (Portage version: 2.1.4.1)
7
8 Revision Changes Path
9 1.1 sys-fs/device-mapper/files/device-mapper-1.02.24-export-format.diff
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-fs/device-mapper/files/device-mapper-1.02.24-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.24-export-format.diff?rev=1.1&content-type=text/plain
13
14 Index: device-mapper-1.02.24-export-format.diff
15 ===================================================================
16 diff -Nuar --exclude '*.rej' --exclude '*.orig' device-mapper.1.02.24.orig/dmsetup/dmsetup.c device-mapper.1.02.24/dmsetup/dmsetup.c
17 --- device-mapper.1.02.24.orig/dmsetup/dmsetup.c 2007-12-05 09:05:04.000000000 -0800
18 +++ device-mapper.1.02.24/dmsetup/dmsetup.c 2008-02-06 17:49:04.670645367 -0800
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 @@ -139,7 +140,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 @@ -1123,8 +1125,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 @@ -1588,6 +1595,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 @@ -1642,6 +1659,66 @@
71 return dm_report_field_string(rh, field, &s);
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 @@ -1865,11 +1942,12 @@
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 /* Column definitions */
146 -#define OFFSET_OF(strct, field) ((unsigned int) &((struct strct *)NULL)->field)
147 +#define OFFSET_OF(strct, field) ((unsigned long) &((struct strct *)NULL)->field)
148 #define STR (DM_REPORT_FIELD_TYPE_STRING)
149 #define NUM (DM_REPORT_FIELD_TYPE_NUMBER)
150 #define FIELD_O(type, strct, sorttype, head, field, width, func, id, desc) {DR_ ## type, sorttype, OFFSET_OF(strct, field), width, id, head, &_ ## func ## _disp, desc},
151 @@ -1884,6 +1962,7 @@
152 FIELD_F(TASK, NUM, "RAhead", 6, dm_read_ahead, "read_ahead", "Read ahead in sectors.")
153
154 FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "attr", "(L)ive, (I)nactive, (s)uspended, (r)ead-only, read-(w)rite.")
155 +FIELD_F(INFO, STR, "State", 1, dm_info_cleartext_status, "status", "State as cleartext.")
156 FIELD_F(INFO, STR, "DevNo", 5, dm_info_devno, "devno", "Device major and minor numbers")
157 FIELD_O(INFO, dm_info, NUM, "Maj", major, 3, int32, "major", "Block device major number.")
158 FIELD_O(INFO, dm_info, NUM, "Min", minor, 3, int32, "minor", "Block device minor number.")
159 @@ -1891,6 +1970,11 @@
160 FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "segments", "Number of segments in live table, if present.")
161 FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "events", "Number of most recent event.")
162
163 +FIELD_O(INFO, dm_info, NUM, "RO", read_only, 2, int, "read_only", "Read only.")
164 +FIELD_O(INFO, dm_info, NUM, "Ex", exists, 2, int, "exists", "Exists.")
165 +FIELD_O(INFO, dm_info, NUM, "Susp", suspended, 4, int, "suspended", "Suspended.")
166 +FIELD_O(INFO, dm_info, NUM, "tab_live", live_table, 8, int, "table_live", "Live table.")
167 +FIELD_O(INFO, dm_info, NUM, "tab_inact", inactive_table, 9, int, "table_inactive", "Inactive table.")
168 FIELD_O(DEPS, dm_deps, NUM, "#Devs", count, 5, int32, "device_count", "Number of devices used by this one.")
169 FIELD_F(TREE, STR, "DevNames", 8, dm_deps_names, "devs_used", "List of names of mapped devices used by this one.")
170 FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers of devices used by this one.")
171 @@ -1898,6 +1982,7 @@
172 FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count", "Number of mapped devices referencing this one.")
173 FIELD_F(TREE, STR, "RefNames", 8, dm_tree_parents_names, "names_using_dev", "List of names of mapped devices using this one.")
174 FIELD_F(TREE, STR, "RefDevNos", 9, dm_tree_parents_devs, "devnos_using_dev", "List of device numbers of mapped devices using this one.")
175 +FIELD_F(TABLE, STR, "Targettypes", 32, dm_info_target_types, "target_types", "Used target types.")
176 {0, 0, 0, 0, "", "", NULL, NULL},
177 /* *INDENT-ON* */
178 };
179 @@ -1908,13 +1993,15 @@
180 #undef FIELD_F
181
182 static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
183 +static const char *default_export_options = "name,major,minor,status,read_only,exists,suspended,table_live,table_inactive,open,segments,events,uuid,target_types";
184
185 static int _report_init(struct command *c)
186 {
187 - char *options = (char *) default_report_options;
188 + char *default_options = (char *) default_report_options;
189 + char *options;
190 const char *keys = "";
191 const char *separator = " ";
192 - int aligned = 1, headings = 1, buffered = 1;
193 + int aligned = 1, headings = 1, buffered = 1, export = 0;
194 uint32_t flags = 0;
195 size_t len = 0;
196 int r = 0;
197 @@ -1929,6 +2016,15 @@
198 if (_switches[UNBUFFERED_ARG])
199 buffered = 0;
200
201 + if (_switches[EXPORT_ARG]) {
202 + default_options = (char *) default_export_options;
203 + separator = "\n";
204 + aligned = 0;
205 + headings = 0;
206 + export = 1;
207 + }
208 +
209 + options = default_options;
210 if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) {
211 if (*_string_args[OPTIONS_ARG] != '+')
212 options = _string_args[OPTIONS_ARG];
213 @@ -1971,6 +2067,9 @@
214 if (headings)
215 flags |= DM_REPORT_OUTPUT_HEADINGS;
216
217 + if (export)
218 + flags |= DM_REPORT_OUTPUT_EXPORT;
219 +
220 if (!(_report = dm_report_init(&_report_type,
221 _report_types, _report_fields,
222 options, separator, flags, keys, NULL)))
223 @@ -2046,7 +2145,8 @@
224 fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n"
225 " [-r|--readonly] [--noopencount] [--nolockfs]\n"
226 " [--readahead [+]<sectors>|auto|none]\n"
227 - " [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
228 + " [-c|-C|--columns] [-e|--export]\n"
229 + " [-o <fields>] [-O|--sort <sort_fields>]\n"
230 " [--noheadings] [--separator <separator>]\n\n");
231 for (i = 0; _commands[i].name; i++)
232 fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
233 @@ -2397,6 +2497,7 @@
234 static struct option long_options[] = {
235 {"readonly", 0, &ind, READ_ONLY},
236 {"columns", 0, &ind, COLS_ARG},
237 + {"export", 0, &ind, EXPORT_ARG},
238 {"exec", 1, &ind, EXEC_ARG},
239 {"force", 0, &ind, FORCE_ARG},
240 {"gid", 1, &ind, GID_ARG},
241 @@ -2476,12 +2577,16 @@
242
243 optarg = 0;
244 optind = OPTIND_INIT;
245 - while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:O:ru:Uv",
246 + while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCefGj:m:Mno:O:ru:Uv",
247 long_options, NULL)) != -1) {
248 if (c == ':' || c == '?')
249 return 0;
250 if (c == 'c' || c == 'C' || ind == COLS_ARG)
251 _switches[COLS_ARG]++;
252 + if (c == 'e' || ind == EXPORT_ARG) {
253 + _switches[EXPORT_ARG]++;
254 + _switches[COLS_ARG]++;
255 + }
256 if (c == 'f' || ind == FORCE_ARG)
257 _switches[FORCE_ARG]++;
258 if (c == 'r' || ind == READ_ONLY)
259 diff -Nuar --exclude '*.rej' --exclude '*.orig' device-mapper.1.02.24.orig/lib/libdevmapper.h device-mapper.1.02.24/lib/libdevmapper.h
260 --- device-mapper.1.02.24.orig/lib/libdevmapper.h 2007-12-05 08:28:19.000000000 -0800
261 +++ device-mapper.1.02.24/lib/libdevmapper.h 2008-02-06 17:48:06.670426177 -0800
262 @@ -738,6 +738,7 @@
263 #define DM_REPORT_OUTPUT_ALIGNED 0x00000001
264 #define DM_REPORT_OUTPUT_BUFFERED 0x00000002
265 #define DM_REPORT_OUTPUT_HEADINGS 0x00000004
266 +#define DM_REPORT_OUTPUT_EXPORT 0x00000008
267
268 struct dm_report *dm_report_init(uint32_t *report_types,
269 const struct dm_report_object_type *types,
270 diff -Nuar --exclude '*.rej' --exclude '*.orig' device-mapper.1.02.24.orig/lib/libdm-report.c device-mapper.1.02.24/lib/libdm-report.c
271 --- device-mapper.1.02.24.orig/lib/libdm-report.c 2007-08-21 09:26:06.000000000 -0700
272 +++ device-mapper.1.02.24/lib/libdm-report.c 2008-02-06 17:48:06.670426177 -0800
273 @@ -13,6 +13,7 @@
274 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
275 */
276
277 +#include <ctype.h>
278 #include "libdevmapper.h"
279 #include "list.h"
280 #include "log.h"
281 @@ -776,6 +777,8 @@
282 char buf[4096];
283 int32_t width;
284 uint32_t align;
285 + const char *fname;
286 + char tmp_char;
287
288 if (list_empty(&rh->rows))
289 return 1;
290 @@ -800,6 +803,25 @@
291 if (field->props->flags & FLD_HIDDEN)
292 continue;
293
294 + if (rh->flags & DM_REPORT_OUTPUT_EXPORT) {
295 + fname = rh->fields[field->props->field_num].id;
296 + if (!dm_pool_grow_object(rh->mem, "DM_", strlen("DM_"))) {
297 + log_error("dm_report: Unable to extend output line");
298 + goto bad;
299 + }
300 + while (fname && fname[0]) {
301 + tmp_char = toupper(fname[0]);
302 + if (!dm_pool_grow_object(rh->mem, &tmp_char, 1)) {
303 + log_error("dm_report: Unable to extend output line");
304 + goto bad;
305 + }
306 + fname++;
307 + }
308 + if (!dm_pool_grow_object(rh->mem, "=", strlen("="))) {
309 + log_error("dm_report: Unable to extend output line");
310 + goto bad;
311 + }
312 + }
313 repstr = field->report_string;
314 width = field->props->width;
315 if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
316
317
318
319 --
320 gentoo-commits@l.g.o mailing list