mirror of
git://sourceware.org/git/lvm2.git
synced 2025-12-25 20:23:49 +03:00
Compare commits
12 Commits
dm_v1_02_0
...
old-v2_02_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f08b98d2 | ||
|
|
8607a74206 | ||
|
|
8339f3ceb3 | ||
|
|
c0c9f3cc19 | ||
|
|
81f4813c29 | ||
|
|
94f57745b9 | ||
|
|
54fb2ebbe0 | ||
|
|
02d122b65b | ||
|
|
df0a5561a1 | ||
|
|
f7c55da7d0 | ||
|
|
b385f701ce | ||
|
|
05dd42f443 |
@@ -1,3 +1,12 @@
|
||||
Version 2.02.08 - 15th August 2006
|
||||
==================================
|
||||
Add checks for duplicate LV name, lvid and PV id before writing metadata.
|
||||
Report all sanity check failures, not just the first.
|
||||
Fix missing lockfs on first snapshot creation.
|
||||
Add unreliable --trustcache option to reporting commands.
|
||||
Fix locking for mimage removal.
|
||||
Fix clvmd_init_rhel4 'status' exit code.
|
||||
|
||||
Version 2.02.07 - 17th July 2006
|
||||
================================
|
||||
Fix activation logic in lvchange --persistent.
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
Version 1.02.10 -
|
||||
==============================
|
||||
|
||||
Version 1.02.09 - 15 Aug 2006
|
||||
==============================
|
||||
Add --table argument to dmsetup for a one-line table.
|
||||
Abort if errors are found during cmdline option processing.
|
||||
Add lockfs indicator to debug output.
|
||||
|
||||
Version 1.02.08 - 17 July 2006
|
||||
==============================
|
||||
Append full patch to check in emails.
|
||||
|
||||
@@ -528,7 +528,7 @@ static int _lv_deactivate(struct logical_volume *lv)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _lv_suspend_lv(struct logical_volume *lv)
|
||||
static int _lv_suspend_lv(struct logical_volume *lv, int lockfs)
|
||||
{
|
||||
int r;
|
||||
struct dev_manager *dm;
|
||||
@@ -536,7 +536,7 @@ static int _lv_suspend_lv(struct logical_volume *lv)
|
||||
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
|
||||
return_0;
|
||||
|
||||
if (!(r = dev_manager_suspend(dm, lv)))
|
||||
if (!(r = dev_manager_suspend(dm, lv, lockfs)))
|
||||
stack;
|
||||
|
||||
dev_manager_destroy(dm);
|
||||
@@ -637,6 +637,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
{
|
||||
struct logical_volume *lv, *lv_pre;
|
||||
struct lvinfo info;
|
||||
int lockfs = 0;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -672,7 +673,11 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
stack;
|
||||
|
||||
memlock_inc();
|
||||
if (!_lv_suspend_lv(lv)) {
|
||||
|
||||
if (lv_is_origin(lv_pre) || lv_is_cow(lv_pre))
|
||||
lockfs = 1;
|
||||
|
||||
if (!_lv_suspend_lv(lv, lockfs)) {
|
||||
memlock_dec();
|
||||
fs_unlock();
|
||||
return 0;
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef enum {
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
SUSPEND,
|
||||
SUSPEND_WITH_LOCKFS,
|
||||
CLEAN
|
||||
} action_t;
|
||||
|
||||
@@ -984,8 +985,8 @@ static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, actio
|
||||
goto_out;
|
||||
break;
|
||||
case SUSPEND:
|
||||
if (!lv_is_origin(lv) && !lv_is_cow(lv))
|
||||
dm_tree_skip_lockfs(root);
|
||||
dm_tree_skip_lockfs(root);
|
||||
case SUSPEND_WITH_LOCKFS:
|
||||
if (!dm_tree_suspend_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1))
|
||||
goto_out;
|
||||
break;
|
||||
@@ -1049,9 +1050,10 @@ int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv)
|
||||
return r;
|
||||
}
|
||||
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv)
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
|
||||
int lockfs)
|
||||
{
|
||||
return _tree_action(dm, lv, SUSPEND);
|
||||
return _tree_action(dm, lv, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -47,7 +47,8 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
int dev_manager_mirror_percent(struct dev_manager *dm,
|
||||
struct logical_volume *lv, int wait,
|
||||
float *percent, uint32_t *event_nr);
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
|
||||
int lockfs);
|
||||
int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv);
|
||||
int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv);
|
||||
|
||||
2
lib/cache/lvmcache.c
vendored
2
lib/cache/lvmcache.c
vendored
@@ -241,7 +241,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1: 0))) {
|
||||
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1 : 0))) {
|
||||
log_error("dev_iter creation failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -645,8 +645,7 @@ struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (dev_scan) {
|
||||
if (dev_scan && !trust_cache()) {
|
||||
/* Flag gets reset between each command */
|
||||
if (!full_scan_done())
|
||||
persistent_filter_wipe(f); /* Calls _full_scan(1) */
|
||||
|
||||
@@ -458,7 +458,7 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
|
||||
|
||||
/*
|
||||
* Build a list of pv_d's structures, allocated from mem.
|
||||
* We keep track of the first object allocated form the pool
|
||||
* We keep track of the first object allocated from the pool
|
||||
* so we can free off all the memory if something goes wrong.
|
||||
*/
|
||||
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
|
||||
|
||||
@@ -32,6 +32,7 @@ static int _partial = 0;
|
||||
static int _md_filtering = 0;
|
||||
static int _pvmove = 0;
|
||||
static int _full_scan_done = 0; /* Restrict to one full scan during each cmd */
|
||||
static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
|
||||
static int _debug_level = 0;
|
||||
static int _syslog = 0;
|
||||
static int _log_to_file = 0;
|
||||
@@ -163,6 +164,11 @@ void init_full_scan_done(int level)
|
||||
_full_scan_done = level;
|
||||
}
|
||||
|
||||
void init_trust_cache(int trustcache)
|
||||
{
|
||||
_trust_cache = trustcache;
|
||||
}
|
||||
|
||||
void init_ignorelockingfailure(int level)
|
||||
{
|
||||
_ignorelockingfailure = level;
|
||||
@@ -237,6 +243,11 @@ int full_scan_done()
|
||||
return _full_scan_done;
|
||||
}
|
||||
|
||||
int trust_cache()
|
||||
{
|
||||
return _trust_cache;
|
||||
}
|
||||
|
||||
int lockingfailed()
|
||||
{
|
||||
return _lockingfailed;
|
||||
|
||||
@@ -66,6 +66,7 @@ void init_partial(int level);
|
||||
void init_md_filtering(int level);
|
||||
void init_pvmove(int level);
|
||||
void init_full_scan_done(int level);
|
||||
void init_trust_cache(int trustcache);
|
||||
void init_debug(int level);
|
||||
void init_cmd_name(int status);
|
||||
void init_msg_prefix(const char *prefix);
|
||||
@@ -83,6 +84,7 @@ int partial_mode(void);
|
||||
int md_filtering(void);
|
||||
int pvmove_mode(void);
|
||||
int full_scan_done(void);
|
||||
int trust_cache(void);
|
||||
int debug_level(void);
|
||||
int ignorelockingfailure(void);
|
||||
int lockingfailed(void);
|
||||
|
||||
@@ -722,23 +722,68 @@ int vg_remove(struct volume_group *vg)
|
||||
|
||||
int vg_validate(struct volume_group *vg)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
struct pv_list *pvl, *pvl2;
|
||||
struct lv_list *lvl, *lvl2;
|
||||
char uuid[64];
|
||||
int r = 1;
|
||||
|
||||
list_iterate_items(pvl, &vg->pvs) {
|
||||
list_iterate_items(pvl2, &vg->pvs) {
|
||||
if (pvl == pvl2)
|
||||
break;
|
||||
if (id_equal(&pvl->pv->id,
|
||||
&pvl2->pv->id)) {
|
||||
if (!id_write_format(&pvl->pv->id, uuid,
|
||||
sizeof(uuid)))
|
||||
stack;
|
||||
log_error("Internal error: Duplicate PV id "
|
||||
"%s detected for %s in %s.",
|
||||
uuid, dev_name(pvl->pv->dev),
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!check_pv_segments(vg)) {
|
||||
log_error("Internal error: PV segments corrupted in %s.",
|
||||
vg->name);
|
||||
return 0;
|
||||
r = 0;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
list_iterate_items(lvl2, &vg->lvs) {
|
||||
if (lvl == lvl2)
|
||||
break;
|
||||
if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
|
||||
log_error("Internal error: Duplicate LV name "
|
||||
"%s detected in %s.", lvl->lv->name,
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
if (id_equal(&lvl->lv->lvid.id[1],
|
||||
&lvl2->lv->lvid.id[1])) {
|
||||
if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
|
||||
sizeof(uuid)))
|
||||
stack;
|
||||
log_error("Internal error: Duplicate LV id "
|
||||
"%s detected for %s and %s in %s.",
|
||||
uuid, lvl->lv->name, lvl2->lv->name,
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!check_lv_segments(lvl->lv, 1)) {
|
||||
log_error("Internal error: LV segments corrupted in %s.",
|
||||
lvl->lv->name);
|
||||
return 0;
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -199,6 +199,12 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
|
||||
/* Delete the 'orphan' LVs */
|
||||
for (m = num_mirrors; m < old_area_count; m++) {
|
||||
/* LV is now independent of the mirror so must acquire lock. */
|
||||
if (!activate_lv(mirrored_seg->lv->vg->cmd, seg_lv(mirrored_seg, m))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!deactivate_lv(mirrored_seg->lv->vg->cmd, seg_lv(mirrored_seg, m))) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -211,6 +217,11 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
}
|
||||
|
||||
if (lv1) {
|
||||
if (!activate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!deactivate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -223,6 +234,11 @@ int remove_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors,
|
||||
}
|
||||
|
||||
if (log_lv) {
|
||||
if (!activate_lv(mirrored_seg->lv->vg->cmd, log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!deactivate_lv(mirrored_seg->lv->vg->cmd, log_lv)) {
|
||||
stack;
|
||||
return 0;
|
||||
|
||||
@@ -1543,7 +1543,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||
dmi->flags |= DM_SKIP_BDGET_FLAG;
|
||||
|
||||
log_debug("dm %s %s %s%s%s %s%.0d%s%.0d%s"
|
||||
"%s%c %.0llu %s [%u]",
|
||||
"%s%c%s %.0llu %s [%u]",
|
||||
_cmd_data_v4[dmt->type].name,
|
||||
dmi->name, dmi->uuid, dmt->newname ? " " : "",
|
||||
dmt->newname ? dmt->newname : "",
|
||||
@@ -1554,6 +1554,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||
dmt->major > 0 && dmt->minor == 0 ? "0" : "",
|
||||
dmt->major > 0 ? ") " : "",
|
||||
dmt->no_open_count ? 'N' : 'O',
|
||||
dmt->skip_lockfs ? "S " : "",
|
||||
dmt->sector, dmt->message ? dmt->message : "",
|
||||
dmi->data_size);
|
||||
#ifdef DM_IOCTLS
|
||||
|
||||
@@ -4,7 +4,7 @@ dmsetup \- low level logical volume management
|
||||
.SH SYNOPSIS
|
||||
.ad l
|
||||
.B dmsetup create
|
||||
.I device_name [-u uuid] [--notable] [table_file]
|
||||
.I device_name [-u uuid] [--notable | --table <table> | table_file]
|
||||
.br
|
||||
.B dmsetup remove
|
||||
.I [-f|--force] device_name
|
||||
@@ -19,13 +19,13 @@ dmsetup \- low level logical volume management
|
||||
.I device_name
|
||||
.br
|
||||
.B dmsetup load
|
||||
.I device_name [table_file]
|
||||
.I device_name [--table <table> | table_file]
|
||||
.br
|
||||
.B dmsetup clear
|
||||
.I device_name
|
||||
.br
|
||||
.B dmsetup reload
|
||||
.I device_name [table_file]
|
||||
.I device_name [--table <table> | table_file]
|
||||
.br
|
||||
.B dmsetup rename
|
||||
.I device_name new_name
|
||||
@@ -101,6 +101,9 @@ Specify which fields to display. Only \fB-o\ name\fP is supported.
|
||||
.IP \fB-r|--readonly
|
||||
.br
|
||||
Set the table being loaded read-only.
|
||||
.IP \fB--table\ <table>
|
||||
.br
|
||||
Specify a one-line table directly on the command line.
|
||||
.IP \fB-u|--uuid
|
||||
.br
|
||||
Specify the uuid.
|
||||
@@ -112,10 +115,10 @@ Produce additional output.
|
||||
Display the library and kernel driver version.
|
||||
.SH COMMANDS
|
||||
.IP \fBcreate
|
||||
.I device_name [-u uuid] [--notable] [table_file]
|
||||
.I device_name [-u uuid] [--notable | --table <table> | table_file]
|
||||
.br
|
||||
Creates a device with the given name.
|
||||
If table_file is supplied, the table is loaded and made live.
|
||||
If table_file or <table> is supplied, the table is loaded and made live.
|
||||
Otherwise a table is read from standard input unless --notable is used.
|
||||
The optional uuid can be used in place of
|
||||
device_name in subsequent dmsetup commands.
|
||||
@@ -160,10 +163,10 @@ device/nodevice; active, open, rw, uuid.
|
||||
Others specify how the tree is displayed:
|
||||
ascii, utf, vt100; compact, inverted, notrunc.
|
||||
.IP \fBload|reload
|
||||
.I device_name [table_file]
|
||||
.I device_name [--table <table> | table_file]
|
||||
.br
|
||||
Loads table_file into the inactive table slot for device_name.
|
||||
If table_file is not supplied, reads a table from standard input.
|
||||
Loads <table> or table_file into the inactive table slot for device_name.
|
||||
If neither is supplied, reads a table from standard input.
|
||||
.IP \fBmknodes
|
||||
.I [device_name]
|
||||
.br
|
||||
|
||||
@@ -119,9 +119,9 @@ case "$1" in
|
||||
|
||||
status)
|
||||
status clvmd
|
||||
rtrn=$?
|
||||
vols=$( $LVDISPLAY -C --nohead 2> /dev/null | awk '($3 ~ /....a./) {print $1}' )
|
||||
echo active volumes: ${vols:-"(none)"}
|
||||
rtrn=0
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@@ -49,6 +49,7 @@ arg(nosync_ARG, '\0', "nosync", NULL)
|
||||
arg(corelog_ARG, '\0', "corelog", NULL)
|
||||
arg(monitor_ARG, '\0', "monitor", yes_no_arg)
|
||||
arg(config_ARG, '\0', "config", string_arg)
|
||||
arg(trustcache_ARG, '\0', "trustcache", NULL)
|
||||
|
||||
/* Allow some variations */
|
||||
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
|
||||
|
||||
@@ -343,6 +343,7 @@ xx(lvs,
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--segments]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--trustcache]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
@@ -351,7 +352,7 @@ xx(lvs,
|
||||
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
|
||||
separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
|
||||
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(lvscan,
|
||||
"List all logical volumes in all volume groups",
|
||||
@@ -527,6 +528,7 @@ xx(pvs,
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--segments]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--trustcache]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
@@ -535,7 +537,7 @@ xx(pvs,
|
||||
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
|
||||
separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
|
||||
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(pvscan,
|
||||
"List all physical volumes",
|
||||
@@ -819,6 +821,7 @@ xx(vgs,
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--trustcache]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
@@ -827,7 +830,7 @@ xx(vgs,
|
||||
|
||||
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
|
||||
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG,
|
||||
sort_ARG, unbuffered_ARG, units_ARG)
|
||||
sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(vgscan,
|
||||
"Search for all volume groups",
|
||||
|
||||
114
tools/dmsetup.c
114
tools/dmsetup.c
@@ -98,6 +98,7 @@ enum {
|
||||
NOOPENCOUNT_ARG,
|
||||
NOTABLE_ARG,
|
||||
OPTIONS_ARG,
|
||||
TABLE_ARG,
|
||||
TARGET_ARG,
|
||||
TREE_ARG,
|
||||
UID_ARG,
|
||||
@@ -112,6 +113,7 @@ static int _values[NUM_SWITCHES];
|
||||
static int _num_devices;
|
||||
static char *_uuid;
|
||||
static char *_fields;
|
||||
static char *_table;
|
||||
static char *_target;
|
||||
static char *_command;
|
||||
static struct dm_tree *_dtree;
|
||||
@@ -119,17 +121,55 @@ static struct dm_tree *_dtree;
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
|
||||
int line)
|
||||
{
|
||||
char ttype[LINE_SIZE], *ptr, *comment;
|
||||
unsigned long long start, size;
|
||||
int n;
|
||||
|
||||
/* trim trailing space */
|
||||
for (ptr = buffer + strlen(buffer) - 1; ptr >= buffer; ptr--)
|
||||
if (!isspace((int) *ptr))
|
||||
break;
|
||||
ptr++;
|
||||
*ptr = '\0';
|
||||
|
||||
/* trim leading space */
|
||||
for (ptr = buffer; *ptr && isspace((int) *ptr); ptr++)
|
||||
;
|
||||
|
||||
if (!*ptr || *ptr == '#')
|
||||
return 1;
|
||||
|
||||
if (sscanf(ptr, "%llu %llu %s %n",
|
||||
&start, &size, ttype, &n) < 3) {
|
||||
err("Invalid format on line %d of table %s", line, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr += n;
|
||||
if ((comment = strchr(ptr, (int) '#')))
|
||||
*comment = '\0';
|
||||
|
||||
if (!dm_task_add_target(dmt, start, size, ttype, ptr))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _parse_file(struct dm_task *dmt, const char *file)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
size_t buffer_size = 0;
|
||||
char ttype[LINE_SIZE], *ptr, *comment;
|
||||
FILE *fp;
|
||||
unsigned long long start, size;
|
||||
int r = 0, n, line = 0;
|
||||
int r = 0, line = 0;
|
||||
|
||||
/* one-line table on cmdline */
|
||||
if (_table)
|
||||
return _parse_line(dmt, _table, "", ++line);
|
||||
|
||||
/* OK for empty stdin */
|
||||
|
||||
if (file) {
|
||||
if (!(fp = fopen(file, "r"))) {
|
||||
err("Couldn't open '%s' for reading", file);
|
||||
@@ -145,38 +185,13 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (fgets(buffer, (int) buffer_size, fp)) {
|
||||
while (fgets(buffer, (int) buffer_size, fp))
|
||||
#else
|
||||
while (getline(&buffer, &buffer_size, fp) > 0) {
|
||||
while (getline(&buffer, &buffer_size, fp) > 0)
|
||||
#endif
|
||||
line++;
|
||||
|
||||
/* trim trailing space */
|
||||
for (ptr = buffer + strlen(buffer) - 1; ptr >= buffer; ptr--)
|
||||
if (!isspace((int) *ptr))
|
||||
break;
|
||||
ptr++;
|
||||
*ptr = '\0';
|
||||
|
||||
/* trim leading space */
|
||||
for (ptr = buffer; *ptr && isspace((int) *ptr); ptr++) ;
|
||||
|
||||
if (!*ptr || *ptr == '#')
|
||||
continue;
|
||||
|
||||
if (sscanf(ptr, "%llu %llu %s %n",
|
||||
&start, &size, ttype, &n) < 3) {
|
||||
err("%s:%d Invalid format", file, line);
|
||||
if (!_parse_line(dmt, buffer, file ? : "on stdin", ++line))
|
||||
goto out;
|
||||
}
|
||||
|
||||
ptr += n;
|
||||
if ((comment = strchr(ptr, (int) '#')))
|
||||
*comment = '\0';
|
||||
|
||||
if (!dm_task_add_target(dmt, start, size, ttype, ptr))
|
||||
goto out;
|
||||
}
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
@@ -725,23 +740,23 @@ static int _error_device(int argc __attribute((unused)), char **argv __attribute
|
||||
|
||||
size = _get_device_size(name);
|
||||
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
|
||||
return 0;
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
|
||||
return 0;
|
||||
|
||||
if (!_set_task_device(dmt, name, 0))
|
||||
goto err;
|
||||
|
||||
if (!dm_task_add_target(dmt, 0, size, "error", ""))
|
||||
if (!dm_task_add_target(dmt, 0, size, "error", ""))
|
||||
goto err;
|
||||
|
||||
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
|
||||
goto err;
|
||||
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
|
||||
goto err;
|
||||
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto err;
|
||||
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
||||
goto err;
|
||||
|
||||
if (!dm_task_run(dmt))
|
||||
goto err;
|
||||
if (!dm_task_run(dmt))
|
||||
goto err;
|
||||
|
||||
if (!_simple(DM_DEVICE_RESUME, name, 0, 0)) {
|
||||
_simple(DM_DEVICE_CLEAR, name, 0, 0);
|
||||
@@ -1472,7 +1487,8 @@ struct command {
|
||||
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"
|
||||
"\t [-u|uuid <uuid>] [--notable] [<table_file>]",
|
||||
"\t [-u|uuid <uuid>]"
|
||||
"\t [--notable | --table <table> | <table_file>]",
|
||||
1, 2, _create},
|
||||
{"remove", "[-f|--force] <device>", 0, 1, _remove},
|
||||
{"remove_all", "[-f|--force]", 0, 0, _remove_all},
|
||||
@@ -1611,6 +1627,7 @@ static int _process_switches(int *argc, char ***argv)
|
||||
{"noopencount", 0, &ind, NOOPENCOUNT_ARG},
|
||||
{"notable", 0, &ind, NOTABLE_ARG},
|
||||
{"options", 1, &ind, OPTIONS_ARG},
|
||||
{"table", 1, &ind, TABLE_ARG},
|
||||
{"target", 1, &ind, TARGET_ARG},
|
||||
{"tree", 0, &ind, TREE_ARG},
|
||||
{"uid", 1, &ind, UID_ARG},
|
||||
@@ -1667,6 +1684,8 @@ static int _process_switches(int *argc, char ***argv)
|
||||
optind = OPTIND_INIT;
|
||||
while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfGj:m:Mno:ru:Uv",
|
||||
long_options, NULL)) != -1) {
|
||||
if (c == ':' || c == '?')
|
||||
return 0;
|
||||
if (c == 'c' || c == 'C' || ind == COLS_ARG)
|
||||
_switches[COLS_ARG]++;
|
||||
if (c == 'f' || ind == FORCE_ARG)
|
||||
@@ -1720,6 +1739,10 @@ static int _process_switches(int *argc, char ***argv)
|
||||
_switches[NOLOCKFS_ARG]++;
|
||||
if ((ind == NOOPENCOUNT_ARG))
|
||||
_switches[NOOPENCOUNT_ARG]++;
|
||||
if ((ind == TABLE_ARG)) {
|
||||
_switches[TABLE_ARG]++;
|
||||
_table = optarg;
|
||||
}
|
||||
if ((ind == TREE_ARG))
|
||||
_switches[TREE_ARG]++;
|
||||
if ((ind == VERSION_ARG))
|
||||
@@ -1745,6 +1768,11 @@ static int _process_switches(int *argc, char ***argv)
|
||||
if (_switches[TREE_ARG] && !_process_tree_options(_fields))
|
||||
return 0;
|
||||
|
||||
if (_switches[TABLE_ARG] && _switches[NOTABLE_ARG]) {
|
||||
fprintf(stderr, "--table and --notable are incompatible.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*argv += optind;
|
||||
*argc -= optind;
|
||||
return 1;
|
||||
@@ -1755,7 +1783,7 @@ int main(int argc, char **argv)
|
||||
struct command *c;
|
||||
int r = 1;
|
||||
|
||||
(void) setlocale(LC_ALL, "");
|
||||
(void) setlocale(LC_ALL, "");
|
||||
|
||||
if (!_process_switches(&argc, &argv)) {
|
||||
fprintf(stderr, "Couldn't process command line.\n");
|
||||
|
||||
@@ -707,6 +707,17 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, trustcache_ARG)) {
|
||||
if (arg_count(cmd, all_ARG)) {
|
||||
log_error("--trustcache is incompatible with --all");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
init_trust_cache(1);
|
||||
log_print("WARNING: Cache file of PVs will be trusted. "
|
||||
"New devices holding PVs may get ignored.");
|
||||
} else
|
||||
init_trust_cache(0);
|
||||
|
||||
/* Handle synonyms */
|
||||
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
|
||||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||
|
||||
|
||||
Reference in New Issue
Block a user