* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2007-02-14 15:12 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2007-02-14 15:12 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-02-14 15:12:16
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdm-report.c
Log message:
Fix a few leaks in reporting error paths.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.171&r2=1.172
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.11&r2=1.12
--- device-mapper/WHATS_NEW 2007/02/13 16:16:15 1.171
+++ device-mapper/WHATS_NEW 2007/02/14 15:12:14 1.172
@@ -1,5 +1,6 @@
Version 1.02.19 -
====================================
+ Fix a few leaks in reporting error paths. [1.02.15+]
Version 1.02.18 - 13th February 2007
====================================
--- device-mapper/dmsetup/dmsetup.c 2007/01/29 19:35:24 1.86
+++ device-mapper/dmsetup/dmsetup.c 2007/02/14 15:12:16 1.87
@@ -2019,6 +2019,7 @@
if (*argc != 2) {
fprintf(stderr, "%s: Too few arguments\n", base);
_losetup_usage(stderr);
+ dm_free(device_name);
return 0;
}
@@ -2027,6 +2028,7 @@
fprintf(stderr, "%s: Could not parse loop file name %s\n",
base, (*argv)[1]);
_losetup_usage(stderr);
+ dm_free(device_name);
return 0;
}
@@ -2034,6 +2036,7 @@
_table = dm_malloc(LOOP_TABLE_SIZE);
if (!_loop_table(_table, LOOP_TABLE_SIZE, loop_file, device_name, offset)) {
fprintf(stderr, "Could not build device-mapper table for %s\n", (*argv)[0]);
+ dm_free(device_name);
return 0;
}
_switches[TABLE_ARG]++;
--- device-mapper/lib/libdm-report.c 2007/01/29 17:23:54 1.11
+++ device-mapper/lib/libdm-report.c 2007/02/14 15:12:16 1.12
@@ -504,15 +504,20 @@
if (!(rh->mem = dm_pool_create("report", 10 * 1024))) {
log_error("dm_report_init: allocation of memory pool failed");
+ dm_free(rh);
return NULL;
}
/* Generate list of fields for output based on format string & flags */
- if (!_parse_options(rh, output_fields))
+ if (!_parse_options(rh, output_fields)) {
+ dm_report_free(rh);
return NULL;
+ }
- if (!_parse_keys(rh, sort_keys))
+ if (!_parse_keys(rh, sort_keys)) {
+ dm_report_free(rh);
return NULL;
+ }
/* Return updated types value for further compatility check by caller */
if (report_types)
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2008-06-24 22:53 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2008-06-24 22:53 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2008-06-24 22:53:48
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdevmapper.h libdm-report.c
Log message:
Add --rows to dmsetup.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.243&r2=1.244
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.82&r2=1.83
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.20&r2=1.21
--- device-mapper/WHATS_NEW 2008/06/24 20:16:47 1.243
+++ device-mapper/WHATS_NEW 2008/06/24 22:53:47 1.244
@@ -1,6 +1,6 @@
Version 1.02.27 -
===============================
- Add --unquoted to dmsetup.
+ Add --unquoted and --rows to dmsetup.
Avoid compiler warning about cast in dmsetup.c's OFFSET_OF macro.
Fix inverted no_flush debug message.
Remove --enable-jobs from configure. (Set at runtime instead.)
--- device-mapper/dmsetup/dmsetup.c 2008/06/24 20:16:47 1.110
+++ device-mapper/dmsetup/dmsetup.c 2008/06/24 22:53:47 1.111
@@ -122,6 +122,7 @@
NOTABLE_ARG,
OPTIONS_ARG,
READAHEAD_ARG,
+ ROWS_ARG,
SEPARATOR_ARG,
SHOWKEYS_ARG,
SORT_ARG,
@@ -1976,7 +1977,8 @@
char *options = (char *) default_report_options;
const char *keys = "";
const char *separator = " ";
- int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0, quoted = 1;
+ int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
+ int quoted = 1, columns_as_rows = 0;
uint32_t flags = 0;
size_t len = 0;
int r = 0;
@@ -1991,6 +1993,9 @@
if (_switches[UNBUFFERED_ARG])
buffered = 0;
+ if (_switches[ROWS_ARG])
+ columns_as_rows = 1;
+
if (_switches[UNQUOTED_ARG])
quoted = 0;
@@ -2047,6 +2052,9 @@
if (!quoted)
flags |= DM_REPORT_OUTPUT_FIELD_UNQUOTED;
+ if (columns_as_rows)
+ flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS;
+
if (!(_report = dm_report_init(&_report_type,
_report_types, _report_fields,
options, separator, flags, keys, NULL)))
@@ -2490,6 +2498,7 @@
{"notable", 0, &ind, NOTABLE_ARG},
{"options", 1, &ind, OPTIONS_ARG},
{"readahead", 1, &ind, READAHEAD_ARG},
+ {"rows", 0, &ind, ROWS_ARG},
{"separator", 1, &ind, SEPARATOR_ARG},
{"showkeys", 0, &ind, SHOWKEYS_ARG},
{"sort", 1, &ind, SORT_ARG},
@@ -2646,6 +2655,8 @@
}
}
}
+ if ((ind == ROWS_ARG))
+ _switches[ROWS_ARG]++;
if ((ind == SHOWKEYS_ARG))
_switches[SHOWKEYS_ARG]++;
if ((ind == TABLE_ARG)) {
--- device-mapper/lib/libdevmapper.h 2008/06/24 20:16:47 1.82
+++ device-mapper/lib/libdevmapper.h 2008/06/24 22:53:48 1.83
@@ -741,6 +741,7 @@
#define DM_REPORT_OUTPUT_HEADINGS 0x00000004
#define DM_REPORT_OUTPUT_FIELD_NAME_PREFIX 0x00000008
#define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010
+#define DM_REPORT_OUTPUT_COLUMNS_AS_ROWS 0x00000020
struct dm_report *dm_report_init(uint32_t *report_types,
const struct dm_report_object_type *types,
--- device-mapper/lib/libdm-report.c 2008/06/24 20:16:47 1.20
+++ device-mapper/lib/libdm-report.c 2008/06/24 22:53:48 1.21
@@ -513,6 +513,14 @@
rh->flags |= output_flags & DM_REPORT_OUTPUT_MASK;
+ /* With columns_as_rows we must buffer and not align. */
+ if (output_flags & DM_REPORT_OUTPUT_COLUMNS_AS_ROWS) {
+ if (!(output_flags & DM_REPORT_OUTPUT_BUFFERED))
+ rh->flags |= DM_REPORT_OUTPUT_BUFFERED;
+ if (output_flags & DM_REPORT_OUTPUT_ALIGNED)
+ rh->flags &= ~DM_REPORT_OUTPUT_ALIGNED;
+ }
+
if (output_flags & DM_REPORT_OUTPUT_BUFFERED)
rh->flags |= RH_SORT_REQUIRED;
@@ -793,23 +801,146 @@
/*
* Produce report output
*/
-int dm_report_output(struct dm_report *rh)
+static int _output_field(struct dm_report *rh, struct dm_report_field *field)
{
- struct list *fh, *rowh, *ftmp, *rtmp;
- struct row *row = NULL;
- struct dm_report_field *field;
- const char *repstr;
char *field_id;
- char buf[4096];
int32_t width;
uint32_t align;
+ const char *repstr;
+ char buf[4096];
- if (list_empty(&rh->rows))
- return 1;
+ if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
+ if (!(field_id = strdup(rh->fields[field->props->field_num].id))) {
+ log_error("dm_report: Failed to copy field name");
+ return 0;
+ }
- /* Sort rows */
- if ((rh->flags & RH_SORT_REQUIRED))
- _sort_rows(rh);
+ if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+
+ if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+
+ free(field_id);
+
+ if (!dm_pool_grow_object(rh->mem, "=", 1)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+
+ if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
+ !dm_pool_grow_object(rh->mem, "\'", 1)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+ }
+
+ repstr = field->report_string;
+ width = field->props->width;
+ if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
+ if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+ } else {
+ if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
+ align = (field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ?
+ DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
+ if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
+ if (dm_snprintf(buf, sizeof(buf), "%-*.*s",
+ width, width, repstr) < 0) {
+ log_error("dm_report: left-aligned snprintf() failed");
+ return 0;
+ }
+ if (!dm_pool_grow_object(rh->mem, buf, width)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+ } else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
+ if (dm_snprintf(buf, sizeof(buf), "%*.*s",
+ width, width, repstr) < 0) {
+ log_error("dm_report: right-aligned snprintf() failed");
+ return 0;
+ }
+ if (!dm_pool_grow_object(rh->mem, buf, width)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+ }
+ }
+
+ if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
+ !(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
+ if (!dm_pool_grow_object(rh->mem, "\'", 1)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+
+ return 1;
+}
+
+static int _output_as_rows(struct dm_report *rh)
+{
+ struct field_properties *fp;
+ struct dm_report_field *field;
+ struct row *row;
+
+ if (!dm_pool_begin_object(rh->mem, 512)) {
+ log_error("dm_report: Unable to allocate output line");
+ return 0;
+ }
+
+ list_iterate_items(fp, &rh->field_props) {
+ if (fp->flags & FLD_HIDDEN)
+ continue;
+
+ if ((rh->flags & DM_REPORT_OUTPUT_HEADINGS)) {
+ if (!dm_pool_grow_object(rh->mem, rh->fields[fp->field_num].heading, 0)) {
+ log_error("dm_report: Failed to extend row for field name");
+ goto bad;
+ }
+ if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
+ log_error("dm_report: Failed to extend row with separator");
+ goto bad;
+ }
+ }
+
+ list_iterate_items(row, &rh->rows) {
+ field = list_item(list_first(&row->fields), struct dm_report_field);
+ if (!_output_field(rh, field))
+ goto bad;
+ list_del(&field->list);
+
+ if (!list_end(&rh->rows, &row->list))
+ if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
+ log_error("dm_report: Unable to extend output line");
+ goto bad;
+ }
+ }
+
+ if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
+ log_error("dm_report: Failed to terminate row");
+ goto bad;
+ }
+ log_print("%s", (char *) dm_pool_end_object(rh->mem));
+ }
+
+ return 1;
+
+ bad:
+ dm_pool_abandon_object(rh->mem);
+ return 0;
+}
+
+static int _output_as_columns(struct dm_report *rh)
+{
+ struct list *fh, *rowh, *ftmp, *rtmp;
+ struct row *row = NULL;
+ struct dm_report_field *field;
/* If headings not printed yet, calculate field widths and print them */
if (!(rh->flags & RH_HEADINGS_PRINTED))
@@ -827,82 +958,15 @@
if (field->props->flags & FLD_HIDDEN)
continue;
- if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
- if (!(field_id = strdup(rh->fields[field->props->field_num].id))) {
- log_error("dm_report: Failed to copy field name");
- goto bad;
- }
-
- if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
-
- if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
-
- free(field_id);
-
- if (!dm_pool_grow_object(rh->mem, "=", 1)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
-
- if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
- !dm_pool_grow_object(rh->mem, "\'", 1)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
- }
-
- repstr = field->report_string;
- width = field->props->width;
- if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
- if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
- } else {
- if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
- align = (field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ?
- DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
- if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
- if (dm_snprintf(buf, sizeof(buf), "%-*.*s",
- width, width, repstr) < 0) {
- log_error("dm_report: left-aligned snprintf() failed");
- goto bad;
- }
- if (!dm_pool_grow_object(rh->mem, buf, width)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
- } else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
- if (dm_snprintf(buf, sizeof(buf), "%*.*s",
- width, width, repstr) < 0) {
- log_error("dm_report: right-aligned snprintf() failed");
- goto bad;
- }
- if (!dm_pool_grow_object(rh->mem, buf, width)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
- }
- }
+ if (!_output_field(rh, field))
+ goto bad;
- if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
- !(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
- if (!dm_pool_grow_object(rh->mem, "\'", 1)) {
- log_error("dm_report: Unable to extend output line");
- goto bad;
- }
-
if (!list_end(&row->fields, fh))
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
log_error("dm_report: Unable to extend output line");
goto bad;
}
+
list_del(&field->list);
}
if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
@@ -922,3 +986,17 @@
dm_pool_abandon_object(rh->mem);
return 0;
}
+
+int dm_report_output(struct dm_report *rh)
+{
+ if (list_empty(&rh->rows))
+ return 1;
+
+ if ((rh->flags & RH_SORT_REQUIRED))
+ _sort_rows(rh);
+
+ if ((rh->flags & DM_REPORT_OUTPUT_COLUMNS_AS_ROWS))
+ return _output_as_rows(rh);
+ else
+ return _output_as_columns(rh);
+}
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2008-06-24 20:16 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2008-06-24 20:16 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2008-06-24 20:16:47
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdevmapper.h libdm-report.c
Log message:
dmsetup --unquoted
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.242&r2=1.243
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.109&r2=1.110
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.19&r2=1.20
--- device-mapper/WHATS_NEW 2008/06/18 10:19:25 1.242
+++ device-mapper/WHATS_NEW 2008/06/24 20:16:47 1.243
@@ -1,5 +1,6 @@
Version 1.02.27 -
===============================
+ Add --unquoted to dmsetup.
Avoid compiler warning about cast in dmsetup.c's OFFSET_OF macro.
Fix inverted no_flush debug message.
Remove --enable-jobs from configure. (Set at runtime instead.)
--- device-mapper/dmsetup/dmsetup.c 2008/06/18 10:19:25 1.109
+++ device-mapper/dmsetup/dmsetup.c 2008/06/24 20:16:47 1.110
@@ -130,6 +130,7 @@
TREE_ARG,
UID_ARG,
UNBUFFERED_ARG,
+ UNQUOTED_ARG,
UUID_ARG,
VERBOSE_ARG,
VERSION_ARG,
@@ -1975,7 +1976,7 @@
char *options = (char *) default_report_options;
const char *keys = "";
const char *separator = " ";
- int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
+ int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0, quoted = 1;
uint32_t flags = 0;
size_t len = 0;
int r = 0;
@@ -1990,6 +1991,9 @@
if (_switches[UNBUFFERED_ARG])
buffered = 0;
+ if (_switches[UNQUOTED_ARG])
+ quoted = 0;
+
if (_switches[NAMEPREFIXES_ARG]) {
aligned = 0;
field_prefixes = 1;
@@ -2040,6 +2044,9 @@
if (field_prefixes)
flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
+ if (!quoted)
+ flags |= DM_REPORT_OUTPUT_FIELD_UNQUOTED;
+
if (!(_report = dm_report_init(&_report_type,
_report_types, _report_fields,
options, separator, flags, keys, NULL)))
@@ -2492,6 +2499,7 @@
{"uid", 1, &ind, UID_ARG},
{"uuid", 1, &ind, UUID_ARG},
{"unbuffered", 0, &ind, UNBUFFERED_ARG},
+ {"unquoted", 0, &ind, UNQUOTED_ARG},
{"verbose", 1, &ind, VERBOSE_ARG},
{"version", 0, &ind, VERSION_ARG},
{0, 0, 0, 0}
@@ -2646,8 +2654,8 @@
}
if ((ind == TREE_ARG))
_switches[TREE_ARG]++;
- if ((ind == UNBUFFERED_ARG))
- _switches[UNBUFFERED_ARG]++;
+ if ((ind == UNQUOTED_ARG))
+ _switches[UNQUOTED_ARG]++;
if ((ind == VERSION_ARG))
_switches[VERSION_ARG]++;
}
--- device-mapper/lib/libdevmapper.h 2008/04/20 00:11:08 1.81
+++ device-mapper/lib/libdevmapper.h 2008/06/24 20:16:47 1.82
@@ -740,6 +740,7 @@
#define DM_REPORT_OUTPUT_BUFFERED 0x00000002
#define DM_REPORT_OUTPUT_HEADINGS 0x00000004
#define DM_REPORT_OUTPUT_FIELD_NAME_PREFIX 0x00000008
+#define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010
struct dm_report *dm_report_init(uint32_t *report_types,
const struct dm_report_object_type *types,
--- device-mapper/lib/libdm-report.c 2008/06/06 19:07:47 1.19
+++ device-mapper/lib/libdm-report.c 2008/06/24 20:16:47 1.20
@@ -845,7 +845,13 @@
free(field_id);
- if (!dm_pool_grow_object(rh->mem, "=\'", 2)) {
+ if (!dm_pool_grow_object(rh->mem, "=", 1)) {
+ log_error("dm_report: Unable to extend output line");
+ goto bad;
+ }
+
+ if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
+ !dm_pool_grow_object(rh->mem, "\'", 1)) {
log_error("dm_report: Unable to extend output line");
goto bad;
}
@@ -885,7 +891,8 @@
}
}
- if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX)
+ if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
+ !(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
if (!dm_pool_grow_object(rh->mem, "\'", 1)) {
log_error("dm_report: Unable to extend output line");
goto bad;
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2008-04-19 15:50 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2008-04-19 15:50 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2008-04-19 15:50:18
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdevmapper.h libdm-report.c
lib/mm : pool-debug.c pool-fast.c
Log message:
Calculate string size within dm_pool_grow_object.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.227&r2=1.228
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.79&r2=1.80
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/mm/pool-debug.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/mm/pool-fast.c.diff?cvsroot=dm&r1=1.4&r2=1.5
--- device-mapper/WHATS_NEW 2008/04/10 18:04:31 1.227
+++ device-mapper/WHATS_NEW 2008/04/19 15:50:17 1.228
@@ -1,5 +1,6 @@
Version 1.02.26 -
=================================
+ Calculate string size within dm_pool_grow_object.
Version 1.02.25 - 10th April 2008
=================================
--- device-mapper/dmsetup/dmsetup.c 2007/12/05 17:05:04 1.103
+++ device-mapper/dmsetup/dmsetup.c 2008/04/19 15:50:17 1.104
@@ -1697,7 +1697,7 @@
log_error("dm_pool_grow_object failed");
goto out_abandon;
}
- if (!dm_pool_grow_object(mem, name, strlen(name))) {
+ if (!dm_pool_grow_object(mem, name, 0)) {
log_error("dm_pool_grow_object failed");
goto out_abandon;
}
@@ -1763,7 +1763,7 @@
log_error("dm_snprintf failed");
goto out_abandon;
}
- if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
+ if (!dm_pool_grow_object(mem, buf, 0)) {
log_error("dm_pool_grow_object failed");
goto out_abandon;
}
@@ -1816,7 +1816,7 @@
log_error("dm_snprintf failed");
goto out_abandon;
}
- if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
+ if (!dm_pool_grow_object(mem, buf, 0)) {
log_error("dm_pool_grow_object failed");
goto out_abandon;
}
--- device-mapper/lib/libdevmapper.h 2007/12/05 16:28:19 1.79
+++ device-mapper/lib/libdevmapper.h 2008/04/19 15:50:18 1.80
@@ -500,7 +500,7 @@
*
* for (i = 0; i < 50; i++) {
* snprintf(buffer, sizeof(buffer), "%d, ", i);
- * if (!dm_pool_grow_object(mem, buffer, strlen(buffer)))
+ * if (!dm_pool_grow_object(mem, buffer, 0))
* goto bad;
* }
*
@@ -524,6 +524,7 @@
* dm_pool_grow_object. Finally get your object with
* a call to dm_pool_end_object.
*
+ * Setting delta to 0 means it will use strlen(extra).
*/
int dm_pool_begin_object(struct dm_pool *p, size_t hint);
int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta);
--- device-mapper/lib/libdm-report.c 2008/01/20 01:14:38 1.16
+++ device-mapper/lib/libdm-report.c 2008/04/19 15:50:18 1.17
@@ -668,15 +668,13 @@
log_error("dm_report: Failed to generate report headings for printing");
goto bad;
}
- } else if (!dm_pool_grow_object(rh->mem, heading,
- strlen(heading))) {
+ } else if (!dm_pool_grow_object(rh->mem, heading, 0)) {
log_error("dm_report: Failed to generate report headings for printing");
goto bad;
}
if (!list_end(&rh->field_props, &fp->list))
- if (!dm_pool_grow_object(rh->mem, rh->separator,
- strlen(rh->separator))) {
+ if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
log_error("dm_report: Failed to generate report headings for printing");
goto bad;
}
@@ -803,8 +801,7 @@
repstr = field->report_string;
width = field->props->width;
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
- if (!dm_pool_grow_object(rh->mem, repstr,
- strlen(repstr))) {
+ if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
log_error("dm_report: Unable to extend output line");
goto bad;
}
@@ -836,8 +833,7 @@
}
if (!list_end(&row->fields, fh))
- if (!dm_pool_grow_object(rh->mem, rh->separator,
- strlen(rh->separator))) {
+ if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
log_error("dm_report: Unable to extend output line");
goto bad;
}
--- device-mapper/lib/mm/pool-debug.c 2007/08/21 16:26:07 1.3
+++ device-mapper/lib/mm/pool-debug.c 2008/04/19 15:50:18 1.4
@@ -216,10 +216,10 @@
return 1;
}
-int dm_pool_grow_object(struct dm_pool *p, const void *buffer, size_t delta)
+int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta)
{
struct block *new;
- size_t size = delta;
+ size_t size = delta ? : strlen(extra);
assert(p->begun);
@@ -238,7 +238,7 @@
}
p->object = new;
- memcpy(new->data + size - delta, buffer, delta);
+ memcpy(new->data + size - delta, extra, delta);
return 1;
}
--- device-mapper/lib/mm/pool-fast.c 2007/08/21 16:26:07 1.4
+++ device-mapper/lib/mm/pool-fast.c 2008/04/19 15:50:18 1.5
@@ -162,14 +162,17 @@
return 1;
}
-int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t n)
+int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta)
{
struct chunk *c = p->chunk, *nc;
- if (c->end - (c->begin + p->object_len) < n) {
+ if (!delta)
+ delta = strlen(extra);
+
+ if (c->end - (c->begin + p->object_len) < delta) {
/* move into a new chunk */
- if (p->object_len + n > (p->chunk_size / 2))
- nc = _new_chunk(p, (p->object_len + n) * 2);
+ if (p->object_len + delta > (p->chunk_size / 2))
+ nc = _new_chunk(p, (p->object_len + delta) * 2);
else
nc = _new_chunk(p, p->chunk_size);
@@ -181,8 +184,8 @@
c = p->chunk;
}
- memcpy(c->begin + p->object_len, extra, n);
- p->object_len += n;
+ memcpy(c->begin + p->object_len, extra, delta);
+ p->object_len += delta;
return 1;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2007-11-27 20:57 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2007-11-27 20:57 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-11-27 20:57:05
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : .exported_symbols libdevmapper.h libdm-common.c
libdm-deptree.c
lib/ioctl : libdm-iface.c libdm-targets.h
man : dmsetup.8
Log message:
add read_ahead functions to library and dmsetup --readahead
(Not live yet.)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.210&r2=1.211
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.96&r2=1.97
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/.exported_symbols.diff?cvsroot=dm&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-common.c.diff?cvsroot=dm&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-deptree.c.diff?cvsroot=dm&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/ioctl/libdm-iface.c.diff?cvsroot=dm&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/ioctl/libdm-targets.h.diff?cvsroot=dm&r1=1.21&r2=1.22
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/man/dmsetup.8.diff?cvsroot=dm&r1=1.18&r2=1.19
--- device-mapper/WHATS_NEW 2007/11/27 12:26:06 1.210
+++ device-mapper/WHATS_NEW 2007/11/27 20:57:04 1.211
@@ -1,7 +1,8 @@
Version 1.02.23 -
==================================
- Fix possible double-free in libdevmapper-event.
- Define DM_READ_AHEAD_* values and flags.
+ Add --readahead to dmsetup.
+ Add external read_ahead library functions and DM_READ_AHEAD_* definitions.
+ Fix double free in a libdevmapper-event error path.
Fix configure --with-dmeventd-path substitution.
Allow $DM_DEV_DIR envvar to override default of "/dev".
Create e.g., libdevmapper.so.1.02, in build dir alongside the .so file.
--- device-mapper/dmsetup/dmsetup.c 2007/10/09 12:14:48 1.96
+++ device-mapper/dmsetup/dmsetup.c 2007/11/27 20:57:05 1.97
@@ -120,6 +120,7 @@
NOOPENCOUNT_ARG,
NOTABLE_ARG,
OPTIONS_ARG,
+ READAHEAD_ARG,
SEPARATOR_ARG,
SHOWKEYS_ARG,
SORT_ARG,
@@ -336,6 +337,8 @@
info->suspended ? "SUSPENDED" : "ACTIVE",
info->read_only ? " (READ-ONLY)" : "");
+ printf("Read Ahead: %d\n", (int) dm_task_get_read_ahead(dmt));
+
if (!info->live_table && !info->inactive_table)
printf("Tables present: None\n");
else
@@ -494,6 +497,11 @@
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
goto out;
+ /* FIXME Provide way to set read_ahead_flags */
+ if (_switches[READAHEAD_ARG] &&
+ !dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG], 0))
+ goto out;
+
if (!dm_task_run(dmt))
goto out;
@@ -673,6 +681,11 @@
if (_switches[NOLOCKFS_ARG] && !dm_task_skip_lockfs(dmt))
goto out;
+ /* FIXME Provide way to set read_ahead_flags */
+ if (_switches[READAHEAD_ARG] &&
+ !dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG], 0))
+ goto out;
+
r = dm_task_run(dmt);
if (r && display && _switches[VERBOSE_ARG])
@@ -1594,6 +1607,16 @@
return dm_report_field_string(rh, field, &uuid);
}
+static int _dm_read_ahead_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private __attribute((unused)))
+{
+ int32_t value = (int32_t) dm_task_get_read_ahead((const struct dm_task *) data);
+
+ return dm_report_field_int32(rh, field, &value);
+}
+
static int _dm_info_status_disp(struct dm_report *rh,
struct dm_pool *mem __attribute((unused)),
struct dm_report_field *field, const void *data,
@@ -1849,6 +1872,10 @@
/* *INDENT-OFF* */
FIELD_F(TASK, STR, "Name", 16, dm_name, "name", "Name of mapped device.")
FIELD_F(TASK, STR, "UUID", 32, dm_uuid, "uuid", "Unique (optional) identifier for mapped device.")
+
+/* FIXME Next one should be INFO */
+FIELD_F(TASK, NUM, "RAhead", 6, dm_read_ahead, "readahead", "Read ahead in sectors.")
+
FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "attr", "(L)ive, (I)nactive, (s)uspended, (r)ead-only, read-(w)rite.")
FIELD_F(INFO, STR, "DevNo", 5, dm_info_devno, "devno", "Device major and minor numbers")
FIELD_O(INFO, dm_info, NUM, "Maj", major, 3, int32, "major", "Block device major number.")
@@ -2010,7 +2037,8 @@
fprintf(out, "Usage:\n\n");
fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n"
- " [-r|--readonly] [--noopencount] [--nolockfs]\n"
+ " [-r|--readonly] [--noopencount] [--nolockfs] "
+ "[--readahead <sectors>]\n"
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
" [--noheadings] [--separator <separator>]\n\n");
for (i = 0; _commands[i].name; i++)
@@ -2374,6 +2402,7 @@
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
{"notable", 0, &ind, NOTABLE_ARG},
{"options", 1, &ind, OPTIONS_ARG},
+ {"readahead", 1, &ind, READAHEAD_ARG},
{"separator", 1, &ind, SEPARATOR_ARG},
{"showkeys", 0, &ind, SHOWKEYS_ARG},
{"sort", 1, &ind, SORT_ARG},
@@ -2506,6 +2535,11 @@
_switches[NOLOCKFS_ARG]++;
if ((ind == NOOPENCOUNT_ARG))
_switches[NOOPENCOUNT_ARG]++;
+ /* FIXME Accept auto/none & set read_ahead_flags too */
+ if ((ind == READAHEAD_ARG)) {
+ _switches[READAHEAD_ARG]++;
+ _int_args[READAHEAD_ARG] = atoi(optarg);
+ }
if ((ind == SHOWKEYS_ARG))
_switches[SHOWKEYS_ARG]++;
if ((ind == TABLE_ARG)) {
--- device-mapper/lib/.exported_symbols 2007/07/28 10:48:36 1.31
+++ device-mapper/lib/.exported_symbols 2007/11/27 20:57:05 1.32
@@ -18,6 +18,7 @@
dm_task_get_names
dm_task_get_versions
dm_task_get_uuid
+dm_task_get_read_ahead
dm_task_set_ro
dm_task_set_newname
dm_task_set_event_nr
@@ -28,6 +29,7 @@
dm_task_set_uid
dm_task_set_gid
dm_task_set_mode
+dm_task_set_read_ahead
dm_task_suppress_identical_reload
dm_task_add_target
dm_task_no_flush
@@ -67,6 +69,7 @@
dm_tree_node_add_mirror_target
dm_tree_node_add_mirror_target_log
dm_tree_node_add_target_area
+dm_tree_node_set_read_ahead
dm_tree_skip_lockfs
dm_tree_use_no_flush_suspend
dm_is_dm_major
--- device-mapper/lib/libdevmapper.h 2007/11/12 20:47:18 1.76
+++ device-mapper/lib/libdevmapper.h 2007/11/27 20:57:05 1.77
@@ -141,11 +141,6 @@
struct dm_names *dm_task_get_names(struct dm_task *dmt);
struct dm_versions *dm_task_get_versions(struct dm_task *dmt);
-#define DM_READ_AHEAD_AUTO UINT32_MAX /* Use kernel default readahead */
-#define DM_READ_AHEAD_NONE 0 /* Disable readahead */
-
-#define DM_READ_AHEAD_MINIMUM_FLAG 0x1 /* Value supplied is minimum */
-
int dm_task_set_ro(struct dm_task *dmt);
int dm_task_set_newname(struct dm_task *dmt, const char *newname);
int dm_task_set_minor(struct dm_task *dmt, int minor);
@@ -163,6 +158,18 @@
int dm_task_suppress_identical_reload(struct dm_task *dmt);
/*
+ * Control read_ahead.
+ */
+#define DM_READ_AHEAD_AUTO UINT32_MAX /* Use kernel default readahead */
+#define DM_READ_AHEAD_NONE 0 /* Disable readahead */
+
+#define DM_READ_AHEAD_MINIMUM_FLAG 0x1 /* Value supplied is minimum */
+
+int dm_task_set_read_ahead(struct dm_task *dmt, uint32_t read_ahead,
+ uint32_t read_ahead_flags);
+uint32_t dm_task_get_read_ahead(const struct dm_task *dmt);
+
+/*
* Use these to prepare for a create or reload.
*/
int dm_task_add_target(struct dm_task *dmt,
@@ -381,6 +388,13 @@
const char *dlid,
uint64_t offset);
+/*
+ * Set readahead (in sectors) after loading the node.
+ */
+void dm_tree_node_set_read_ahead(struct dm_tree_node *dnode,
+ uint32_t read_ahead,
+ uint32_t read_ahead_flags);
+
/*****************************************************************************
* Library functions
*****************************************************************************/
--- device-mapper/lib/libdm-common.c 2007/10/09 12:14:48 1.47
+++ device-mapper/lib/libdm-common.c 2007/11/27 20:57:05 1.48
@@ -118,6 +118,8 @@
dmt->gid = DEVICE_GID;
dmt->mode = DEVICE_MODE;
dmt->no_open_count = 0;
+ dmt->read_ahead = DM_READ_AHEAD_AUTO;
+ dmt->read_ahead_flags = 0;
return dmt;
}
--- device-mapper/lib/libdm-deptree.c 2007/08/21 16:26:06 1.32
+++ device-mapper/lib/libdm-deptree.c 2007/11/27 20:57:05 1.33
@@ -95,6 +95,9 @@
uint32_t major;
uint32_t minor;
+ uint32_t read_ahead;
+ uint32_t read_ahead_flags;
+
unsigned segment_count;
struct list segs;
@@ -609,6 +612,8 @@
}
dnode->props.read_only = read_only ? 1 : 0;
+ dnode->props.read_ahead = DM_READ_AHEAD_AUTO;
+ dnode->props.read_ahead_flags = 0;
if (clear_inactive && !_node_clear_table(dnode))
return_NULL;
@@ -618,6 +623,14 @@
return dnode;
}
+void dm_tree_node_set_read_ahead(struct dm_tree_node *dnode,
+ uint32_t read_ahead,
+ uint32_t read_ahead_flags)
+{
+ dnode->props.read_ahead = read_ahead;
+ dnode->props.read_ahead_flags = read_ahead_flags;
+}
+
int dm_tree_add_dev(struct dm_tree *dtree, uint32_t major, uint32_t minor)
{
return _add_dev(dtree, &dtree->root, major, minor) ? 1 : 0;
@@ -875,6 +888,7 @@
/* FIXME Merge with _suspend_node? */
static int _resume_node(const char *name, uint32_t major, uint32_t minor,
+ uint32_t read_ahead, uint32_t read_ahead_flags,
struct dm_info *newinfo)
{
struct dm_task *dmt;
@@ -896,6 +910,9 @@
if (!dm_task_no_open_count(dmt))
log_error("Failed to disable open_count");
+ if (!dm_task_set_read_ahead(dmt, read_ahead, read_ahead_flags))
+ log_error("Failed to set read ahead");
+
if ((r = dm_task_run(dmt)))
r = dm_task_get_info(dmt, newinfo);
@@ -1136,7 +1153,9 @@
if (!child->info.inactive_table && !child->info.suspended)
continue;
- if (!_resume_node(name, child->info.major, child->info.minor, &newinfo)) {
+ if (!_resume_node(name, child->info.major, child->info.minor,
+ child->props.read_ahead,
+ child->props.read_ahead_flags, &newinfo)) {
log_error("Unable to resume %s (%" PRIu32
":%" PRIu32 ")", name, child->info.major,
child->info.minor);
@@ -1527,7 +1546,9 @@
if (!child->info.inactive_table && !child->info.suspended)
continue;
- if (!_resume_node(name, child->info.major, child->info.minor, &newinfo)) {
+ if (!_resume_node(name, child->info.major, child->info.minor,
+ child->props.read_ahead,
+ child->props.read_ahead_flags, &newinfo)) {
log_error("Unable to resume %s (%" PRIu32
":%" PRIu32 ")", name, child->info.major,
child->info.minor);
--- device-mapper/lib/ioctl/libdm-iface.c 2007/08/21 16:26:07 1.46
+++ device-mapper/lib/ioctl/libdm-iface.c 2007/11/27 20:57:05 1.47
@@ -920,6 +920,14 @@
return 1;
}
+uint32_t dm_task_get_read_ahead(const struct dm_task *dmt)
+{
+ uint32_t read_ahead = 0; //FIXME default? How cope with failure below?
+ // FIXME (void) dm_blockdev_get_read_ahead(dmt->dev_name, &read_ahead);
+
+ return read_ahead;
+}
+
const char *dm_task_get_name(const struct dm_task *dmt)
{
#ifdef DM_COMPAT
@@ -974,6 +982,15 @@
return 1;
}
+int dm_task_set_read_ahead(struct dm_task *dmt, uint32_t read_ahead,
+ uint32_t read_ahead_flags)
+{
+ dmt->read_ahead = read_ahead;
+ dmt->read_ahead_flags = read_ahead_flags;
+
+ return 1;
+}
+
int dm_task_suppress_identical_reload(struct dm_task *dmt)
{
dmt->suppress_identical_reload = 1;
--- device-mapper/lib/ioctl/libdm-targets.h 2007/08/21 16:26:07 1.21
+++ device-mapper/lib/ioctl/libdm-targets.h 2007/11/27 20:57:05 1.22
@@ -44,6 +44,8 @@
uid_t uid;
gid_t gid;
mode_t mode;
+ uint32_t read_ahead;
+ uint32_t read_ahead_flags;
union {
struct dm_ioctl *v4;
struct dm_ioctl_v1 *v1;
--- device-mapper/man/dmsetup.8 2007/10/09 12:14:48 1.18
+++ device-mapper/man/dmsetup.8 2007/11/27 20:57:05 1.19
@@ -114,6 +114,9 @@
.IP \fB-r|--readonly
.br
Set the table being loaded read-only.
+.IP \fB--readahead\ <sectors>
+.br
+Specify read ahead size in units of sectors.
.IP \fB--table\ <table>
.br
Specify a one-line table directly on the command line.
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2007-10-09 12:14 meyering
0 siblings, 0 replies; 8+ messages in thread
From: meyering @ 2007-10-09 12:14 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: meyering@sourceware.org 2007-10-09 12:14:48
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdm-common.c
man : dmsetup.8
Log message:
Allow $DM_DEV_DIR envvar to override default of "/dev".
* dmsetup/dmsetup.c (DEV_PATH): Remove definition.
(parse_loop_device_name): Add parameter: dev_dir.
Declare the "dev" parameter to be "const".
Use dev_dir, not DEV_PATH. Handle the case in which dev_dir
does not end in a "/".
(_get_abspath): Declare "path" parameter "const", to match.
(_process_losetup_switches): Add parameter: dev_dir.
Pass dev_dir to parse_loop_device_name.
(_process_switches): Add parameter: dev_dir.
Pass dev_dir to _process_losetup_switches.
(main): Set dev_dir from the DM_DEV_DIR envvar, else to "/dev".
Call dm_set_dev_dir.
* lib/libdm-common.c (dm_set_dev_dir): Rewrite to be careful
about boundary conditions, now that dev_dir may be tainted.
* man/dmsetup.8: Mention $DM_DEV_DIR.
Author: Jim Meyering <meyering@redhat.com>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.205&r2=1.206
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.95&r2=1.96
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-common.c.diff?cvsroot=dm&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/man/dmsetup.8.diff?cvsroot=dm&r1=1.17&r2=1.18
--- device-mapper/WHATS_NEW 2007/09/18 13:02:58 1.205
+++ device-mapper/WHATS_NEW 2007/10/09 12:14:48 1.206
@@ -1,5 +1,6 @@
Version 1.02.23 -
==================================
+ Allow $DM_DEV_DIR envvar to override default of "/dev".
Create e.g., libdevmapper.so.1.02, in build dir alongside the .so file.
Avoid static link failure with some SELinux libraries.
Remove obsolete dmfs code from tree and update INSTALL.
--- device-mapper/dmsetup/dmsetup.c 2007/08/21 16:26:06 1.95
+++ device-mapper/dmsetup/dmsetup.c 2007/10/09 12:14:48 1.96
@@ -90,6 +90,8 @@
#define ARGS_MAX 256
#define LOOP_TABLE_SIZE (PATH_MAX + 255)
+#define DEFAULT_DM_DEV_DIR "/dev"
+
/* FIXME Should be imported */
#ifndef DM_MAX_TYPE_NAME
# define DM_MAX_TYPE_NAME 16
@@ -97,7 +99,6 @@
/* FIXME Should be elsewhere */
#define SECTOR_SHIFT 9L
-#define DEV_PATH "/dev/"
#define err(msg, x...) fprintf(stderr, msg "\n", ##x)
@@ -2129,7 +2130,7 @@
* Returns the full absolute path, or NULL if the path could
* not be resolved.
*/
-static char *_get_abspath(char *path)
+static char *_get_abspath(const char *path)
{
char *_path;
@@ -2141,7 +2142,7 @@
return _path;
}
-static char *parse_loop_device_name(char *dev)
+static char *parse_loop_device_name(const char *dev, const char *dev_dir)
{
char *buf;
char *device;
@@ -2153,7 +2154,13 @@
if (!(device = _get_abspath(dev)))
goto error;
- if (strncmp(device, DEV_PATH, strlen(DEV_PATH)))
+ if (strncmp(device, dev_dir, strlen(dev_dir)))
+ goto error;
+
+ /* If dev_dir does not end in a slash, ensure that the
+ following byte in the device string is "/". */
+ if (dev_dir[strlen(dev_dir) - 1] != '/'
+ && device[strlen(dev_dir)] != '/')
goto error;
strncpy(buf, strrchr(device, '/') + 1, (size_t) PATH_MAX);
@@ -2234,7 +2241,8 @@
return 0;
}
-static int _process_losetup_switches(const char *base, int *argc, char ***argv)
+static int _process_losetup_switches(const char *base, int *argc, char ***argv,
+ const char *dev_dir)
{
static int ind;
int c;
@@ -2297,7 +2305,7 @@
return 0;
}
- if (!(device_name = parse_loop_device_name((*argv)[0]))) {
+ if (!(device_name = parse_loop_device_name((*argv)[0], dev_dir))) {
fprintf(stderr, "%s: Could not parse loop_device %s\n",
base, (*argv)[0]);
_losetup_usage(stderr);
@@ -2344,7 +2352,7 @@
return 1;
}
-static int _process_switches(int *argc, char ***argv)
+static int _process_switches(int *argc, char ***argv, const char *dev_dir)
{
char *base, *namebase;
static int ind;
@@ -2422,7 +2430,7 @@
}
if (!strcmp(base, "losetup") || !strcmp(base, "dmlosetup")){
- r = _process_losetup_switches(base, argc, argv);
+ r = _process_losetup_switches(base, argc, argv, dev_dir);
free(namebase);
return r;
}
@@ -2539,10 +2547,21 @@
{
struct command *c;
int r = 1;
+ const char *dev_dir;
(void) setlocale(LC_ALL, "");
- if (!_process_switches(&argc, &argv)) {
+ dev_dir = getenv ("DM_DEV_DIR");
+ if (dev_dir && *dev_dir) {
+ if (!dm_set_dev_dir(dev_dir)) {
+ fprintf(stderr, "Invalid DM_DEV_DIR envvar value.\n");
+ goto out;
+ }
+ } else {
+ dev_dir = DEFAULT_DM_DEV_DIR;
+ }
+
+ if (!_process_switches(&argc, &argv, dev_dir)) {
fprintf(stderr, "Couldn't process command line.\n");
goto out;
}
--- device-mapper/lib/libdm-common.c 2007/08/21 16:26:06 1.46
+++ device-mapper/lib/libdm-common.c 2007/10/09 12:14:48 1.47
@@ -463,9 +463,25 @@
_pop_node_ops();
}
-int dm_set_dev_dir(const char *dir)
+int dm_set_dev_dir(const char *dev_dir)
{
- snprintf(_dm_dir, sizeof(_dm_dir), "%s%s", dir, DM_DIR);
+ size_t len;
+ const char *slash;
+ if (*dev_dir != '/') {
+ log_debug("Invalid dev_dir value, %s: "
+ "not an absolute name.", dev_dir);
+ return 0;
+ }
+
+ len = strlen(dev_dir);
+ slash = dev_dir[len-1] == '/' ? "" : "/";
+
+ if (snprintf(_dm_dir, sizeof _dm_dir, "%s%s%s", dev_dir, slash, DM_DIR)
+ >= sizeof _dm_dir) {
+ log_debug("Invalid dev_dir value, %s: name too long.", dev_dir);
+ return 0;
+ }
+
return 1;
}
--- device-mapper/man/dmsetup.8 2007/01/29 19:35:24 1.17
+++ device-mapper/man/dmsetup.8 2007/10/09 12:14:48 1.18
@@ -341,6 +341,12 @@
.br
2056320 2875602 linear /dev/hdb 1028160
+.SH ENVIRONMENT VARIABLES
+.TP
+\fBDM_DEV_DIR\fP
+The device directory name.
+Defaults to "/dev" and must be an absolute name.
+
.SH AUTHORS
Original version: Joe Thornber (thornber@sistina.com)
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2007-04-27 14:52 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2007-04-27 14:52 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-04-27 15:52:41
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdevmapper.h libdm-string.c
lib/datastruct : hash.c
lib/ioctl : libdm-iface.c
Log message:
Deal with some more compiler warnings. Hope this doesn't break anything...
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.176&r2=1.177
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.68&r2=1.69
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-string.c.diff?cvsroot=dm&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/datastruct/hash.c.diff?cvsroot=dm&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/ioctl/libdm-iface.c.diff?cvsroot=dm&r1=1.41&r2=1.42
--- device-mapper/WHATS_NEW 2007/04/23 15:06:03 1.176
+++ device-mapper/WHATS_NEW 2007/04/27 14:52:40 1.177
@@ -1,5 +1,6 @@
Version 1.02.19 -
====================================
+ Deal with some more compiler warnings.
Introduce _add_field() and _is_same_field() to libdm-report.c.
Fix some libdevmapper-event and dmeventd memory leaks.
Remove unnecessary memset() return value checks.
--- device-mapper/dmsetup/dmsetup.c 2007/02/14 15:12:16 1.87
+++ device-mapper/dmsetup/dmsetup.c 2007/04/27 14:52:40 1.88
@@ -749,7 +749,7 @@
if (!_set_task_device(dmt, name, 0))
goto error;
- if (!dm_task_add_target(dmt, 0, size, "error", ""))
+ if (!dm_task_add_target(dmt, UINT64_C(0), size, "error", ""))
goto error;
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
@@ -1261,10 +1261,10 @@
}
}
-static void _out_string(const unsigned char *str)
+static void _out_string(const char *str)
{
while (*str)
- _out_char(*str++);
+ _out_char((unsigned char) *str++);
}
/* non-negative integers only */
@@ -1502,7 +1502,7 @@
struct dm_report_field *field, const void *data,
void *private __attribute((unused)))
{
- const char *name = dm_task_get_name((struct dm_task *) data);
+ const char *name = dm_task_get_name((const struct dm_task *) data);
return dm_report_field_string(rh, field, &name);
}
@@ -1512,7 +1512,7 @@
struct dm_report_field *field,
const void *data, void *private __attribute((unused)))
{
- const char *uuid = dm_task_get_uuid((struct dm_task *) data);
+ const char *uuid = dm_task_get_uuid((const struct dm_task *) data);
if (!uuid || !*uuid)
uuid = "";
@@ -1527,7 +1527,7 @@
{
char buf[5];
const char *s = buf;
- struct dm_info *info = (struct dm_info *) data;
+ const struct dm_info *info = data;
buf[0] = info->live_table ? 'L' : '-';
buf[1] = info->inactive_table ? 'I' : '-';
@@ -1767,7 +1767,7 @@
{
const char *s, *end;
struct winsize winsz;
- int len;
+ size_t len;
/* Symbol set default */
if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
@@ -1823,7 +1823,7 @@
/* Truncation doesn't work well with vt100 drawing char */
if (_tsym != &_tsym_vt100)
- if (ioctl(1, TIOCGWINSZ, &winsz) >= 0 && winsz.ws_col > 3)
+ if (ioctl(1, (unsigned long) TIOCGWINSZ, &winsz) >= 0 && winsz.ws_col > 3)
_termwidth = winsz.ws_col - 3;
return 1;
@@ -1860,13 +1860,13 @@
if (strncmp(device, DEV_PATH, strlen(DEV_PATH)))
goto error;
- strncpy(buf, strrchr(device, '/') + 1, PATH_MAX);
+ strncpy(buf, strrchr(device, '/') + 1, (size_t) PATH_MAX);
dm_free(device);
} else {
/* check for device number */
if (!strncmp(dev, "loop", strlen("loop")))
- strncpy(buf, dev, PATH_MAX);
+ strncpy(buf, dev, (size_t) PATH_MAX);
else
goto error;
}
@@ -1909,8 +1909,9 @@
sectors = size >> SECTOR_SHIFT;
if (_switches[VERBOSE_ARG])
- fprintf(stderr, "losetup: set loop size to %llukB (%llu sectors)\n",
- sectors >> 1, sectors);
+ fprintf(stderr, "losetup: set loop size to %llukB "
+ "(%llu sectors)\n", (long long unsigned) sectors >> 1,
+ (long long unsigned) sectors);
#ifdef HAVE_SYS_STATVFS_H
if (fstatvfs(fd, &fsbuf))
@@ -2034,7 +2035,7 @@
/* FIXME Missing free */
_table = dm_malloc(LOOP_TABLE_SIZE);
- if (!_loop_table(_table, LOOP_TABLE_SIZE, loop_file, device_name, offset)) {
+ if (!_loop_table(_table, (size_t) LOOP_TABLE_SIZE, loop_file, device_name, offset)) {
fprintf(stderr, "Could not build device-mapper table for %s\n", (*argv)[0]);
dm_free(device_name);
return 0;
--- device-mapper/lib/libdevmapper.h 2007/01/29 17:23:54 1.68
+++ device-mapper/lib/libdevmapper.h 2007/04/27 14:52:40 1.69
@@ -133,8 +133,8 @@
int dm_get_library_version(char *version, size_t size);
int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
-const char *dm_task_get_name(struct dm_task *dmt);
-const char *dm_task_get_uuid(struct dm_task *dmt);
+const char *dm_task_get_name(const struct dm_task *dmt);
+const char *dm_task_get_uuid(const struct dm_task *dmt);
struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
struct dm_names *dm_task_get_names(struct dm_task *dmt);
--- device-mapper/lib/libdm-string.c 2007/01/22 15:03:57 1.7
+++ device-mapper/lib/libdm-string.c 2007/04/27 14:52:40 1.8
@@ -117,7 +117,7 @@
n = vsnprintf(buf, bufsize, format, ap);
va_end(ap);
- if (n < 0 || (n > bufsize - 1))
+ if (n < 0 || ((unsigned) n + 1 > bufsize))
return -1;
return n;
--- device-mapper/lib/datastruct/hash.c 2007/01/22 15:03:57 1.5
+++ device-mapper/lib/datastruct/hash.c 2007/04/27 14:52:40 1.6
@@ -68,14 +68,14 @@
return n;
}
-static unsigned long _hash(const unsigned char *str, unsigned len)
+static unsigned long _hash(const char *str, unsigned len)
{
unsigned long h = 0, g;
unsigned i;
for (i = 0; i < len; i++) {
h <<= 4;
- h += _nums[*str++];
+ h += _nums[(unsigned char) *str++];
g = h & ((unsigned long) 0xf << 16u);
if (g) {
h ^= g >> 16u;
--- device-mapper/lib/ioctl/libdm-iface.c 2007/01/25 14:16:20 1.41
+++ device-mapper/lib/ioctl/libdm-iface.c 2007/04/27 14:52:41 1.42
@@ -433,12 +433,12 @@
return 1;
}
-static const char *_dm_task_get_name_v1(struct dm_task *dmt)
+static const char *_dm_task_get_name_v1(const struct dm_task *dmt)
{
return (dmt->dmi.v1->name);
}
-static const char *_dm_task_get_uuid_v1(struct dm_task *dmt)
+static const char *_dm_task_get_uuid_v1(const struct dm_task *dmt)
{
return (dmt->dmi.v1->uuid);
}
@@ -924,7 +924,7 @@
return 1;
}
-const char *dm_task_get_name(struct dm_task *dmt)
+const char *dm_task_get_name(const struct dm_task *dmt)
{
#ifdef DM_COMPAT
if (_dm_version == 1)
@@ -934,7 +934,7 @@
return (dmt->dmi.v4->name);
}
-const char *dm_task_get_uuid(struct dm_task *dmt)
+const char *dm_task_get_uuid(const struct dm_task *dmt)
{
#ifdef DM_COMPAT
if (_dm_version == 1)
@@ -1555,7 +1555,7 @@
dmi->flags |= DM_SKIP_BDGET_FLAG;
log_debug("dm %s %s %s%s%s %s%.0d%s%.0d%s"
- "%s%c%c%s %.0llu %s [%u]",
+ "%s%c%c%s %.0" PRIu64 " %s [%u]",
_cmd_data_v4[dmt->type].name,
dmi->name, dmi->uuid, dmt->newname ? " " : "",
dmt->newname ? dmt->newname : "",
^ permalink raw reply [flat|nested] 8+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...
@ 2007-01-18 17:48 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2007-01-18 17:48 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-01-18 17:47:59
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
lib : libdevmapper.h libdm-report.c
Log message:
Some internal renaming.
Add --separator and --sort to dmsetup (unused as yet).
Make alignment flag optional when specifying report fields.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.151&r2=1.152
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdevmapper.h.diff?cvsroot=dm&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.2&r2=1.3
--- device-mapper/WHATS_NEW 2007/01/17 17:50:54 1.151
+++ device-mapper/WHATS_NEW 2007/01/18 17:47:56 1.152
@@ -1,5 +1,8 @@
Version 1.02.16 -
===================================
+ Add --separator and --sort to dmsetup (unused).
+ Make alignment flag optional when specifying report fields.
+
Version 1.02.15 - 17th January 2007
===================================
Add basic reporting functions to libdevmapper.
--- device-mapper/dmsetup/dmsetup.c 2007/01/16 21:13:07 1.76
+++ device-mapper/dmsetup/dmsetup.c 2007/01/18 17:47:57 1.77
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2005 NEC Corperation
+ * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2007 NEC Corperation
*
* This file is part of the device-mapper userspace tools.
*
@@ -114,7 +114,9 @@
NOOPENCOUNT_ARG,
NOTABLE_ARG,
OPTIONS_ARG,
+ SEPARATOR_ARG,
SHOWKEYS_ARG,
+ SORT_ARG,
TABLE_ARG,
TARGET_ARG,
TREE_ARG,
@@ -126,10 +128,10 @@
};
static int _switches[NUM_SWITCHES];
-static int _values[NUM_SWITCHES];
+static int _int_args[NUM_SWITCHES];
+static char *_string_args[NUM_SWITCHES];
static int _num_devices;
static char *_uuid;
-static char *_fields;
static char *_table;
static char *_target;
static char *_command;
@@ -348,8 +350,8 @@
if (!dm_task_set_uuid(dmt, _uuid))
return 0;
} else if (_switches[MAJOR_ARG] && _switches[MINOR_ARG]) {
- if (!dm_task_set_major(dmt, _values[MAJOR_ARG]) ||
- !dm_task_set_minor(dmt, _values[MINOR_ARG]))
+ if (!dm_task_set_major(dmt, _int_args[MAJOR_ARG]) ||
+ !dm_task_set_minor(dmt, _int_args[MINOR_ARG]))
return 0;
} else if (!optional) {
fprintf(stderr, "No device specified.\n");
@@ -440,19 +442,19 @@
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
goto out;
- if (_switches[MAJOR_ARG] && !dm_task_set_major(dmt, _values[MAJOR_ARG]))
+ if (_switches[MAJOR_ARG] && !dm_task_set_major(dmt, _int_args[MAJOR_ARG]))
goto out;
- if (_switches[MINOR_ARG] && !dm_task_set_minor(dmt, _values[MINOR_ARG]))
+ if (_switches[MINOR_ARG] && !dm_task_set_minor(dmt, _int_args[MINOR_ARG]))
goto out;
- if (_switches[UID_ARG] && !dm_task_set_uid(dmt, _values[UID_ARG]))
+ if (_switches[UID_ARG] && !dm_task_set_uid(dmt, _int_args[UID_ARG]))
goto out;
- if (_switches[GID_ARG] && !dm_task_set_gid(dmt, _values[GID_ARG]))
+ if (_switches[GID_ARG] && !dm_task_set_gid(dmt, _int_args[GID_ARG]))
goto out;
- if (_switches[MODE_ARG] && !dm_task_set_mode(dmt, _values[MODE_ARG]))
+ if (_switches[MODE_ARG] && !dm_task_set_mode(dmt, _int_args[MODE_ARG]))
goto out;
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
@@ -1736,7 +1738,7 @@
#ifdef HAVE_SYS_STATVFS_H
if (fstatvfs(fd, &fsbuf))
- goto error;
+ goto error;
/* FIXME Fragment size currently unused */
blksize = fsbuf.f_frsize;
@@ -1744,7 +1746,7 @@
close(fd);
- if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL,
+ if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL,
(long long unsigned)sectors, file, off) < 0)
return 0;
@@ -1888,7 +1890,9 @@
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
{"notable", 0, &ind, NOTABLE_ARG},
{"options", 1, &ind, OPTIONS_ARG},
+ {"separator", 1, &ind, SEPARATOR_ARG},
{"showkeys", 0, &ind, SHOWKEYS_ARG},
+ {"sort", 1, &ind, SORT_ARG},
{"table", 1, &ind, TABLE_ARG},
{"target", 1, &ind, TARGET_ARG},
{"tree", 0, &ind, TREE_ARG},
@@ -1906,7 +1910,7 @@
* Zero all the index counts.
*/
memset(&_switches, 0, sizeof(_switches));
- memset(&_values, 0, sizeof(_values));
+ memset(&_int_args, 0, sizeof(_int_args));
namebase = strdup((*argv)[0]);
base = basename(namebase);
@@ -1918,17 +1922,17 @@
_switches[OPTIONS_ARG]++;
_switches[MAJOR_ARG]++;
_switches[MINOR_ARG]++;
- _fields = (char *) "name";
+ _string_args[OPTIONS_ARG] = (char *) "name";
if (*argc == 3) {
- _values[MAJOR_ARG] = atoi((*argv)[1]);
- _values[MINOR_ARG] = atoi((*argv)[2]);
+ _int_args[MAJOR_ARG] = atoi((*argv)[1]);
+ _int_args[MINOR_ARG] = atoi((*argv)[2]);
*argc -= 2;
*argv += 2;
} else if ((*argc == 2) &&
(2 == sscanf((*argv)[1], "%i:%i",
- &_values[MAJOR_ARG],
- &_values[MINOR_ARG]))) {
+ &_int_args[MAJOR_ARG],
+ &_int_args[MINOR_ARG]))) {
*argc -= 1;
*argv += 1;
} else {
@@ -1950,7 +1954,7 @@
optarg = 0;
optind = OPTIND_INIT;
- while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:ru:Uv",
+ while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:O:ru:Uv",
long_options, NULL)) != -1) {
if (c == ':' || c == '?')
return 0;
@@ -1962,17 +1966,25 @@
_switches[READ_ONLY]++;
if (c == 'j' || ind == MAJOR_ARG) {
_switches[MAJOR_ARG]++;
- _values[MAJOR_ARG] = atoi(optarg);
+ _int_args[MAJOR_ARG] = atoi(optarg);
}
if (c == 'm' || ind == MINOR_ARG) {
_switches[MINOR_ARG]++;
- _values[MINOR_ARG] = atoi(optarg);
+ _int_args[MINOR_ARG] = atoi(optarg);
}
if (c == 'n' || ind == NOTABLE_ARG)
_switches[NOTABLE_ARG]++;
if (c == 'o' || ind == OPTIONS_ARG) {
_switches[OPTIONS_ARG]++;
- _fields = optarg;
+ _string_args[OPTIONS_ARG] = optarg;
+ }
+ if (ind == SEPARATOR_ARG) {
+ _switches[SEPARATOR_ARG]++;
+ _string_args[SEPARATOR_ARG] = optarg;
+ }
+ if (c == 'O' || ind == SORT_ARG) {
+ _switches[SORT_ARG]++;
+ _string_args[SORT_ARG] = optarg;
}
if (c == 'v' || ind == VERBOSE_ARG)
_switches[VERBOSE_ARG]++;
@@ -1982,16 +1994,16 @@
}
if (c == 'G' || ind == GID_ARG) {
_switches[GID_ARG]++;
- _values[GID_ARG] = atoi(optarg);
+ _int_args[GID_ARG] = atoi(optarg);
}
if (c == 'U' || ind == UID_ARG) {
_switches[UID_ARG]++;
- _values[UID_ARG] = atoi(optarg);
+ _int_args[UID_ARG] = atoi(optarg);
}
if (c == 'M' || ind == MODE_ARG) {
_switches[MODE_ARG]++;
/* FIXME Accept modes as per chmod */
- _values[MODE_ARG] = (int) strtol(optarg, NULL, 8);
+ _int_args[MODE_ARG] = (int) strtol(optarg, NULL, 8);
}
if ((ind == EXEC_ARG)) {
_switches[EXEC_ARG]++;
@@ -2032,12 +2044,12 @@
}
if (_switches[COLS_ARG] && _switches[OPTIONS_ARG] &&
- strcmp(_fields, "name")) {
+ strcmp(_string_args[OPTIONS_ARG], "name")) {
fprintf(stderr, "Only -o name is supported so far.\n");
return 0;
}
- if (_switches[TREE_ARG] && !_process_tree_options(_fields))
+ if (_switches[TREE_ARG] && !_process_tree_options(_string_args[OPTIONS_ARG]))
return 0;
if (_switches[TABLE_ARG] && _switches[NOTABLE_ARG]) {
--- device-mapper/lib/libdevmapper.h 2007/01/16 18:03:40 1.64
+++ device-mapper/lib/libdevmapper.h 2007/01/18 17:47:58 1.65
@@ -646,11 +646,13 @@
/*
* dm_report_field_type flags
*/
-#define DM_REPORT_FIELD_MASK 0x0000000F
+#define DM_REPORT_FIELD_MASK 0x000000FF
+#define DM_REPORT_FIELD_ALIGN_MASK 0x0000000F
#define DM_REPORT_FIELD_ALIGN_LEFT 0x00000001
#define DM_REPORT_FIELD_ALIGN_RIGHT 0x00000002
-#define DM_REPORT_FIELD_STRING 0x00000004
-#define DM_REPORT_FIELD_NUMBER 0x00000008
+#define DM_REPORT_FIELD_TYPE_MASK 0x000000F0
+#define DM_REPORT_FIELD_TYPE_STRING 0x00000010
+#define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020
struct dm_report;
struct dm_report_field_type {
@@ -668,7 +670,7 @@
/*
* dm_report_init output_flags
*/
-#define DM_REPORT_OUTPUT_MASK 0x00000007
+#define DM_REPORT_OUTPUT_MASK 0x000000FF
#define DM_REPORT_OUTPUT_ALIGNED 0x00000001
#define DM_REPORT_OUTPUT_BUFFERED 0x00000002
#define DM_REPORT_OUTPUT_HEADINGS 0x00000004
--- device-mapper/lib/libdm-report.c 2007/01/16 21:13:07 1.2
+++ device-mapper/lib/libdm-report.c 2007/01/18 17:47:58 1.3
@@ -672,7 +672,7 @@
for (cnt = 0; cnt < rowa->rh->keys_count; cnt++) {
sfa = (*rowa->sort_fields)[cnt];
sfb = (*rowb->sort_fields)[cnt];
- if (sfa->props->flags & DM_REPORT_FIELD_NUMBER) {
+ if (sfa->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) {
const uint64_t numa =
*(const uint64_t *) sfa->sort_value;
const uint64_t numb =
@@ -686,7 +686,7 @@
} else { /* FLD_DESCENDING */
return (numa < numb) ? 1 : -1;
}
- } else { /* DM_REPORT_FIELD_STRING */
+ } else { /* DM_REPORT_FIELD_TYPE_STRING */
const char *stra = (const char *) sfa->sort_value;
const char *strb = (const char *) sfb->sort_value;
int cmp = strcmp(stra, strb);
@@ -740,6 +740,7 @@
const char *repstr;
char buf[4096];
unsigned width;
+ uint32_t align;
if (list_empty(&rh->rows))
return 1;
@@ -771,18 +772,23 @@
if (!dm_pool_grow_object(rh->mem, repstr,
strlen(repstr)))
goto bad_grow;
- } else if (field->props->flags & DM_REPORT_FIELD_ALIGN_LEFT) {
- if (dm_snprintf(buf, sizeof(buf), "%-*.*s",
- width, width, repstr) < 0)
- goto bad_snprintf;
- if (!dm_pool_grow_object(rh->mem, buf, width))
- goto bad_grow;
- } else if (field->props->flags & DM_REPORT_FIELD_ALIGN_RIGHT) {
- if (dm_snprintf(buf, sizeof(buf), "%*.*s",
- width, width, repstr) < 0)
- goto bad_snprintf;
- if (!dm_pool_grow_object(rh->mem, buf, width))
- goto bad_grow;
+ } else {
+ if (!(align = field->props->flags & DM_REPORT_FIELD_ALIGN_MASK))
+ align = (field->props->flags & DM_REPORT_FIELD_TYPE_NUMBER) ?
+ DM_REPORT_FIELD_ALIGN_RIGHT : DM_REPORT_FIELD_ALIGN_LEFT;
+ if (align & DM_REPORT_FIELD_ALIGN_LEFT) {
+ if (dm_snprintf(buf, sizeof(buf), "%-*.*s",
+ width, width, repstr) < 0)
+ goto bad_snprintf;
+ if (!dm_pool_grow_object(rh->mem, buf, width))
+ goto bad_grow;
+ } else if (field->props->flags & DM_REPORT_FIELD_ALIGN_RIGHT) {
+ if (dm_snprintf(buf, sizeof(buf), "%*.*s",
+ width, width, repstr) < 0)
+ goto bad_snprintf;
+ if (!dm_pool_grow_object(rh->mem, buf, width))
+ goto bad_grow;
+ }
}
if (!list_end(&row->fields, fh))
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-06-24 22:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 15:12 device-mapper ./WHATS_NEW dmsetup/dmsetup.c li agk
-- strict thread matches above, loose matches on Subject: below --
2008-06-24 22:53 agk
2008-06-24 20:16 agk
2008-04-19 15:50 agk
2007-11-27 20:57 agk
2007-10-09 12:14 meyering
2007-04-27 14:52 agk
2007-01-18 17:48 agk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.