mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add --noheadings option to dmsetup -c for colon-separated output.
This commit is contained in:
parent
56f5c04d5b
commit
45ae32da38
@ -1,5 +1,6 @@
|
|||||||
Version 1.00.20 -
|
Version 1.00.20 -
|
||||||
=============================
|
=============================
|
||||||
|
Add --noheadings columns option for colon-separated dmsetup output.
|
||||||
Support device referencing by uuid or major/minor.
|
Support device referencing by uuid or major/minor.
|
||||||
Warn if kernel data didn't fit in buffer.
|
Warn if kernel data didn't fit in buffer.
|
||||||
Fix a printf.
|
Fix a printf.
|
||||||
|
@ -57,6 +57,7 @@ enum {
|
|||||||
COLS_ARG,
|
COLS_ARG,
|
||||||
MAJOR_ARG,
|
MAJOR_ARG,
|
||||||
MINOR_ARG,
|
MINOR_ARG,
|
||||||
|
NOHEADINGS_ARG,
|
||||||
NOTABLE_ARG,
|
NOTABLE_ARG,
|
||||||
UUID_ARG,
|
UUID_ARG,
|
||||||
VERBOSE_ARG,
|
VERBOSE_ARG,
|
||||||
@ -125,6 +126,27 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
|||||||
return r;
|
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);
|
||||||
|
|
||||||
|
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 : "");
|
||||||
|
}
|
||||||
|
|
||||||
static void _display_info_cols(struct dm_task *dmt, struct dm_info *info)
|
static void _display_info_cols(struct dm_task *dmt, struct dm_info *info)
|
||||||
{
|
{
|
||||||
static int _headings = 0;
|
static int _headings = 0;
|
||||||
@ -201,10 +223,12 @@ static void _display_info(struct dm_task *dmt)
|
|||||||
if (!dm_task_get_info(dmt, &info))
|
if (!dm_task_get_info(dmt, &info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_switches[COLS_ARG])
|
if (!_switches[COLS_ARG])
|
||||||
_display_info_cols(dmt, &info);
|
|
||||||
else
|
|
||||||
_display_info_long(dmt, &info);
|
_display_info_long(dmt, &info);
|
||||||
|
else if (_switches[NOHEADINGS_ARG])
|
||||||
|
_display_info_cols_noheadings(dmt, &info);
|
||||||
|
else
|
||||||
|
_display_info_cols(dmt, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
|
static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
|
||||||
@ -844,10 +868,11 @@ static int _process_switches(int *argc, char ***argv)
|
|||||||
|
|
||||||
#ifdef HAVE_GETOPTLONG
|
#ifdef HAVE_GETOPTLONG
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"columns", 0, NULL, COLS_ARG},
|
|
||||||
{"readonly", 0, NULL, READ_ONLY},
|
{"readonly", 0, NULL, READ_ONLY},
|
||||||
|
{"columns", 0, NULL, COLS_ARG},
|
||||||
{"major", 1, NULL, MAJOR_ARG},
|
{"major", 1, NULL, MAJOR_ARG},
|
||||||
{"minor", 1, NULL, MINOR_ARG},
|
{"minor", 1, NULL, MINOR_ARG},
|
||||||
|
{"noheadings", 0, NULL, NOHEADINGS_ARG},
|
||||||
{"notable", 0, NULL, NOTABLE_ARG},
|
{"notable", 0, NULL, NOTABLE_ARG},
|
||||||
{"uuid", 1, NULL, UUID_ARG},
|
{"uuid", 1, NULL, UUID_ARG},
|
||||||
{"verbose", 1, NULL, VERBOSE_ARG},
|
{"verbose", 1, NULL, VERBOSE_ARG},
|
||||||
@ -888,6 +913,8 @@ static int _process_switches(int *argc, char ***argv)
|
|||||||
_switches[UUID_ARG]++;
|
_switches[UUID_ARG]++;
|
||||||
_uuid = optarg;
|
_uuid = optarg;
|
||||||
}
|
}
|
||||||
|
if ((ind == NOHEADINGS_ARG))
|
||||||
|
_switches[NOHEADINGS_ARG]++;
|
||||||
if ((ind == VERSION_ARG))
|
if ((ind == VERSION_ARG))
|
||||||
_switches[VERSION_ARG]++;
|
_switches[VERSION_ARG]++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user