* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2006-10-19 15:34 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2006-10-19 15:34 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2006-10-19 15:34:50
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Suppress encryption key in 'dmsetup table' output unless --showkeys supplied.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.73&r2=1.74
--- device-mapper/WHATS_NEW 2006/10/13 19:01:30 1.132
+++ device-mapper/WHATS_NEW 2006/10/19 15:34:49 1.133
@@ -1,5 +1,6 @@
Version 1.02.13 -
=============================
+ Suppress encryption key in 'dmsetup table' output unless --showkeys supplied.
Version 1.02.12 - 13 Oct 2006
=============================
--- device-mapper/dmsetup/dmsetup.c 2006/10/12 17:09:09 1.73
+++ device-mapper/dmsetup/dmsetup.c 2006/10/19 15:34:50 1.74
@@ -114,6 +114,7 @@
NOOPENCOUNT_ARG,
NOTABLE_ARG,
OPTIONS_ARG,
+ SHOWKEYS_ARG,
TABLE_ARG,
TARGET_ARG,
TREE_ARG,
@@ -211,7 +212,11 @@
r = 1;
out:
+#ifndef HAVE_GETLINE
dm_free(buffer);
+#else
+ free(buffer);
+#endif
if (file)
fclose(fp);
return r;
@@ -915,7 +920,7 @@
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
- char *params;
+ char *params, *c;
int cmd;
struct dm_names *names = (struct dm_names *) data;
const char *name = NULL;
@@ -978,6 +983,17 @@
if (data && !_switches[VERBOSE_ARG])
printf("%s: ", name);
if (target_type) {
+
+ /* Suppress encryption key */
+ if (!_switches[SHOWKEYS_ARG] &&
+ !strcmp(target_type, "crypt")) {
+ c = params;
+ while (*c && *c != ' ')
+ c++;
+ c++;
+ while (*c && *c != ' ')
+ *c++ = '0';
+ }
printf("%" PRIu64 " %" PRIu64 " %s %s",
start, length, target_type, params);
}
@@ -1522,7 +1538,7 @@
{"info", "[<device>]", 0, 1, _info},
{"deps", "[<device>]", 0, 1, _deps},
{"status", "[<device>] [--target <target_type>]", 0, 1, _status},
- {"table", "[<device>] [--target <target_type>]", 0, 1, _status},
+ {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, 1, _status},
{"wait", "<device> [<event_nr>]", 0, 2, _wait},
{"mknodes", "[<device>]", 0, 1, _mknodes},
{"targets", "", 0, 0, _targets},
@@ -1868,6 +1884,7 @@
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
{"notable", 0, &ind, NOTABLE_ARG},
{"options", 1, &ind, OPTIONS_ARG},
+ {"showkeys", 0, &ind, SHOWKEYS_ARG},
{"table", 1, &ind, TABLE_ARG},
{"target", 1, &ind, TARGET_ARG},
{"tree", 0, &ind, TREE_ARG},
@@ -1988,6 +2005,8 @@
_switches[NOLOCKFS_ARG]++;
if ((ind == NOOPENCOUNT_ARG))
_switches[NOOPENCOUNT_ARG]++;
+ if ((ind == SHOWKEYS_ARG))
+ _switches[SHOWKEYS_ARG]++;
if ((ind == TABLE_ARG)) {
_switches[TABLE_ARG]++;
_table = optarg;
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-01-24 18:09 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-01-24 18:09 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-01-24 18:09:07
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Migrate dmsetup column-based output over to new libdevmapper report framework.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.158&r2=1.159
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.78&r2=1.79
--- device-mapper/WHATS_NEW 2007/01/23 19:18:52 1.158
+++ device-mapper/WHATS_NEW 2007/01/24 18:09:06 1.159
@@ -1,5 +1,6 @@
Version 1.02.16 -
===================================
+ Migrate dmsetup column-based output over to new libdevmapper report framework.
Add descriptions to reporting field definitions.
Add a dso-private variable to dmeventd dso interface.
Add dm_event_handler_[gs]et_timeout functions.
--- device-mapper/dmsetup/dmsetup.c 2007/01/22 15:03:57 1.78
+++ device-mapper/dmsetup/dmsetup.c 2007/01/24 18:09:07 1.79
@@ -136,10 +136,22 @@
static char *_target;
static char *_command;
static struct dm_tree *_dtree;
+static struct dm_report *_report;
/*
* Commands
*/
+
+typedef int (*command_fn) (int argc, char **argv, void *data);
+
+struct command {
+ const char *name;
+ const char *help;
+ int min_args;
+ int max_args;
+ command_fn fn;
+};
+
static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
int line)
{
@@ -224,66 +236,27 @@
return r;
}
-static void _display_info_cols_noheadings(struct dm_task *dmt,
- struct dm_info *info)
-{
- const char *uuid;
-
- if (!info->exists)
- return;
-
- uuid = dm_task_get_uuid(dmt);
-
- if (_switches[OPTIONS_ARG])
- printf("%s\n", dm_task_get_name(dmt));
- else
- printf("%s:%d:%d:%s%s%s%s:%d:%d:%" PRIu32 ":%s\n",
- dm_task_get_name(dmt),
- info->major, info->minor,
- info->live_table ? "L" : "-",
- info->inactive_table ? "I" : "-",
- info->suspended ? "s" : "-",
- info->read_only ? "r" : "w",
- info->open_count, info->target_count, info->event_nr,
- uuid && *uuid ? uuid : "");
-}
+struct dmsetup_report_obj {
+ struct dm_task *task;
+ struct dm_info *info;
+};
-static void _display_info_cols(struct dm_task *dmt, struct dm_info *info)
+static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
{
- static int _headings = 0;
- const char *uuid;
+ struct dmsetup_report_obj obj;
if (!info->exists) {
- printf("Device does not exist.\n");
- return;
- }
-
- if (!_headings) {
- if (_switches[OPTIONS_ARG])
- printf("Name\n");
- else
- printf("Name Maj Min Stat Open Targ "
- "Event UUID\n");
- _headings = 1;
+ fprintf(stderr, "Device does not exist.\n");
+ return 0;
}
- if (_switches[OPTIONS_ARG])
- printf("%s\n", dm_task_get_name(dmt));
- else {
- printf("%-16s %3d %3d %s%s%s%s %4d %4d %6" PRIu32 " ",
- dm_task_get_name(dmt),
- info->major, info->minor,
- info->live_table ? "L" : "-",
- info->inactive_table ? "I" : "-",
- info->suspended ? "s" : "-",
- info->read_only ? "r" : "w",
- info->open_count, info->target_count, info->event_nr);
+ obj.task = dmt;
+ obj.info = info;
- if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
- printf("%s", uuid);
+ if (!dm_report_object(_report, &obj))
+ return 0;
- printf("\n");
- }
+ return 1;
}
static void _display_info_long(struct dm_task *dmt, struct dm_info *info)
@@ -333,9 +306,8 @@
if (!_switches[COLS_ARG])
_display_info_long(dmt, &info);
- else if (_switches[NOHEADINGS_ARG])
- _display_info_cols_noheadings(dmt, &info);
else
+ /* FIXME return code */
_display_info_cols(dmt, &info);
return info.exists ? 1 : 0;
@@ -1499,6 +1471,194 @@
}
/*
+ * Report device information
+ */
+
+/* dm specific display functions */
+
+static int _int32_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private)
+{
+ const int32_t value = *(const int32_t *)data;
+
+ return dm_report_field_int32(rh, field, &value);
+}
+
+static int _uint32_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private)
+{
+ const uint32_t value = *(const int32_t *)data;
+
+ return dm_report_field_uint32(rh, field, &value);
+}
+
+static int _dm_name_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private)
+{
+ const char *name = dm_task_get_name((struct dm_task *) data);
+
+ return dm_report_field_string(rh, field, &name);
+}
+
+static int _dm_uuid_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const char *uuid = dm_task_get_uuid((struct dm_task *) data);
+
+ if (!uuid || !*uuid)
+ uuid = "";
+
+ return dm_report_field_string(rh, field, &uuid);
+}
+
+static int _dm_info_status_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field, const void *data,
+ void *private)
+{
+ char buf[5];
+ const char *s = buf;
+ struct dm_info *info = (struct dm_info *) data;
+
+ buf[0] = info->live_table ? 'L' : '-';
+ buf[1] = info->inactive_table ? 'I' : '-';
+ buf[2] = info->suspended ? 's' : '-';
+ buf[3] = info->read_only ? 'r' : 'w';
+ buf[4] = '\0';
+
+ return dm_report_field_string(rh, field, &s);
+}
+
+/* Report types */
+enum { DR_TASK = 1, DR_INFO = 2 };
+
+static void *_task_get_obj(void *obj)
+{
+ return ((struct dmsetup_report_obj *)obj)->task;
+}
+
+static void *_info_get_obj(void *obj)
+{
+ return ((struct dmsetup_report_obj *)obj)->info;
+}
+
+static const struct dm_report_object_type _report_types[] = {
+ { DR_TASK, "Mapped Device Name", "", _task_get_obj },
+ { DR_INFO, "Mapped Device Information", "", _info_get_obj },
+ { 0, "", "", NULL },
+};
+
+/* Column definitions */
+#define OFFSET_OF(strct, field) ((unsigned int) &((struct strct *)NULL)->field)
+#define STR (DM_REPORT_FIELD_TYPE_STRING)
+#define NUM (DM_REPORT_FIELD_TYPE_NUMBER)
+#define FIELD_O(type, strct, sorttype, head, field, width, func, id, desc) {DR_ ## type, id, OFFSET_OF(strct, field), head, width, sorttype, &_ ## func ## _disp, desc},
+#define FIELD_F(type, sorttype, head, width, func, id, desc) {DR_ ## type, id, 0, head, width, sorttype, &_ ## func ## _disp, desc},
+
+static const struct dm_report_field_type _report_fields[] = {
+/* *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 identifier for mapped device (optional).")
+FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "status", "Attributes.")
+FIELD_O(INFO, dm_info, NUM, "Maj", major, 3, int32, "major", "Major number.")
+FIELD_O(INFO, dm_info, NUM, "Min", minor, 3, int32, "minor", "Minor number.")
+FIELD_O(INFO, dm_info, NUM, "Open", open_count, 4, int32, "open_count", "Number of references to open device, if requested.")
+FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "target_count", "Number of segments in live table, if present.")
+FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "event_nr", "Current event number.")
+{0, "", 0, "", 0, 0, NULL, NULL},
+/* *INDENT-ON* */
+};
+
+#undef STR
+#undef NUM
+#undef FIELD_O
+#undef FIELD_F
+
+static const char *default_report_options = "name,major,minor,status,open_count,target_count,event_nr,uuid";
+
+static int _report_init(struct command *c)
+{
+ char *options = (char *) default_report_options;
+ const char *keys = "";
+ const char *separator = " ";
+ int aligned = 1, headings = 1, buffered = 0;
+ uint32_t report_type = 0;
+ uint32_t flags = 0;
+ size_t len = 0;
+ int r = 0;
+
+ /* emulate old dmsetup behaviour */
+ if (_switches[NOHEADINGS_ARG]) {
+ separator = ":";
+ aligned = 0;
+ headings = 0;
+ }
+
+ if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) {
+ if (*_string_args[OPTIONS_ARG] != '+')
+ options = _string_args[OPTIONS_ARG];
+ else {
+ len = strlen(default_report_options) +
+ strlen(_string_args[OPTIONS_ARG]);
+ if (!(options = dm_malloc(len))) {
+ err("Failed to allocate option string.");
+ return 0;
+ }
+ if (dm_snprintf(options, len, "%s,%s",
+ default_report_options,
+ &_string_args[OPTIONS_ARG][1]) < 0) {
+ err("snprintf failed");
+ goto out;
+ }
+ }
+ }
+
+ if (_switches[SORT_ARG] && _string_args[SORT_ARG]) {
+ keys = _string_args[SORT_ARG];
+ buffered = 1;
+ if (!strcmp(c->name, "status") || !strcmp(c->name, "table")) {
+ err("--sort is not yet supported with status and table");
+ goto out;
+ }
+ }
+
+ if (_switches[SEPARATOR_ARG] && _string_args[SEPARATOR_ARG]) {
+ separator = _string_args[SEPARATOR_ARG];
+ aligned = 0;
+ }
+
+ if (aligned)
+ flags |= DM_REPORT_OUTPUT_ALIGNED;
+
+ if (buffered)
+ flags |= DM_REPORT_OUTPUT_BUFFERED;
+
+ if (headings)
+ flags |= DM_REPORT_OUTPUT_HEADINGS;
+
+ if (!(_report = dm_report_init(&report_type,
+ _report_types, _report_fields,
+ options, separator, flags, keys, NULL)))
+ goto out;
+
+ r = 1;
+
+out:
+ if (len)
+ dm_free(options);
+
+ return r;
+}
+
+/*
* List devices
*/
static int _ls(int argc, char **argv, void *data)
@@ -1513,18 +1673,8 @@
}
/*
- * dispatch table
+ * Dispatch table
*/
-typedef int (*command_fn) (int argc, char **argv, void *data);
-
-struct command {
- const char *name;
- const char *help;
- int min_args;
- int max_args;
- command_fn fn;
-};
-
static struct command _commands[] = {
{"create", "<dev_name> [-j|--major <major> -m|--minor <minor>]\n"
"\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
@@ -2044,12 +2194,6 @@
return 0;
}
- if (_switches[COLS_ARG] && _switches[OPTIONS_ARG] &&
- 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(_string_args[OPTIONS_ARG]))
return 0;
@@ -2098,6 +2242,9 @@
goto out;
}
+ if (_switches[COLS_ARG] && !_report_init(c))
+ goto out;
+
doit:
if (!c->fn(argc, argv, NULL)) {
fprintf(stderr, "Command failed\n");
@@ -2107,5 +2254,10 @@
r = 0;
out:
+ if (_report) {
+ dm_report_output(_report);
+ dm_report_free(_report);
+ }
+
return r;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-01-29 17:45 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-01-29 17:45 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-01-29 17:45:32
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
reorder report field definitions
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.163&r2=1.164
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.80&r2=1.81
--- device-mapper/WHATS_NEW 2007/01/29 17:23:54 1.163
+++ device-mapper/WHATS_NEW 2007/01/29 17:45:32 1.164
@@ -1,6 +1,6 @@
Version 1.02.17 -
===================================
- Use fixed-size fields in report interface.
+ Use fixed-size fields in report interface and reorder.
Version 1.02.16 - 25th January 2007
===================================
--- device-mapper/dmsetup/dmsetup.c 2007/01/25 14:16:20 1.80
+++ device-mapper/dmsetup/dmsetup.c 2007/01/29 17:45:32 1.81
@@ -1561,8 +1561,8 @@
#define OFFSET_OF(strct, field) ((unsigned int) &((struct strct *)NULL)->field)
#define STR (DM_REPORT_FIELD_TYPE_STRING)
#define NUM (DM_REPORT_FIELD_TYPE_NUMBER)
-#define FIELD_O(type, strct, sorttype, head, field, width, func, id, desc) {DR_ ## type, id, OFFSET_OF(strct, field), head, width, sorttype, &_ ## func ## _disp, desc},
-#define FIELD_F(type, sorttype, head, width, func, id, desc) {DR_ ## type, id, 0, head, width, sorttype, &_ ## func ## _disp, desc},
+#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},
+#define FIELD_F(type, sorttype, head, width, func, id, desc) {DR_ ## type, sorttype, 0, width, id, head, &_ ## func ## _disp, desc},
static const struct dm_report_field_type _report_fields[] = {
/* *INDENT-OFF* */
@@ -1574,7 +1574,7 @@
FIELD_O(INFO, dm_info, NUM, "Open", open_count, 4, int32, "open_count", "Number of references to open device, if requested.")
FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "target_count", "Number of segments in live table, if present.")
FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "event_nr", "Current event number.")
-{0, "", 0, "", 0, 0, NULL, NULL},
+{0, 0, 0, 0, "", "", NULL, NULL},
/* *INDENT-ON* */
};
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-01-29 18:18 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-01-29 18:18 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-01-29 18:18:41
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Add dmsetup 'help' command and update usage text.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.164&r2=1.165
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.81&r2=1.82
--- device-mapper/WHATS_NEW 2007/01/29 17:45:32 1.164
+++ device-mapper/WHATS_NEW 2007/01/29 18:18:40 1.165
@@ -1,5 +1,6 @@
Version 1.02.17 -
===================================
+ Add dmsetup 'help' command and update usage text.
Use fixed-size fields in report interface and reorder.
Version 1.02.16 - 25th January 2007
--- device-mapper/dmsetup/dmsetup.c 2007/01/29 17:45:32 1.81
+++ device-mapper/dmsetup/dmsetup.c 2007/01/29 18:18:41 1.82
@@ -1567,10 +1567,10 @@
static const struct dm_report_field_type _report_fields[] = {
/* *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 identifier for mapped device (optional).")
-FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "status", "Attributes.")
-FIELD_O(INFO, dm_info, NUM, "Maj", major, 3, int32, "major", "Major number.")
-FIELD_O(INFO, dm_info, NUM, "Min", minor, 3, int32, "minor", "Minor number.")
+FIELD_F(TASK, STR, "UUID", 32, dm_uuid, "uuid", "Unique (optional) identifier for mapped device.")
+FIELD_F(INFO, STR, "Stat", 4, dm_info_status, "status", "(L)ive, (I)nactive, (s)uspended, (r)ead-only, read-(w)rite.")
+FIELD_O(INFO, dm_info, NUM, "Maj", major, 3, int32, "major", "Block device major number.")
+FIELD_O(INFO, dm_info, NUM, "Min", minor, 3, int32, "minor", "Block device minor number.")
FIELD_O(INFO, dm_info, NUM, "Open", open_count, 4, int32, "open_count", "Number of references to open device, if requested.")
FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "target_count", "Number of segments in live table, if present.")
FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "event_nr", "Current event number.")
@@ -1673,10 +1673,13 @@
return _process_all(argc, argv, 0, _display_name);
}
+static int _help(int argc, char **argv, void *data);
+
/*
* Dispatch table
*/
static struct command _commands[] = {
+ {"help", "\n", 0, 0, _help},
{"create", "<dev_name> [-j|--major <major> -m|--minor <minor>]\n"
"\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
"\t [-u|uuid <uuid>]\n"
@@ -1710,14 +1713,17 @@
fprintf(out, "Usage:\n\n");
fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n"
- " [-r|--readonly] [--noopencount] [--nolockfs]\n\n");
+ " [-r|--readonly] [--noopencount] [--nolockfs]\n"
+ " [-c|--columns] [-o <fields>] [--noheadings] [--separator <separator>]\n\n");
for (i = 0; _commands[i].name; i++)
fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
fprintf(out, "\n<device> may be device name or -u <uuid> or "
"-j <major> -m <minor>\n");
+ fprintf(out, "<fields> are comma-separated. Use -c -o help for list.\n");
fprintf(out, "Table_file contents may be supplied on stdin.\n");
fprintf(out, "Tree options are: ascii, utf, vt100; compact, inverted, notrunc;\n"
- " [no]device, active, open, rw and uuid.\n\n");
+ " [no]device, active, open, rw and uuid.\n");
+ fprintf(out, "\n");
return;
}
@@ -1728,6 +1734,13 @@
"[-o offset] [-f|loop_device] [file]\n\n");
}
+static int _help(int argc, char **argv, void *data)
+{
+ _usage(stderr);
+
+ return 1;
+}
+
static struct command *_find_command(const char *name)
{
int i;
@@ -2096,7 +2109,7 @@
return 1;
}
- if(!strcmp(base, "losetup") || !strcmp(base, "dmlosetup")){
+ if (!strcmp(base, "losetup") || !strcmp(base, "dmlosetup")){
r = _process_losetup_switches(base, argc, argv);
free(namebase);
return r;
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-04-27 15:12 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-04-27 15:12 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-04-27 16:12:26
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Fix segfault in 'dmsetup status' without --showkeys against crypt target. [nec]
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.177&r2=1.178
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.88&r2=1.89
--- device-mapper/WHATS_NEW 2007/04/27 14:52:40 1.177
+++ device-mapper/WHATS_NEW 2007/04/27 15:12:26 1.178
@@ -1,5 +1,6 @@
Version 1.02.19 -
====================================
+ Fix segfault in 'dmsetup status' without --showkeys against crypt target.
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.
--- device-mapper/dmsetup/dmsetup.c 2007/04/27 14:52:40 1.88
+++ device-mapper/dmsetup/dmsetup.c 2007/04/27 15:12:26 1.89
@@ -962,17 +962,18 @@
if (data && !_switches[VERBOSE_ARG])
printf("%s: ", name);
if (target_type) {
-
- /* Suppress encryption key */
- if (!_switches[SHOWKEYS_ARG] &&
- !strcmp(target_type, "crypt")) {
- c = params;
- while (*c && *c != ' ')
- c++;
- c++;
- while (*c && *c != ' ')
- *c++ = '0';
- }
+ /* Suppress encryption key */
+ if (!_switches[SHOWKEYS_ARG] &&
+ cmd == DM_DEVICE_TABLE &&
+ !strcmp(target_type, "crypt")) {
+ c = params;
+ while (*c && *c != ' ')
+ c++;
+ if (*c)
+ c++;
+ while (*c && *c != ' ')
+ *c++ = '0';
+ }
printf("%" PRIu64 " %" PRIu64 " %s %s",
start, length, target_type, params);
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-06-11 13:20 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-06-11 13:20 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-06-11 13:20:29
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Add capability for tree-based fields to dmsetup reports.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.183&r2=1.184
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.90&r2=1.91
--- device-mapper/WHATS_NEW 2007/04/27 20:09:08 1.183
+++ device-mapper/WHATS_NEW 2007/06/11 13:20:28 1.184
@@ -1,5 +1,6 @@
Version 1.02.20 -
=================================
+ Add capability for tree-based fields to dmsetup reports.
Version 1.02.19 - 27th April 2007
=================================
--- device-mapper/dmsetup/dmsetup.c 2007/04/27 18:01:45 1.90
+++ device-mapper/dmsetup/dmsetup.c 2007/06/11 13:20:29 1.91
@@ -127,6 +127,12 @@
NUM_SWITCHES
};
+typedef enum {
+ DR_TASK = 1,
+ DR_INFO = 2,
+ DR_TREE = 8 /* Complete dependency tree required */
+} report_type_t;
+
static int _switches[NUM_SWITCHES];
static int _int_args[NUM_SWITCHES];
static char *_string_args[NUM_SWITCHES];
@@ -137,6 +143,7 @@
static char *_command;
static struct dm_tree *_dtree;
static struct dm_report *_report;
+static report_type_t _report_type;
/*
* Commands
@@ -240,11 +247,13 @@
struct dmsetup_report_obj {
struct dm_task *task;
struct dm_info *info;
+ struct dm_tree_node *tree_node;
};
static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
{
struct dmsetup_report_obj obj;
+ int r = 0;
if (!info->exists) {
fprintf(stderr, "Device does not exist.\n");
@@ -254,10 +263,16 @@
obj.task = dmt;
obj.info = info;
+ if (_report_type & DR_TREE)
+ obj.tree_node = dm_tree_find_node(_dtree, info->major, info->minor);
+
if (!dm_report_object(_report, &obj))
- return 0;
+ goto out;
- return 1;
+ r = 1;
+
+ out:
+ return r;
}
static void _display_info_long(struct dm_task *dmt, struct dm_info *info)
@@ -1419,7 +1434,8 @@
/*
* Walk the dependency tree
*/
-static void _tree_walk_children(struct dm_tree_node *node, unsigned depth)
+static void _display_tree_walk_children(struct dm_tree_node *node,
+ unsigned depth)
{
struct dm_tree_node *child, *next_child;
void *handle = NULL;
@@ -1438,7 +1454,7 @@
next_child ? 0U : 1U, has_children);
if (has_children)
- _tree_walk_children(child, depth + 1);
+ _display_tree_walk_children(child, depth + 1);
first_child = 0;
}
@@ -1457,17 +1473,28 @@
/*
* Create and walk dependency tree
*/
-static int _tree(int argc, char **argv, void *data __attribute((unused)))
+static int _build_whole_deptree(void)
{
+ if (_dtree)
+ return 1;
+
if (!(_dtree = dm_tree_create()))
return 0;
- if (!_process_all(argc, argv, 0, _add_dep))
+ if (!_process_all(0, NULL, 0, _add_dep))
return 0;
- _tree_walk_children(dm_tree_find_node(_dtree, 0, 0), 0);
+ return 1;
+}
- dm_tree_free(_dtree);
+static int _display_tree(int argc __attribute((unused)),
+ char **argv __attribute((unused)),
+ void *data __attribute((unused)))
+{
+ if (!_build_whole_deptree())
+ return 0;
+
+ _display_tree_walk_children(dm_tree_find_node(_dtree, 0, 0), 0);
return 1;
}
@@ -1490,8 +1517,8 @@
static int _uint32_disp(struct dm_report *rh,
struct dm_pool *mem __attribute((unused)),
- struct dm_report_field *field, const void *data,
- void *private __attribute((unused)))
+ struct dm_report_field *field, const void *data,
+ void *private __attribute((unused)))
{
const uint32_t value = *(const int32_t *)data;
@@ -1539,8 +1566,16 @@
return dm_report_field_string(rh, field, &s);
}
-/* Report types */
-enum { DR_TASK = 1, DR_INFO = 2 };
+static int _dm_tree_parents_count_disp(struct dm_report *rh,
+ struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ struct dm_tree_node *node = (struct dm_tree_node *) data;
+ int num_parent = dm_tree_node_num_children(node, 1);
+
+ return dm_report_field_int(rh, field, &num_parent);
+}
static void *_task_get_obj(void *obj)
{
@@ -1552,9 +1587,15 @@
return ((struct dmsetup_report_obj *)obj)->info;
}
+static void *_tree_get_obj(void *obj)
+{
+ return ((struct dmsetup_report_obj *)obj)->tree_node;
+}
+
static const struct dm_report_object_type _report_types[] = {
{ DR_TASK, "Mapped Device Name", "", _task_get_obj },
{ DR_INFO, "Mapped Device Information", "", _info_get_obj },
+ { DR_TREE, "Mapped Device Dependency", "", _tree_get_obj },
{ 0, "", "", NULL },
};
@@ -1575,6 +1616,7 @@
FIELD_O(INFO, dm_info, NUM, "Open", open_count, 4, int32, "open", "Number of references to open device, if requested.")
FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "segments", "Number of segments in live table, if present.")
FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "events", "Number of most recent event.")
+FIELD_F(TREE, NUM, "#DevsUsing", 10, dm_tree_parents_count, "devs_using_count", "Number of devices using this one.")
{0, 0, 0, 0, "", "", NULL, NULL},
/* *INDENT-ON* */
};
@@ -1592,7 +1634,6 @@
const char *keys = "";
const char *separator = " ";
int aligned = 1, headings = 1, buffered = 0;
- uint32_t report_type = 0;
uint32_t flags = 0;
size_t len = 0;
int r = 0;
@@ -1646,10 +1687,15 @@
if (headings)
flags |= DM_REPORT_OUTPUT_HEADINGS;
- if (!(_report = dm_report_init(&report_type,
- _report_types, _report_fields,
- options, separator, flags, keys, NULL)))
+ if (!(_report = dm_report_init(&_report_type,
+ _report_types, _report_fields,
+ options, separator, flags, keys, NULL)))
+ goto out;
+
+ if ((_report_type & DR_TREE) && !_build_whole_deptree()) {
+ err("Internal device dependency tree creation failed.");
goto out;
+ }
r = 1;
@@ -1669,7 +1715,7 @@
(_switches[EXEC_ARG] && _command))
return _status(argc, argv, data);
else if ((_switches[TREE_ARG]))
- return _tree(argc, argv, data);
+ return _display_tree(argc, argv, data);
else
return _process_all(argc, argv, 0, _display_name);
}
@@ -2289,5 +2335,8 @@
dm_report_free(_report);
}
+ if (_dtree)
+ dm_tree_free(_dtree);
+
return r;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-06-15 18:20 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-06-15 18:20 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-06-15 18:20:29
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Fix default dmsetup report buffering and add --unbuffered.
Add tree-based and dependency fields to dmsetup reports.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.184&r2=1.185
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.91&r2=1.92
--- device-mapper/WHATS_NEW 2007/06/11 13:20:28 1.184
+++ device-mapper/WHATS_NEW 2007/06/15 18:20:28 1.185
@@ -1,6 +1,7 @@
Version 1.02.20 -
=================================
- Add capability for tree-based fields to dmsetup reports.
+ Fix default dmsetup report buffering and add --unbuffered.
+ Add tree-based and dependency fields to dmsetup reports.
Version 1.02.19 - 27th April 2007
=================================
--- device-mapper/dmsetup/dmsetup.c 2007/06/11 13:20:29 1.91
+++ device-mapper/dmsetup/dmsetup.c 2007/06/15 18:20:28 1.92
@@ -90,6 +90,11 @@
#define ARGS_MAX 256
#define LOOP_TABLE_SIZE (PATH_MAX + 255)
+/* FIXME Should be imported */
+#ifndef DM_MAX_TYPE_NAME
+# define DM_MAX_TYPE_NAME 16
+#endif
+
/* FIXME Should be elsewhere */
#define SECTOR_SHIFT 9L
#define DEV_PATH "/dev/"
@@ -121,6 +126,7 @@
TARGET_ARG,
TREE_ARG,
UID_ARG,
+ UNBUFFERED_ARG,
UUID_ARG,
VERBOSE_ARG,
VERSION_ARG,
@@ -130,6 +136,7 @@
typedef enum {
DR_TASK = 1,
DR_INFO = 2,
+ DR_DEPS = 4,
DR_TREE = 8 /* Complete dependency tree required */
} report_type_t;
@@ -247,9 +254,41 @@
struct dmsetup_report_obj {
struct dm_task *task;
struct dm_info *info;
+ struct dm_task *deps_task;
struct dm_tree_node *tree_node;
};
+static struct dm_task *_get_deps_task(int major, int minor)
+{
+ struct dm_task *dmt;
+ struct dm_info info;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
+ return NULL;
+
+ if (!dm_task_set_major(dmt, major) ||
+ !dm_task_set_minor(dmt, minor))
+ goto err;
+
+ if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
+ goto err;
+
+ if (!dm_task_run(dmt))
+ goto err;
+
+ if (!dm_task_get_info(dmt, &info))
+ goto err;
+
+ if (!info.exists)
+ goto err;
+
+ return dmt;
+
+ err:
+ dm_task_destroy(dmt);
+ return NULL;
+}
+
static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
{
struct dmsetup_report_obj obj;
@@ -262,16 +301,22 @@
obj.task = dmt;
obj.info = info;
+ obj.deps_task = NULL;
if (_report_type & DR_TREE)
obj.tree_node = dm_tree_find_node(_dtree, info->major, info->minor);
+ if (_report_type & DR_DEPS)
+ obj.deps_task = _get_deps_task(info->major, info->minor);
+
if (!dm_report_object(_report, &obj))
goto out;
r = 1;
out:
+ if (obj.deps_task)
+ dm_task_destroy(obj.deps_task);
return r;
}
@@ -1566,6 +1611,149 @@
return dm_report_field_string(rh, field, &s);
}
+static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field, const void *data,
+ void *private)
+{
+ char buf[DM_MAX_TYPE_NAME], *repstr;
+ struct dm_info *info = (struct dm_info *) data;
+
+ if (!dm_pool_begin_object(mem, 8)) {
+ log_error("dm_pool_begin_object failed");
+ return 0;
+ }
+
+ if (dm_snprintf(buf, sizeof(buf), "%d:%d",
+ info->major, info->minor) < 0) {
+ log_error("dm_pool_alloc failed");
+ goto out_abandon;
+ }
+
+ if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+
+ repstr = dm_pool_end_object(mem);
+ dm_report_field_set_value(field, repstr, repstr);
+ return 1;
+
+ out_abandon:
+ dm_pool_abandon_object(mem);
+ return 0;
+}
+
+static int _dm_tree_names(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field, const void *data,
+ void *private, unsigned inverted)
+{
+ struct dm_tree_node *node = (struct dm_tree_node *) data, *parent;
+ void *t = NULL;
+ const char *name;
+ int first_node = 1;
+ char *repstr;
+
+ if (!dm_pool_begin_object(mem, 16)) {
+ log_error("dm_pool_begin_object failed");
+ return 0;
+ }
+
+ while ((parent = dm_tree_next_child(&t, node, inverted))) {
+ name = dm_tree_node_get_name(parent);
+ if (!name || !*name)
+ continue;
+ if (!first_node && !dm_pool_grow_object(mem, ",", 1)) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+ if (!dm_pool_grow_object(mem, name, strlen(name))) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+ if (first_node)
+ first_node = 0;
+ }
+
+ if (!dm_pool_grow_object(mem, "\0", 1)) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+
+ repstr = dm_pool_end_object(mem);
+ dm_report_field_set_value(field, repstr, repstr);
+ return 1;
+
+ out_abandon:
+ dm_pool_abandon_object(mem);
+ return 0;
+}
+
+static int _dm_deps_names_disp(struct dm_report *rh,
+ struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ return _dm_tree_names(rh, mem, field, data, private, 0);
+}
+
+static int _dm_tree_parents_names_disp(struct dm_report *rh,
+ struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ return _dm_tree_names(rh, mem, field, data, private, 1);
+}
+
+static int _dm_tree_parents_devs_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ struct dm_tree_node *node = (struct dm_tree_node *) data, *parent;
+ void *t = NULL;
+ const struct dm_info *info;
+ int first_node = 1;
+ char buf[DM_MAX_TYPE_NAME], *repstr;
+
+ if (!dm_pool_begin_object(mem, 16)) {
+ log_error("dm_pool_begin_object failed");
+ return 0;
+ }
+
+ while ((parent = dm_tree_next_child(&t, node, 1))) {
+ info = dm_tree_node_get_info(parent);
+ if (!info->major && !info->minor)
+ continue;
+ if (!first_node && !dm_pool_grow_object(mem, ",", 1)) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+ if (dm_snprintf(buf, sizeof(buf), "%d:%d",
+ info->major, info->minor) < 0) {
+ log_error("dm_snprintf failed");
+ goto out_abandon;
+ }
+ if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+ if (first_node)
+ first_node = 0;
+ }
+
+ if (!dm_pool_grow_object(mem, "\0", 1)) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+
+ repstr = dm_pool_end_object(mem);
+ dm_report_field_set_value(field, repstr, repstr);
+ return 1;
+
+ out_abandon:
+ dm_pool_abandon_object(mem);
+ return 0;
+}
+
static int _dm_tree_parents_count_disp(struct dm_report *rh,
struct dm_pool *mem,
struct dm_report_field *field,
@@ -1577,6 +1765,50 @@
return dm_report_field_int(rh, field, &num_parent);
}
+static int _dm_deps_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field, const void *data,
+ void *private)
+{
+ struct dm_deps *deps = (struct dm_deps *) data;
+ int i;
+ char buf[DM_MAX_TYPE_NAME], *repstr;
+
+ if (!dm_pool_begin_object(mem, 16)) {
+ log_error("dm_pool_begin_object failed");
+ return 0;
+ }
+
+ for (i = 0; i < deps->count; i++) {
+ if (dm_snprintf(buf, sizeof(buf), "%d:%d",
+ (int) MAJOR(deps->device[i]),
+ (int) MINOR(deps->device[i])) < 0) {
+ log_error("dm_snprintf failed");
+ goto out_abandon;
+ }
+ if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+ if (i + 1 < deps->count && !dm_pool_grow_object(mem, ",", 1)) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+ }
+
+ if (!dm_pool_grow_object(mem, "\0", 1)) {
+ log_error("dm_pool_grow_object failed");
+ goto out_abandon;
+ }
+
+ repstr = dm_pool_end_object(mem);
+ dm_report_field_set_value(field, repstr, repstr);
+ return 1;
+
+ out_abandon:
+ dm_pool_abandon_object(mem);
+ return 0;
+}
+
static void *_task_get_obj(void *obj)
{
return ((struct dmsetup_report_obj *)obj)->task;
@@ -1587,6 +1819,11 @@
return ((struct dmsetup_report_obj *)obj)->info;
}
+static void *_deps_get_obj(void *obj)
+{
+ return dm_task_get_deps(((struct dmsetup_report_obj *)obj)->deps_task);
+}
+
static void *_tree_get_obj(void *obj)
{
return ((struct dmsetup_report_obj *)obj)->tree_node;
@@ -1595,7 +1832,8 @@
static const struct dm_report_object_type _report_types[] = {
{ DR_TASK, "Mapped Device Name", "", _task_get_obj },
{ DR_INFO, "Mapped Device Information", "", _info_get_obj },
- { DR_TREE, "Mapped Device Dependency", "", _tree_get_obj },
+ { DR_DEPS, "Mapped Device Relationship Information", "", _deps_get_obj },
+ { DR_TREE, "Mapped Device Relationship Information", "", _tree_get_obj },
{ 0, "", "", NULL },
};
@@ -1611,12 +1849,20 @@
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.")
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.")
FIELD_O(INFO, dm_info, NUM, "Min", minor, 3, int32, "minor", "Block device minor number.")
FIELD_O(INFO, dm_info, NUM, "Open", open_count, 4, int32, "open", "Number of references to open device, if requested.")
FIELD_O(INFO, dm_info, NUM, "Targ", target_count, 4, int32, "segments", "Number of segments in live table, if present.")
FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "events", "Number of most recent event.")
-FIELD_F(TREE, NUM, "#DevsUsing", 10, dm_tree_parents_count, "devs_using_count", "Number of devices using this one.")
+
+FIELD_O(DEPS, dm_deps, NUM, "#Devs", count, 5, int32, "device_count", "Number of devices used by this one.")
+FIELD_F(TREE, STR, "DevNames", 8, dm_deps_names, "devs_used", "List of names of mapped devices used by this one.")
+FIELD_F(DEPS, STR, "DevNos", 6, dm_deps, "devnos_used", "List of device numbers of devices used by this one.")
+
+FIELD_F(TREE, NUM, "#Refs", 5, dm_tree_parents_count, "device_ref_count", "Number of mapped devices referencing this one.")
+FIELD_F(TREE, STR, "RefNames", 8, dm_tree_parents_names, "names_using_dev", "List of names of mapped devices using this one.")
+FIELD_F(TREE, STR, "RefDevNos", 9, dm_tree_parents_devs, "devnos_using_dev", "List of device numbers of mapped devices using this one.")
{0, 0, 0, 0, "", "", NULL, NULL},
/* *INDENT-ON* */
};
@@ -1633,7 +1879,7 @@
char *options = (char *) default_report_options;
const char *keys = "";
const char *separator = " ";
- int aligned = 1, headings = 1, buffered = 0;
+ int aligned = 1, headings = 1, buffered = 1;
uint32_t flags = 0;
size_t len = 0;
int r = 0;
@@ -1645,6 +1891,9 @@
headings = 0;
}
+ if (_switches[UNBUFFERED_ARG])
+ buffered = 0;
+
if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) {
if (*_string_args[OPTIONS_ARG] != '+')
options = _string_args[OPTIONS_ARG];
@@ -2125,6 +2374,7 @@
{"tree", 0, &ind, TREE_ARG},
{"uid", 1, &ind, UID_ARG},
{"uuid", 1, &ind, UUID_ARG},
+ {"unbuffered", 0, &ind, UNBUFFERED_ARG},
{"verbose", 1, &ind, VERBOSE_ARG},
{"version", 0, &ind, VERSION_ARG},
{0, 0, 0, 0}
@@ -2256,6 +2506,8 @@
}
if ((ind == TREE_ARG))
_switches[TREE_ARG]++;
+ if ((ind == UNBUFFERED_ARG))
+ _switches[UNBUFFERED_ARG]++;
if ((ind == VERSION_ARG))
_switches[VERSION_ARG]++;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2007-06-19 15:47 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2007-06-19 15:47 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2007-06-19 15:47:21
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Fix dmsetup -o devno string termination. (1.02.20)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.187&r2=1.188
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.92&r2=1.93
--- device-mapper/WHATS_NEW 2007/06/15 20:49:30 1.187
+++ device-mapper/WHATS_NEW 2007/06/19 15:47:20 1.188
@@ -1,5 +1,6 @@
Version 1.02.21 -
================================
+ Fix dmsetup -o devno string termination. (1.02.20)
Version 1.02.20 - 15th June 2007
================================
--- device-mapper/dmsetup/dmsetup.c 2007/06/15 18:20:28 1.92
+++ device-mapper/dmsetup/dmsetup.c 2007/06/19 15:47:20 1.93
@@ -1629,7 +1629,7 @@
goto out_abandon;
}
- if (!dm_pool_grow_object(mem, buf, strlen(buf))) {
+ if (!dm_pool_grow_object(mem, buf, strlen(buf) + 1)) {
log_error("dm_pool_grow_object failed");
goto out_abandon;
}
@@ -1662,7 +1662,7 @@
name = dm_tree_node_get_name(parent);
if (!name || !*name)
continue;
- if (!first_node && !dm_pool_grow_object(mem, ",", 1)) {
+ if (!first_node && !dm_pool_grow_object(mem, ",", 2)) {
log_error("dm_pool_grow_object failed");
goto out_abandon;
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2008-04-21 11:59 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2008-04-21 11:59 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2008-04-21 11:59:22
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Add --prefixes to dmsetup
E.g. dmsetup info -c --prefixes
Again, might change the name of this option.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.229&r2=1.230
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.104&r2=1.105
--- device-mapper/WHATS_NEW 2008/04/20 00:11:07 1.229
+++ device-mapper/WHATS_NEW 2008/04/21 11:59:22 1.230
@@ -1,5 +1,6 @@
Version 1.02.26 -
=================================
+ Add --prefixes to dmsetup.
Add field name prefix option to reporting functions.
Calculate string size within dm_pool_grow_object.
--- device-mapper/dmsetup/dmsetup.c 2008/04/19 15:50:17 1.104
+++ device-mapper/dmsetup/dmsetup.c 2008/04/21 11:59:22 1.105
@@ -120,6 +120,7 @@
NOOPENCOUNT_ARG,
NOTABLE_ARG,
OPTIONS_ARG,
+ PREFIXES_ARG,
READAHEAD_ARG,
SEPARATOR_ARG,
SHOWKEYS_ARG,
@@ -1914,7 +1915,7 @@
char *options = (char *) default_report_options;
const char *keys = "";
const char *separator = " ";
- int aligned = 1, headings = 1, buffered = 1;
+ int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
uint32_t flags = 0;
size_t len = 0;
int r = 0;
@@ -1929,6 +1930,11 @@
if (_switches[UNBUFFERED_ARG])
buffered = 0;
+ if (_switches[PREFIXES_ARG]) {
+ aligned = 0;
+ field_prefixes = 1;
+ }
+
if (_switches[OPTIONS_ARG] && _string_args[OPTIONS_ARG]) {
if (*_string_args[OPTIONS_ARG] != '+')
options = _string_args[OPTIONS_ARG];
@@ -1971,6 +1977,9 @@
if (headings)
flags |= DM_REPORT_OUTPUT_HEADINGS;
+ if (field_prefixes)
+ flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
+
if (!(_report = dm_report_init(&_report_type,
_report_types, _report_fields,
options, separator, flags, keys, NULL)))
@@ -1981,6 +1990,9 @@
goto out;
}
+ if (field_prefixes)
+ dm_report_set_output_field_name_prefix(_report, "dm_");
+
r = 1;
out:
@@ -2047,7 +2059,7 @@
" [-r|--readonly] [--noopencount] [--nolockfs]\n"
" [--readahead [+]<sectors>|auto|none]\n"
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
- " [--noheadings] [--separator <separator>]\n\n");
+ " [--noheadings] [--prefixes] [--separator <separator>]\n\n");
for (i = 0; _commands[i].name; i++)
fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
fprintf(out, "\n<device> may be device name or -u <uuid> or "
@@ -2409,6 +2421,7 @@
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
{"notable", 0, &ind, NOTABLE_ARG},
{"options", 1, &ind, OPTIONS_ARG},
+ {"prefixes", 0, &ind, PREFIXES_ARG},
{"readahead", 1, &ind, READAHEAD_ARG},
{"separator", 1, &ind, SEPARATOR_ARG},
{"showkeys", 0, &ind, SHOWKEYS_ARG},
@@ -2543,6 +2556,8 @@
_switches[NOLOCKFS_ARG]++;
if ((ind == NOOPENCOUNT_ARG))
_switches[NOOPENCOUNT_ARG]++;
+ if ((ind == PREFIXES_ARG))
+ _switches[PREFIXES_ARG]++;
if ((ind == READAHEAD_ARG)) {
_switches[READAHEAD_ARG]++;
if (!strcasecmp(optarg, "auto"))
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2008-04-21 13:16 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2008-04-21 13:16 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2008-04-21 13:16:31
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
Add 3 new reporting colums: tables_loaded, readonly, suspended.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.230&r2=1.231
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.105&r2=1.106
--- device-mapper/WHATS_NEW 2008/04/21 11:59:22 1.230
+++ device-mapper/WHATS_NEW 2008/04/21 13:16:30 1.231
@@ -1,5 +1,6 @@
Version 1.02.26 -
=================================
+ Add tables_loaded, readonly and suspended columns to reports.
Add --prefixes to dmsetup.
Add field name prefix option to reporting functions.
Calculate string size within dm_pool_grow_object.
--- device-mapper/dmsetup/dmsetup.c 2008/04/21 11:59:22 1.105
+++ device-mapper/dmsetup/dmsetup.c 2008/04/21 13:16:30 1.106
@@ -1643,6 +1643,63 @@
return dm_report_field_string(rh, field, &s);
}
+static int _dm_info_table_loaded_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field,
+ const void *data,
+ void *private __attribute((unused)))
+{
+ const struct dm_info *info = data;
+
+ if (info->live_table) {
+ if (info->inactive_table)
+ dm_report_field_set_value(field, "Both", NULL);
+ else
+ dm_report_field_set_value(field, "Live", NULL);
+ return 1;
+ }
+
+ if (info->inactive_table)
+ dm_report_field_set_value(field, "Inactive", NULL);
+ else
+ dm_report_field_set_value(field, "None", NULL);
+
+ return 1;
+}
+
+static int _dm_info_suspended_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field,
+ const void *data,
+ void *private __attribute((unused)))
+{
+ const struct dm_info *info = data;
+
+ if (info->suspended)
+ dm_report_field_set_value(field, "Suspended", NULL);
+ else
+ dm_report_field_set_value(field, "", NULL);
+
+ return 1;
+}
+
+static int _dm_info_read_only_disp(struct dm_report *rh,
+ struct dm_pool *mem __attribute((unused)),
+ struct dm_report_field *field,
+ const void *data,
+ void *private __attribute((unused)))
+{
+ const struct dm_info *info = data;
+
+ if (info->read_only)
+ dm_report_field_set_value(field, "Read-only", NULL);
+ else
+ dm_report_field_set_value(field, "Writeable", NULL);
+
+ return 1;
+}
+
+
static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field, const void *data,
void *private)
@@ -1885,6 +1942,9 @@
FIELD_F(TASK, NUM, "RAhead", 6, dm_read_ahead, "read_ahead", "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, "Tables", 6, dm_info_table_loaded, "tables_loaded", "Which of the live and inactive table slots are filled.")
+FIELD_F(INFO, STR, "Suspended", 9, dm_info_suspended, "suspended", "Whether the device is suspended.")
+FIELD_F(INFO, STR, "Read-only", 9, dm_info_read_only, "readonly", "Whether the device is read-only or writeable.")
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.")
FIELD_O(INFO, dm_info, NUM, "Min", minor, 3, int32, "minor", "Block device minor number.")
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2008-06-06 18:53 agk
0 siblings, 0 replies; 12+ messages in thread
From: agk @ 2008-06-06 18:53 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: agk@sourceware.org 2008-06-06 18:53:08
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
change --prefixes to --nameprefixes
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.233&r2=1.234
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.107&r2=1.108
--- device-mapper/WHATS_NEW 2008/06/05 19:10:35 1.233
+++ device-mapper/WHATS_NEW 2008/06/06 18:53:08 1.234
@@ -5,7 +5,7 @@
Make dm_hash_iter safe against deletion.
Accept a NULL pointer to dm_free silently.
Add tables_loaded, readonly and suspended columns to reports.
- Add --prefixes to dmsetup.
+ Add --fieldprefixes to dmsetup.
Add field name prefix option to reporting functions.
Calculate string size within dm_pool_grow_object.
--- device-mapper/dmsetup/dmsetup.c 2008/04/21 16:57:11 1.107
+++ device-mapper/dmsetup/dmsetup.c 2008/06/06 18:53:08 1.108
@@ -114,13 +114,13 @@
MAJOR_ARG,
MINOR_ARG,
MODE_ARG,
+ NAMEPREFIXES_ARG,
NOFLUSH_ARG,
NOHEADINGS_ARG,
NOLOCKFS_ARG,
NOOPENCOUNT_ARG,
NOTABLE_ARG,
OPTIONS_ARG,
- PREFIXES_ARG,
READAHEAD_ARG,
SEPARATOR_ARG,
SHOWKEYS_ARG,
@@ -1990,7 +1990,7 @@
if (_switches[UNBUFFERED_ARG])
buffered = 0;
- if (_switches[PREFIXES_ARG]) {
+ if (_switches[NAMEPREFIXES_ARG]) {
aligned = 0;
field_prefixes = 1;
}
@@ -2119,7 +2119,7 @@
" [-r|--readonly] [--noopencount] [--nolockfs]\n"
" [--readahead [+]<sectors>|auto|none]\n"
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
- " [--noheadings] [--prefixes] [--separator <separator>]\n\n");
+ " [--nameprefixes] [--noheadings] [--separator <separator>]\n\n");
for (i = 0; _commands[i].name; i++)
fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
fprintf(out, "\n<device> may be device name or -u <uuid> or "
@@ -2475,13 +2475,13 @@
{"major", 1, &ind, MAJOR_ARG},
{"minor", 1, &ind, MINOR_ARG},
{"mode", 1, &ind, MODE_ARG},
+ {"nameprefixes", 0, &ind, NAMEPREFIXES_ARG},
{"noflush", 0, &ind, NOFLUSH_ARG},
{"noheadings", 0, &ind, NOHEADINGS_ARG},
{"nolockfs", 0, &ind, NOLOCKFS_ARG},
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
{"notable", 0, &ind, NOTABLE_ARG},
{"options", 1, &ind, OPTIONS_ARG},
- {"prefixes", 0, &ind, PREFIXES_ARG},
{"readahead", 1, &ind, READAHEAD_ARG},
{"separator", 1, &ind, SEPARATOR_ARG},
{"showkeys", 0, &ind, SHOWKEYS_ARG},
@@ -2608,6 +2608,8 @@
_switches[TARGET_ARG]++;
_target = optarg;
}
+ if ((ind == NAMEPREFIXES_ARG))
+ _switches[NAMEPREFIXES_ARG]++;
if ((ind == NOFLUSH_ARG))
_switches[NOFLUSH_ARG]++;
if ((ind == NOHEADINGS_ARG))
@@ -2616,8 +2618,6 @@
_switches[NOLOCKFS_ARG]++;
if ((ind == NOOPENCOUNT_ARG))
_switches[NOOPENCOUNT_ARG]++;
- if ((ind == PREFIXES_ARG))
- _switches[PREFIXES_ARG]++;
if ((ind == READAHEAD_ARG)) {
_switches[READAHEAD_ARG]++;
if (!strcasecmp(optarg, "auto"))
^ permalink raw reply [flat|nested] 12+ messages in thread
* device-mapper ./WHATS_NEW dmsetup/dmsetup.c
@ 2008-06-18 10:19 meyering
0 siblings, 0 replies; 12+ messages in thread
From: meyering @ 2008-06-18 10:19 UTC (permalink / raw)
To: dm-cvs, dm-devel
CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: meyering@sourceware.org 2008-06-18 10:19:25
Modified files:
. : WHATS_NEW
dmsetup : dmsetup.c
Log message:
avoid compiler warning about cast in OFFSET_OF macro
* dmsetup/dmsetup.c (OFFSET_OF): Use an equivalent definition
that does not cast a pointer value to a narrower type.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.241&r2=1.242
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.108&r2=1.109
--- device-mapper/WHATS_NEW 2008/06/10 11:19:18 1.241
+++ device-mapper/WHATS_NEW 2008/06/18 10:19:25 1.242
@@ -1,5 +1,6 @@
Version 1.02.27 -
===============================
+ 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.)
Bring configure.in and list.h into line with the lvm2 versions.
--- device-mapper/dmsetup/dmsetup.c 2008/06/06 18:53:08 1.108
+++ device-mapper/dmsetup/dmsetup.c 2008/06/18 10:19:25 1.109
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
* Copyright (C) 2005-2007 NEC Corporation
*
* This file is part of the device-mapper userspace tools.
@@ -1927,7 +1927,7 @@
};
/* Column definitions */
-#define OFFSET_OF(strct, field) ((unsigned int) &((struct strct *)NULL)->field)
+#define OFFSET_OF(strct, field) (((char*)&((struct strct*)0)->field) - (char*)0)
#define STR (DM_REPORT_FIELD_TYPE_STRING)
#define NUM (DM_REPORT_FIELD_TYPE_NUMBER)
#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},
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-06-18 10:19 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-29 17:45 device-mapper ./WHATS_NEW dmsetup/dmsetup.c agk
-- strict thread matches above, loose matches on Subject: below --
2008-06-18 10:19 meyering
2008-06-06 18:53 agk
2008-04-21 13:16 agk
2008-04-21 11:59 agk
2007-06-19 15:47 agk
2007-06-15 18:20 agk
2007-06-11 13:20 agk
2007-04-27 15:12 agk
2007-01-29 18:18 agk
2007-01-24 18:09 agk
2006-10-19 15:34 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.