From cd79e58eda05be577410400b1ab349719f7dc14b Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 29 Jan 2007 18:18:41 +0000 Subject: [PATCH] Add dmsetup 'help' command and update usage text. --- WHATS_NEW_DM | 1 + tools/dmsetup.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index c0c8dec08..89c436955 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -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 diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 772aead23..0aa18dd1c 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -1567,10 +1567,10 @@ static const struct dm_report_object_type _report_types[] = { 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 @@ static int _ls(int argc, char **argv, void *data) 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", " [-j|--major -m|--minor ]\n" "\t [-U|--uid ] [-G|--gid ] [-M|--mode ]\n" "\t [-u|uuid ]\n" @@ -1710,14 +1713,17 @@ static void _usage(FILE *out) 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 ] [--noheadings] [--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 may be device name or -u or " "-j -m \n"); + fprintf(out, " 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 @@ static void _losetup_usage(FILE *out) "[-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 @@ static int _process_switches(int *argc, char ***argv) 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;