mirror of
git://sourceware.org/git/lvm2.git
synced 2025-12-27 00:23:49 +03:00
Compare commits
12 Commits
dm_v1_02_1
...
dm_v1_02_1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94c5e7deb0 | ||
|
|
c344766f3c | ||
|
|
67895de0bc | ||
|
|
ff00cb6990 | ||
|
|
2cc75c11ed | ||
|
|
cd79e58eda | ||
|
|
6fa801f3d8 | ||
|
|
684eecba1d | ||
|
|
da9cf7e5de | ||
|
|
f57e7445fd | ||
|
|
fba1388719 | ||
|
|
80ed029c17 |
@@ -1,3 +1,8 @@
|
||||
Version 2.02.21 -
|
||||
===================================
|
||||
Fix vgs to treat args as VGs even when PV fields are displayed.
|
||||
Fix md signature check to handle both endiannesses.
|
||||
|
||||
Version 2.02.20 - 25th January 2007
|
||||
===================================
|
||||
dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors.
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
Version 1.02.17 - 29th January 2007
|
||||
===================================
|
||||
Add recent reporting options to dmsetup man page.
|
||||
Revise some report fields names.
|
||||
Add dmsetup 'help' command and update usage text.
|
||||
Use fixed-size fields in report interface and reorder.
|
||||
|
||||
Version 1.02.16 - 25th January 2007
|
||||
===================================
|
||||
Add some missing close() and fclose() return value checks.
|
||||
|
||||
@@ -53,8 +53,10 @@ int dev_is_md(struct device *dev, uint64_t *sb)
|
||||
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
|
||||
|
||||
/* Check if it is an md component device. */
|
||||
/* Version 1 is little endian; version 0.90.0 is machine endian */
|
||||
if (dev_read(dev, sb_offset, sizeof(uint32_t), &md_magic) &&
|
||||
(md_magic == xlate32(MD_SB_MAGIC))) {
|
||||
((md_magic == xlate32(MD_SB_MAGIC)) ||
|
||||
(md_magic == MD_SB_MAGIC))) {
|
||||
if (sb)
|
||||
*sb = sb_offset;
|
||||
ret = 1;
|
||||
|
||||
@@ -657,11 +657,11 @@ struct dm_report_field;
|
||||
struct dm_report;
|
||||
struct dm_report_field_type {
|
||||
uint32_t type; /* object type id */
|
||||
const char id[32]; /* string used to specify the field */
|
||||
unsigned int offset; /* byte offset in the object */
|
||||
const char heading[32]; /* string printed in header */
|
||||
int width; /* default width */
|
||||
uint32_t flags; /* DM_REPORT_FIELD_* */
|
||||
uint32_t offset; /* byte offset in the object */
|
||||
int32_t width; /* default width */
|
||||
const char id[32]; /* string used to specify the field */
|
||||
const char heading[32]; /* string printed in header */
|
||||
int (*report_fn)(struct dm_report *rh, struct dm_pool *mem,
|
||||
struct dm_report_field *field, const void *data,
|
||||
void *private);
|
||||
|
||||
@@ -60,7 +60,7 @@ struct field_properties {
|
||||
struct list list;
|
||||
uint32_t field_num;
|
||||
uint32_t sort_posn;
|
||||
unsigned width;
|
||||
int32_t width;
|
||||
const struct dm_report_object_type *type;
|
||||
uint32_t flags;
|
||||
};
|
||||
@@ -750,7 +750,7 @@ int dm_report_output(struct dm_report *rh)
|
||||
struct dm_report_field *field;
|
||||
const char *repstr;
|
||||
char buf[4096];
|
||||
unsigned width;
|
||||
int32_t width;
|
||||
uint32_t align;
|
||||
|
||||
if (list_empty(&rh->rows))
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
dmsetup \- low level logical volume management
|
||||
.SH SYNOPSIS
|
||||
.ad l
|
||||
.B dmsetup help
|
||||
.I [-c|-C|--columns]
|
||||
.br
|
||||
.B dmsetup create
|
||||
.I device_name [-u uuid] [--notable | --table <table> | table_file]
|
||||
.br
|
||||
@@ -33,21 +36,25 @@ dmsetup \- low level logical volume management
|
||||
.B dmsetup message
|
||||
.I device_name sector message
|
||||
.br
|
||||
.B dmsetup ls [--target target_type] [--exec command] [--tree [-o options]]
|
||||
.B dmsetup ls
|
||||
.I [--target target_type] [--exec command] [--tree [-o options]]
|
||||
.br
|
||||
.B dmsetup info
|
||||
.I [device_name]
|
||||
.br
|
||||
.B dmsetup info -c|-C|--columns [--noheadings] [-o name]
|
||||
.B dmsetup info -c|-C|--columns
|
||||
.I [--noheadings] [--separator separator] [-o fields] [-O|--sort sort_fields]
|
||||
.I [device_name]
|
||||
.br
|
||||
.B dmsetup deps
|
||||
.I [device_name]
|
||||
.br
|
||||
.B dmsetup status [--target target_type]
|
||||
.B dmsetup status
|
||||
.I [--target target_type]
|
||||
.I [device_name]
|
||||
.br
|
||||
.B dmsetup table [--target target_type]
|
||||
.B dmsetup table
|
||||
.I [--target target_type]
|
||||
.I [device_name]
|
||||
.br
|
||||
.B dmsetup wait
|
||||
@@ -103,7 +110,7 @@ Tell the kernel not to supply the open reference count for the device.
|
||||
When creating a device, don't load any table.
|
||||
.IP \fB-o|--options
|
||||
.br
|
||||
Specify which fields to display. Only \fB-o\ name\fP is supported.
|
||||
Specify which fields to display.
|
||||
.IP \fB-r|--readonly
|
||||
.br
|
||||
Set the table being loaded read-only.
|
||||
@@ -136,6 +143,11 @@ See below for information on the table format.
|
||||
.br
|
||||
Outputs a list of (major, minor) pairs for devices referenced by the
|
||||
live table for the specified device.
|
||||
.IP \fBhelp
|
||||
.I [-c|-C|--columns]
|
||||
.br
|
||||
Outputs a summary of the commands available, optionally including
|
||||
the list of report fields.
|
||||
.IP \fBinfo
|
||||
.I [device_name]
|
||||
.br
|
||||
@@ -154,6 +166,17 @@ Outputs some brief information about the device in the form:
|
||||
Number of targets in the live table
|
||||
.br
|
||||
UUID
|
||||
.IP \fBinfo -c|-C|--columns
|
||||
.I [--noheadings] [--separator separator] [-o fields] [-O|--sort sort_fields]
|
||||
.I [device_name]
|
||||
.br
|
||||
Output you can customise.
|
||||
Fields are comma-separated and chosen from the following list:
|
||||
name, major, minor, attr, open, segments, events, uuid.
|
||||
Attributes are: (L)ive, (I)nactive, (s)uspended, (r)ead-only, read-(w)rite.
|
||||
Precede the list with '+' to append
|
||||
to the default selection of columns instead of replacing it.
|
||||
Precede any sort_field with - for a reverse sort on that column.
|
||||
.IP \fBls
|
||||
.I [--target target_type]
|
||||
.I [--exec command]
|
||||
|
||||
@@ -1561,20 +1561,20 @@ static const struct dm_report_object_type _report_types[] = {
|
||||
#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* */
|
||||
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},
|
||||
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_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.")
|
||||
{0, 0, 0, 0, "", "", NULL, NULL},
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
@@ -1583,7 +1583,7 @@ FIELD_O(INFO, dm_info, NUM, "Event", event_nr, 6, uint32, "event_nr", "Current e
|
||||
#undef FIELD_O
|
||||
#undef FIELD_F
|
||||
|
||||
static const char *default_report_options = "name,major,minor,status,open_count,target_count,event_nr,uuid";
|
||||
static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
|
||||
|
||||
static int _report_init(struct command *c)
|
||||
{
|
||||
@@ -1625,7 +1625,7 @@ static int _report_init(struct command *c)
|
||||
if (_switches[SORT_ARG] && _string_args[SORT_ARG]) {
|
||||
keys = _string_args[SORT_ARG];
|
||||
buffered = 1;
|
||||
if (!strcmp(c->name, "status") || !strcmp(c->name, "table")) {
|
||||
if (c && (!strcmp(c->name, "status") || !strcmp(c->name, "table"))) {
|
||||
err("--sort is not yet supported with status and table");
|
||||
goto out;
|
||||
}
|
||||
@@ -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", "[-c|-C|--columns]", 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,18 @@ 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|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
|
||||
" [--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 'help -c' 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 +1735,23 @@ static void _losetup_usage(FILE *out)
|
||||
"[-o offset] [-f|loop_device] [file]\n\n");
|
||||
}
|
||||
|
||||
static int _help(int argc __attribute((unused)),
|
||||
char **argv __attribute((unused)),
|
||||
void *data __attribute((unused)))
|
||||
{
|
||||
_usage(stderr);
|
||||
|
||||
if (_switches[COLS_ARG]) {
|
||||
_switches[OPTIONS_ARG] = 1;
|
||||
_string_args[OPTIONS_ARG] = (char *) "help";
|
||||
_switches[SORT_ARG] = 0;
|
||||
|
||||
(void) _report_init(NULL);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct command *_find_command(const char *name)
|
||||
{
|
||||
int i;
|
||||
@@ -2096,7 +2120,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;
|
||||
|
||||
@@ -138,6 +138,30 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
|
||||
struct volume_group *vg, int consistent,
|
||||
void *handle)
|
||||
{
|
||||
if (!vg) {
|
||||
log_error("Volume group %s not found", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single);
|
||||
}
|
||||
|
||||
static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
|
||||
struct volume_group *vg, int consistent,
|
||||
void *handle)
|
||||
{
|
||||
if (!vg) {
|
||||
log_error("Volume group %s not found", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single);
|
||||
}
|
||||
|
||||
static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
report_type_t report_type)
|
||||
{
|
||||
@@ -146,8 +170,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
char *str;
|
||||
const char *keys = NULL, *options = NULL, *separator;
|
||||
int r = ECMD_PROCESSED;
|
||||
|
||||
int aligned, buffered, headings;
|
||||
unsigned args_are_pvs;
|
||||
|
||||
aligned = find_config_tree_int(cmd, "report/aligned",
|
||||
DEFAULT_REP_ALIGNED);
|
||||
@@ -158,6 +182,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
separator = find_config_tree_str(cmd, "report/separator",
|
||||
DEFAULT_REP_SEPARATOR);
|
||||
|
||||
args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0;
|
||||
|
||||
switch (report_type) {
|
||||
case LVS:
|
||||
keys = find_config_tree_str(cmd, "report/lvs_sort",
|
||||
@@ -292,16 +318,24 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
report_handle, &_vgs_single);
|
||||
break;
|
||||
case PVS:
|
||||
r = process_each_pv(cmd, argc, argv, NULL, report_handle,
|
||||
&_pvs_single);
|
||||
if (args_are_pvs)
|
||||
r = process_each_pv(cmd, argc, argv, NULL,
|
||||
report_handle, &_pvs_single);
|
||||
else
|
||||
r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0,
|
||||
report_handle, &_pvs_in_vg);
|
||||
break;
|
||||
case SEGS:
|
||||
r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvsegs_single);
|
||||
break;
|
||||
case PVSEGS:
|
||||
r = process_each_pv(cmd, argc, argv, NULL, report_handle,
|
||||
&_pvsegs_single);
|
||||
if (args_are_pvs)
|
||||
r = process_each_pv(cmd, argc, argv, NULL,
|
||||
report_handle, &_pvsegs_single);
|
||||
else
|
||||
r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0,
|
||||
report_handle, &_pvsegs_in_vg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user