mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Run through indent - no (intentional) changes to any code.
This commit is contained in:
parent
60274aba6e
commit
6fda126dd7
@ -16,7 +16,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int enabled;
|
int enabled;
|
||||||
char *dir;
|
char *dir;
|
||||||
@ -25,8 +24,7 @@ static struct {
|
|||||||
|
|
||||||
} _archive_params;
|
} _archive_params;
|
||||||
|
|
||||||
int archive_init(const char *dir,
|
int archive_init(const char *dir, unsigned int keep_days, unsigned int keep_min)
|
||||||
unsigned int keep_days, unsigned int keep_min)
|
|
||||||
{
|
{
|
||||||
_archive_params.dir = NULL;
|
_archive_params.dir = NULL;
|
||||||
|
|
||||||
@ -118,8 +116,6 @@ int archive_display(struct cmd_context *cmd, const char *vg_name)
|
|||||||
return archive_list(cmd, cmd->um, _archive_params.dir, vg_name);
|
return archive_list(cmd, cmd->um, _archive_params.dir, vg_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int enabled;
|
int enabled;
|
||||||
char *dir;
|
char *dir;
|
||||||
@ -232,8 +228,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
|
|||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
struct format_instance *tf;
|
struct format_instance *tf;
|
||||||
|
|
||||||
if (!(tf = text_format_create(cmd, file, cmd->um,
|
if (!(tf = text_format_create(cmd, file, cmd->um, cmd->cmd_line))) {
|
||||||
cmd->cmd_line))) {
|
|
||||||
log_error("Couldn't create text format object.");
|
log_error("Couldn't create text format object.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -245,7 +240,8 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
|
|||||||
return vg;
|
return vg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, const char *file)
|
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
|
||||||
|
const char *file)
|
||||||
{
|
{
|
||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ void backup_enable(int flag);
|
|||||||
int backup(struct volume_group *vg);
|
int backup(struct volume_group *vg);
|
||||||
int backup_remove(const char *vg_name);
|
int backup_remove(const char *vg_name);
|
||||||
|
|
||||||
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, const char *file);
|
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
|
||||||
|
const char *file);
|
||||||
int backup_restore(struct cmd_context *cmd, const char *vg_name);
|
int backup_restore(struct cmd_context *cmd, const char *vg_name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,4 +2,3 @@
|
|||||||
#define xx(a, b, c...) a
|
#define xx(a, b, c...) a
|
||||||
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
|
||||||
|
@ -21,17 +21,22 @@
|
|||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv);
|
static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv);
|
||||||
static int lvchange_permission(struct cmd_context *cmd, struct logical_volume *lv);
|
static int lvchange_permission(struct cmd_context *cmd,
|
||||||
static int lvchange_availability(struct cmd_context *cmd, struct logical_volume *lv);
|
struct logical_volume *lv);
|
||||||
static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *lv);
|
static int lvchange_availability(struct cmd_context *cmd,
|
||||||
static int lvchange_readahead(struct cmd_context *cmd, struct logical_volume *lv);
|
struct logical_volume *lv);
|
||||||
static int lvchange_persistent(struct cmd_context *cmd, struct logical_volume *lv);
|
static int lvchange_contiguous(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv);
|
||||||
|
static int lvchange_readahead(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv);
|
||||||
|
static int lvchange_persistent(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv);
|
||||||
|
|
||||||
int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (!arg_count(cmd,available_ARG) && !arg_count(cmd,contiguous_ARG)
|
if (!arg_count(cmd, available_ARG) && !arg_count(cmd, contiguous_ARG)
|
||||||
&& !arg_count(cmd,permission_ARG) && !arg_count(cmd,readahead_ARG)
|
&& !arg_count(cmd, permission_ARG) && !arg_count(cmd, readahead_ARG)
|
||||||
&& !arg_count(cmd,minor_ARG) && !arg_count(cmd,persistent_ARG)) {
|
&& !arg_count(cmd, minor_ARG) && !arg_count(cmd, persistent_ARG)) {
|
||||||
log_error("One or more of -a, -C, -m, -M, -p or -r required");
|
log_error("One or more of -a, -C, -m, -M, -p or -r required");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
@ -41,7 +46,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,minor_ARG) && argc != 1) {
|
if (arg_count(cmd, minor_ARG) && argc != 1) {
|
||||||
log_error("Only give one logical volume when specifying minor");
|
log_error("Only give one logical volume when specifying minor");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
@ -55,8 +60,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
int archived = 0;
|
int archived = 0;
|
||||||
|
|
||||||
if (!(lv->vg->status & LVM_WRITE) &&
|
if (!(lv->vg->status & LVM_WRITE) &&
|
||||||
(arg_count(cmd,contiguous_ARG) || arg_count(cmd,permission_ARG) ||
|
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
||||||
arg_count(cmd,readahead_ARG) || arg_count(cmd,persistent_ARG))) {
|
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG))) {
|
||||||
log_error("Only -a permitted with read-only volume "
|
log_error("Only -a permitted with read-only volume "
|
||||||
"group \"%s\"", lv->vg->name);
|
"group \"%s\"", lv->vg->name);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
@ -75,7 +80,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* access permission change */
|
/* access permission change */
|
||||||
if (arg_count(cmd,permission_ARG)) {
|
if (arg_count(cmd, permission_ARG)) {
|
||||||
if (!archive(lv->vg))
|
if (!archive(lv->vg))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
archived = 1;
|
archived = 1;
|
||||||
@ -83,7 +88,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocation policy change */
|
/* allocation policy change */
|
||||||
if (arg_count(cmd,contiguous_ARG)) {
|
if (arg_count(cmd, contiguous_ARG)) {
|
||||||
if (!archived && !archive(lv->vg))
|
if (!archived && !archive(lv->vg))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
archived = 1;
|
archived = 1;
|
||||||
@ -91,7 +96,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read ahead sector change */
|
/* read ahead sector change */
|
||||||
if (arg_count(cmd,readahead_ARG)) {
|
if (arg_count(cmd, readahead_ARG)) {
|
||||||
if (!archived && !archive(lv->vg))
|
if (!archived && !archive(lv->vg))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
archived = 1;
|
archived = 1;
|
||||||
@ -99,7 +104,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* read ahead sector change */
|
/* read ahead sector change */
|
||||||
if (arg_count(cmd,persistent_ARG)) {
|
if (arg_count(cmd, persistent_ARG)) {
|
||||||
if (!archived && !archive(lv->vg))
|
if (!archived && !archive(lv->vg))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
archived = 1;
|
archived = 1;
|
||||||
@ -110,38 +115,42 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
log_print("Logical volume \"%s\" changed", lv->name);
|
log_print("Logical volume \"%s\" changed", lv->name);
|
||||||
|
|
||||||
/* availability change */
|
/* availability change */
|
||||||
if (arg_count(cmd,available_ARG))
|
if (arg_count(cmd, available_ARG))
|
||||||
if (!lvchange_availability(cmd, lv))
|
if (!lvchange_availability(cmd, lv))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_permission(struct cmd_context *cmd, struct logical_volume *lv)
|
static int lvchange_permission(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
int lv_access;
|
int lv_access;
|
||||||
|
|
||||||
lv_access = arg_int_value(cmd,permission_ARG, 0);
|
lv_access = arg_int_value(cmd, permission_ARG, 0);
|
||||||
|
|
||||||
if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
|
if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
|
||||||
log_error("Logical volume \"%s\" is already writable", lv->name);
|
log_error("Logical volume \"%s\" is already writable",
|
||||||
|
lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(lv_access & LVM_WRITE) && !(lv->status & LVM_WRITE)) {
|
if (!(lv_access & LVM_WRITE) && !(lv->status & LVM_WRITE)) {
|
||||||
log_error("Logical volume \"%s\" is already read only", lv->name);
|
log_error("Logical volume \"%s\" is already read only",
|
||||||
|
lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lv_access & LVM_WRITE) {
|
if (lv_access & LVM_WRITE) {
|
||||||
lv->status |= LVM_WRITE;
|
lv->status |= LVM_WRITE;
|
||||||
log_verbose("Setting logical volume \"%s\" read/write", lv->name);
|
log_verbose("Setting logical volume \"%s\" read/write",
|
||||||
|
lv->name);
|
||||||
} else {
|
} else {
|
||||||
lv->status &= ~LVM_WRITE;
|
lv->status &= ~LVM_WRITE;
|
||||||
log_verbose("Setting logical volume \"%s\" read-only", lv->name);
|
log_verbose("Setting logical volume \"%s\" read-only",
|
||||||
|
lv->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||||
if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg))
|
if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg))
|
||||||
return 0;
|
return 0;
|
||||||
@ -155,16 +164,17 @@ static int lvchange_permission(struct cmd_context *cmd, struct logical_volume *l
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_availability(struct cmd_context *cmd, struct logical_volume *lv)
|
static int lvchange_availability(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
int activate = 0;
|
int activate = 0;
|
||||||
int active;
|
int active;
|
||||||
|
|
||||||
if (strcmp(arg_str_value(cmd,available_ARG, "n"), "n"))
|
if (strcmp(arg_str_value(cmd, available_ARG, "n"), "n"))
|
||||||
activate = 1;
|
activate = 1;
|
||||||
|
|
||||||
if (arg_count(cmd,minor_ARG)) {
|
if (arg_count(cmd, minor_ARG)) {
|
||||||
lv->minor = arg_int_value(cmd,minor_ARG, -1);
|
lv->minor = arg_int_value(cmd, minor_ARG, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((active = lv_active(lv)) < 0) {
|
if ((active = lv_active(lv)) < 0) {
|
||||||
@ -204,11 +214,12 @@ static int lvchange_availability(struct cmd_context *cmd, struct logical_volume
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *lv)
|
static int lvchange_contiguous(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
int lv_allocation = 0;
|
int lv_allocation = 0;
|
||||||
|
|
||||||
if (strcmp(arg_str_value(cmd,contiguous_ARG, "n"), "n"))
|
if (strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n"))
|
||||||
lv_allocation |= ALLOC_CONTIGUOUS;
|
lv_allocation |= ALLOC_CONTIGUOUS;
|
||||||
|
|
||||||
if ((lv_allocation & ALLOC_CONTIGUOUS) &&
|
if ((lv_allocation & ALLOC_CONTIGUOUS) &&
|
||||||
@ -220,7 +231,8 @@ static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *l
|
|||||||
|
|
||||||
if (!(lv_allocation & ALLOC_CONTIGUOUS) &&
|
if (!(lv_allocation & ALLOC_CONTIGUOUS) &&
|
||||||
!(lv->status & ALLOC_CONTIGUOUS)) {
|
!(lv->status & ALLOC_CONTIGUOUS)) {
|
||||||
log_error("Allocation policy of logical volume \"%s\" is already"
|
log_error
|
||||||
|
("Allocation policy of logical volume \"%s\" is already"
|
||||||
" not contiguous", lv->name);
|
" not contiguous", lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -252,11 +264,12 @@ static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *l
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_readahead(struct cmd_context *cmd, struct logical_volume *lv)
|
static int lvchange_readahead(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
int read_ahead = 0;
|
int read_ahead = 0;
|
||||||
|
|
||||||
read_ahead = arg_int_value(cmd,readahead_ARG, 0);
|
read_ahead = arg_int_value(cmd, readahead_ARG, 0);
|
||||||
|
|
||||||
/******* FIXME Ranges?
|
/******* FIXME Ranges?
|
||||||
if (read_ahead < LVM_MIN_READ_AHEAD || read_ahead > LVM_MAX_READ_AHEAD) {
|
if (read_ahead < LVM_MIN_READ_AHEAD || read_ahead > LVM_MAX_READ_AHEAD) {
|
||||||
@ -272,7 +285,8 @@ static int lvchange_readahead(struct cmd_context *cmd, struct logical_volume *lv
|
|||||||
}
|
}
|
||||||
|
|
||||||
lv->read_ahead = read_ahead;
|
lv->read_ahead = read_ahead;
|
||||||
log_verbose("Setting read ahead to %u for \"%s\"", read_ahead, lv->name);
|
log_verbose("Setting read ahead to %u for \"%s\"", read_ahead,
|
||||||
|
lv->name);
|
||||||
|
|
||||||
log_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
log_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
|
||||||
|
|
||||||
@ -284,9 +298,10 @@ static int lvchange_readahead(struct cmd_context *cmd, struct logical_volume *lv
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lvchange_persistent(struct cmd_context *cmd, struct logical_volume *lv)
|
static int lvchange_persistent(struct cmd_context *cmd,
|
||||||
|
struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
if (!strcmp(arg_str_value(cmd,persistent_ARG, "n"), "n")) {
|
if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "n")) {
|
||||||
if (!(lv->status & FIXED_MINOR)) {
|
if (!(lv->status & FIXED_MINOR)) {
|
||||||
log_error("Minor number is already not persistent "
|
log_error("Minor number is already not persistent "
|
||||||
"for \"%s\"", lv->name);
|
"for \"%s\"", lv->name);
|
||||||
@ -300,12 +315,12 @@ static int lvchange_persistent(struct cmd_context *cmd, struct logical_volume *l
|
|||||||
log_error("Cannot change minor number when active");
|
log_error("Cannot change minor number when active");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!arg_count(cmd,minor_ARG)) {
|
if (!arg_count(cmd, minor_ARG)) {
|
||||||
log_error("Minor number must be specified with -My");
|
log_error("Minor number must be specified with -My");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lv->status |= FIXED_MINOR;
|
lv->status |= FIXED_MINOR;
|
||||||
lv->minor = arg_int_value(cmd,minor_ARG, -1);
|
lv->minor = arg_int_value(cmd, minor_ARG, -1);
|
||||||
log_verbose("Setting persistent minor number to %d for \"%s\"",
|
log_verbose("Setting persistent minor number to %d for \"%s\"",
|
||||||
lv->minor, lv->name);
|
lv->minor, lv->name);
|
||||||
}
|
}
|
||||||
@ -319,4 +334,3 @@ static int lvchange_persistent(struct cmd_context *cmd, struct logical_volume *l
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,38 +28,38 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
char *vg_name;
|
char *vg_name;
|
||||||
char *st;
|
char *st;
|
||||||
|
|
||||||
if (arg_count(cmd,snapshot_ARG) || arg_count(cmd,chunksize_ARG)) {
|
if (arg_count(cmd, snapshot_ARG) || arg_count(cmd, chunksize_ARG)) {
|
||||||
log_error("Snapshots are not yet supported in LVM2.");
|
log_error("Snapshots are not yet supported in LVM2.");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mutually exclusive */
|
/* mutually exclusive */
|
||||||
if ((arg_count(cmd,zero_ARG) && arg_count(cmd,snapshot_ARG)) ||
|
if ((arg_count(cmd, zero_ARG) && arg_count(cmd, snapshot_ARG)) ||
|
||||||
(arg_count(cmd,extents_ARG) && arg_count(cmd,size_ARG))) {
|
(arg_count(cmd, extents_ARG) && arg_count(cmd, size_ARG))) {
|
||||||
log_error("Invalid combination of arguments");
|
log_error("Invalid combination of arguments");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,size_ARG) + arg_count(cmd,extents_ARG) == 0) {
|
if (arg_count(cmd, size_ARG) + arg_count(cmd, extents_ARG) == 0) {
|
||||||
log_error("Please indicate size using option -l or -L");
|
log_error("Please indicate size using option -l or -L");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(arg_str_value(cmd,contiguous_ARG, "n"), "n"))
|
if (strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n"))
|
||||||
status |= ALLOC_CONTIGUOUS;
|
status |= ALLOC_CONTIGUOUS;
|
||||||
else
|
else
|
||||||
status |= ALLOC_SIMPLE;
|
status |= ALLOC_SIMPLE;
|
||||||
|
|
||||||
zero = strcmp(arg_str_value(cmd,zero_ARG, "y"), "n");
|
zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||||
|
|
||||||
if (arg_count(cmd,stripes_ARG)) {
|
if (arg_count(cmd, stripes_ARG)) {
|
||||||
stripes = arg_int_value(cmd,stripes_ARG, 1);
|
stripes = arg_int_value(cmd, stripes_ARG, 1);
|
||||||
if (stripes == 1)
|
if (stripes == 1)
|
||||||
log_print("Redundant stripes argument: default is 1");
|
log_print("Redundant stripes argument: default is 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,stripesize_ARG))
|
if (arg_count(cmd, stripesize_ARG))
|
||||||
stripesize = 2 * arg_int_value(cmd,stripesize_ARG, 0);
|
stripesize = 2 * arg_int_value(cmd, stripesize_ARG, 0);
|
||||||
|
|
||||||
if (stripes == 1 && stripesize) {
|
if (stripes == 1 && stripesize) {
|
||||||
log_print("Ignoring stripesize argument with single stripe");
|
log_print("Ignoring stripesize argument with single stripe");
|
||||||
@ -71,23 +71,23 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
log_print("Using default stripesize %dKB", stripesize / 2);
|
log_print("Using default stripesize %dKB", stripesize / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,permission_ARG))
|
if (arg_count(cmd, permission_ARG))
|
||||||
status |= arg_int_value(cmd,permission_ARG, 0);
|
status |= arg_int_value(cmd, permission_ARG, 0);
|
||||||
else
|
else
|
||||||
status |= LVM_READ | LVM_WRITE;
|
status |= LVM_READ | LVM_WRITE;
|
||||||
|
|
||||||
if (arg_count(cmd,readahead_ARG))
|
if (arg_count(cmd, readahead_ARG))
|
||||||
read_ahead = arg_int_value(cmd,readahead_ARG, 0);
|
read_ahead = arg_int_value(cmd, readahead_ARG, 0);
|
||||||
|
|
||||||
if (arg_count(cmd,extents_ARG))
|
if (arg_count(cmd, extents_ARG))
|
||||||
extents = arg_int_value(cmd,extents_ARG, 0);
|
extents = arg_int_value(cmd, extents_ARG, 0);
|
||||||
|
|
||||||
/* Size returned in kilobyte units; held in sectors */
|
/* Size returned in kilobyte units; held in sectors */
|
||||||
if (arg_count(cmd,size_ARG))
|
if (arg_count(cmd, size_ARG))
|
||||||
size = arg_int_value(cmd,size_ARG, 0);
|
size = arg_int_value(cmd, size_ARG, 0);
|
||||||
|
|
||||||
if (arg_count(cmd,name_ARG))
|
if (arg_count(cmd, name_ARG))
|
||||||
lv_name = arg_value(cmd,name_ARG);
|
lv_name = arg_value(cmd, name_ARG);
|
||||||
|
|
||||||
/* If VG not on command line, try -n arg and then environment */
|
/* If VG not on command line, try -n arg and then environment */
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
@ -157,7 +157,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc && argc < stripes ) {
|
if (argc && argc < stripes) {
|
||||||
log_error("Too few physical volumes on "
|
log_error("Too few physical volumes on "
|
||||||
"command line for %d-way striping", stripes);
|
"command line for %d-way striping", stripes);
|
||||||
goto error_cmdline;
|
goto error_cmdline;
|
||||||
@ -178,8 +178,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
if (stripesize > vg->extent_size) {
|
if (stripesize > vg->extent_size) {
|
||||||
log_error("Setting stripe size %d KB to physical extent "
|
log_error("Setting stripe size %d KB to physical extent "
|
||||||
"size %u KB",
|
"size %u KB", stripesize / 2, vg->extent_size / 2);
|
||||||
stripesize / 2, vg->extent_size / 2);
|
|
||||||
stripesize = vg->extent_size;
|
stripesize = vg->extent_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,26 +209,24 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(lv = lv_create(cmd->fid, lv_name, status,
|
if (!(lv = lv_create(cmd->fid, lv_name, status,
|
||||||
stripes, stripesize, extents,
|
stripes, stripesize, extents, vg, pvh)))
|
||||||
vg, pvh)))
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (arg_count(cmd,readahead_ARG)) {
|
if (arg_count(cmd, readahead_ARG)) {
|
||||||
log_verbose("Setting read ahead sectors");
|
log_verbose("Setting read ahead sectors");
|
||||||
lv->read_ahead = read_ahead;
|
lv->read_ahead = read_ahead;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,minor_ARG)) {
|
if (arg_count(cmd, minor_ARG)) {
|
||||||
lv->status |= FIXED_MINOR;
|
lv->status |= FIXED_MINOR;
|
||||||
lv->minor = arg_int_value(cmd,minor_ARG, -1);
|
lv->minor = arg_int_value(cmd, minor_ARG, -1);
|
||||||
log_verbose("Setting minor number to %d", lv->minor);
|
log_verbose("Setting minor number to %d", lv->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,persistent_ARG)) {
|
if (arg_count(cmd, persistent_ARG)) {
|
||||||
if (!strcmp(arg_str_value(cmd,persistent_ARG, "n"), "n"))
|
if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "n"))
|
||||||
lv->status &= ~FIXED_MINOR;
|
lv->status &= ~FIXED_MINOR;
|
||||||
else
|
else if (!arg_count(cmd, minor_ARG)) {
|
||||||
if (!arg_count(cmd,minor_ARG)) {
|
|
||||||
log_error("Please specify minor number with "
|
log_error("Please specify minor number with "
|
||||||
"--minor when using -My");
|
"--minor when using -My");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
|
|
||||||
int lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv)
|
int lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv)
|
||||||
{
|
{
|
||||||
if (arg_count(cmd,colon_ARG))
|
if (arg_count(cmd, colon_ARG))
|
||||||
lvdisplay_colons(lv);
|
lvdisplay_colons(lv);
|
||||||
else {
|
else {
|
||||||
lvdisplay_full(cmd, lv);
|
lvdisplay_full(cmd, lv);
|
||||||
if (arg_count(cmd,maps_ARG))
|
if (arg_count(cmd, maps_ARG))
|
||||||
lvdisplay_segments(lv);
|
lvdisplay_segments(lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +37,10 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
{
|
{
|
||||||
/* FIXME Allow VG args via process_each */
|
/* FIXME Allow VG args via process_each */
|
||||||
|
|
||||||
if (arg_count(cmd,colon_ARG) && arg_count(cmd,verbose_ARG)) {
|
if (arg_count(cmd, colon_ARG) && arg_count(cmd, verbose_ARG)) {
|
||||||
log_error("Options -v and -c are incompatible");
|
log_error("Options -v and -c are incompatible");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_each_lv(cmd, argc, argv, &lvdisplay_single);
|
return process_each_lv(cmd, argc, argv, &lvdisplay_single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
64
tools/lvm.c
64
tools/lvm.c
@ -24,11 +24,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef READLINE_SUPPORT
|
#ifdef READLINE_SUPPORT
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
#ifndef HAVE_RL_COMPLETION_MATCHES
|
#ifndef HAVE_RL_COMPLETION_MATCHES
|
||||||
#define rl_completion_matches(a, b) completion_matches((char *)a, b)
|
#define rl_completion_matches(a, b) completion_matches((char *)a, b)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -42,7 +42,6 @@ struct arg the_args[ARG_COUNT + 1] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int _array_size;
|
static int _array_size;
|
||||||
static int _num_commands;
|
static int _num_commands;
|
||||||
static struct command *_commands;
|
static struct command *_commands;
|
||||||
@ -57,7 +56,6 @@ static FILE *_log;
|
|||||||
/* lvm1 label handler */
|
/* lvm1 label handler */
|
||||||
static struct labeller *_lvm1_label;
|
static struct labeller *_lvm1_label;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This structure only contains those options that
|
* This structure only contains those options that
|
||||||
* can have a default and per command setting.
|
* can have a default and per command setting.
|
||||||
@ -77,7 +75,6 @@ struct config_info {
|
|||||||
static struct config_info _default_settings;
|
static struct config_info _default_settings;
|
||||||
static struct config_info _current_settings;
|
static struct config_info _current_settings;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The lvm_sys_dir contains:
|
* The lvm_sys_dir contains:
|
||||||
*
|
*
|
||||||
@ -551,14 +548,13 @@ static int merge_synonym(int oldarg, int newarg)
|
|||||||
{
|
{
|
||||||
struct arg *old, *new;
|
struct arg *old, *new;
|
||||||
|
|
||||||
if (arg_count(cmd,oldarg) && arg_count(cmd,newarg)) {
|
if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) {
|
||||||
log_error("%s and %s are synonyms. Please only supply one.",
|
log_error("%s and %s are synonyms. Please only supply one.",
|
||||||
the_args[oldarg].long_arg,
|
the_args[oldarg].long_arg, the_args[newarg].long_arg);
|
||||||
the_args[newarg].long_arg);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arg_count(cmd,oldarg))
|
if (!arg_count(cmd, oldarg))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
old = the_args + oldarg;
|
old = the_args + oldarg;
|
||||||
@ -589,44 +585,43 @@ static int process_common_commands(struct command *com)
|
|||||||
{
|
{
|
||||||
_current_settings = _default_settings;
|
_current_settings = _default_settings;
|
||||||
|
|
||||||
if (arg_count(cmd,suspend_ARG))
|
if (arg_count(cmd, suspend_ARG))
|
||||||
kill(getpid(), SIGSTOP);
|
kill(getpid(), SIGSTOP);
|
||||||
|
|
||||||
if (arg_count(cmd,debug_ARG))
|
if (arg_count(cmd, debug_ARG))
|
||||||
_current_settings.debug = _LOG_FATAL +
|
_current_settings.debug = _LOG_FATAL +
|
||||||
(arg_count(cmd,debug_ARG) - 1);
|
(arg_count(cmd, debug_ARG) - 1);
|
||||||
|
|
||||||
if (arg_count(cmd,verbose_ARG))
|
if (arg_count(cmd, verbose_ARG))
|
||||||
_current_settings.verbose = arg_count(cmd,verbose_ARG);
|
_current_settings.verbose = arg_count(cmd, verbose_ARG);
|
||||||
|
|
||||||
if (arg_count(cmd,quiet_ARG)) {
|
if (arg_count(cmd, quiet_ARG)) {
|
||||||
_current_settings.debug = 0;
|
_current_settings.debug = 0;
|
||||||
_current_settings.verbose = 0;
|
_current_settings.verbose = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,test_ARG))
|
if (arg_count(cmd, test_ARG))
|
||||||
_current_settings.test = arg_count(cmd,test_ARG);
|
_current_settings.test = arg_count(cmd, test_ARG);
|
||||||
|
|
||||||
if (arg_count(cmd,help_ARG)) {
|
if (arg_count(cmd, help_ARG)) {
|
||||||
usage(com->name);
|
usage(com->name);
|
||||||
return ECMD_PROCESSED;
|
return ECMD_PROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,version_ARG)) {
|
if (arg_count(cmd, version_ARG)) {
|
||||||
return version(cmd, 0, (char **)NULL);
|
return version(cmd, 0, (char **) NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,autobackup_ARG)) {
|
if (arg_count(cmd, autobackup_ARG)) {
|
||||||
_current_settings.archive = 1;
|
_current_settings.archive = 1;
|
||||||
_current_settings.backup = 1;
|
_current_settings.backup = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,partial_ARG)) {
|
if (arg_count(cmd, partial_ARG)) {
|
||||||
init_partial(1);
|
init_partial(1);
|
||||||
log_print("Partial mode. Incomplete volume groups will "
|
log_print("Partial mode. Incomplete volume groups will "
|
||||||
"be activated read-only.");
|
"be activated read-only.");
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
init_partial(0);
|
init_partial(0);
|
||||||
|
|
||||||
/* Handle synonyms */
|
/* Handle synonyms */
|
||||||
@ -693,7 +688,7 @@ static char *_copy_command_line(struct pool *mem, int argc, char **argv)
|
|||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
if (i < (argc - 1))
|
if (i < (argc - 1))
|
||||||
if (!pool_grow_object(cmd->mem, " ", 1));
|
if (!pool_grow_object(cmd->mem, " ", 1)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -761,7 +756,6 @@ static int run_command(int argc, char **argv)
|
|||||||
if (ret == EINVALID_CMD_LINE && !_interactive)
|
if (ret == EINVALID_CMD_LINE && !_interactive)
|
||||||
usage(cmd->command->name);
|
usage(cmd->command->name);
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -804,7 +798,6 @@ static void __init_log(struct config_file *cf)
|
|||||||
|
|
||||||
const char *log_file, *prefix;
|
const char *log_file, *prefix;
|
||||||
|
|
||||||
|
|
||||||
_default_settings.syslog =
|
_default_settings.syslog =
|
||||||
find_config_int(cf->root, "log/syslog", '/', 1);
|
find_config_int(cf->root, "log/syslog", '/', 1);
|
||||||
if (_default_settings.syslog != 1)
|
if (_default_settings.syslog != 1)
|
||||||
@ -989,8 +982,7 @@ static struct dev_filter *filter_setup(struct config_file *cf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lvm_cache = find_config_str(cf->root, "devices/cache", '/',
|
lvm_cache = find_config_str(cf->root, "devices/cache", '/', cache_file);
|
||||||
cache_file);
|
|
||||||
|
|
||||||
if (!(f4 = persistent_filter_create(f3, lvm_cache))) {
|
if (!(f4 = persistent_filter_create(f3, lvm_cache))) {
|
||||||
log_error("Failed to create persistent device filter");
|
log_error("Failed to create persistent device filter");
|
||||||
@ -1092,8 +1084,7 @@ static int init(void)
|
|||||||
if (stat(config_file, &info) != -1) {
|
if (stat(config_file, &info) != -1) {
|
||||||
/* we've found a config file */
|
/* we've found a config file */
|
||||||
if (!read_config(cmd->cf, config_file)) {
|
if (!read_config(cmd->cf, config_file)) {
|
||||||
log_error("Failed to load config file %s",
|
log_error("Failed to load config file %s", config_file);
|
||||||
config_file);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1104,8 +1095,8 @@ static int init(void)
|
|||||||
"global/umask", '/',
|
"global/umask", '/',
|
||||||
DEFAULT_UMASK);
|
DEFAULT_UMASK);
|
||||||
|
|
||||||
if ((old_umask = umask((mode_t)_default_settings.umask)) !=
|
if ((old_umask = umask((mode_t) _default_settings.umask)) !=
|
||||||
(mode_t)_default_settings.umask)
|
(mode_t) _default_settings.umask)
|
||||||
log_verbose("Set umask to %04o", _default_settings.umask);
|
log_verbose("Set umask to %04o", _default_settings.umask);
|
||||||
|
|
||||||
if (lvm_snprintf(_dev_dir, sizeof(_dev_dir), "%s/",
|
if (lvm_snprintf(_dev_dir, sizeof(_dev_dir), "%s/",
|
||||||
@ -1358,7 +1349,6 @@ static int _hist_file(char *buffer, size_t size)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void _read_history(void)
|
static void _read_history(void)
|
||||||
{
|
{
|
||||||
char hist_file[PATH_MAX];
|
char hist_file[PATH_MAX];
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
int _get_max_dev_name_len(struct dev_filter *filter);
|
int _get_max_dev_name_len(struct dev_filter *filter);
|
||||||
void _count(struct device*, int*, int*);
|
void _count(struct device *, int *, int *);
|
||||||
void _print(struct device*, uint64_t, char*);
|
void _print(struct device *, uint64_t, char *);
|
||||||
int _check_device(struct device*);
|
int _check_device(struct device *);
|
||||||
|
|
||||||
int disks_found = 0;
|
int disks_found = 0;
|
||||||
int parts_found = 0;
|
int parts_found = 0;
|
||||||
@ -31,7 +31,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
|
|
||||||
if (arg_count(cmd,lvmpartition_ARG))
|
if (arg_count(cmd, lvmpartition_ARG))
|
||||||
log_print("WARNING: only considering LVM devices");
|
log_print("WARNING: only considering LVM devices");
|
||||||
|
|
||||||
max_len = _get_max_dev_name_len(cmd->filter);
|
max_len = _get_max_dev_name_len(cmd->filter);
|
||||||
@ -44,8 +44,8 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
/* Do scan */
|
/* Do scan */
|
||||||
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
||||||
/* Try if it is a PV first */
|
/* Try if it is a PV first */
|
||||||
if((pv = cmd->fid->ops->pv_read(cmd->fid, dev_name(dev)))) {
|
if ((pv = cmd->fid->ops->pv_read(cmd->fid, dev_name(dev)))) {
|
||||||
if(!dev_get_size(dev, &size)) {
|
if (!dev_get_size(dev, &size)) {
|
||||||
log_error("Couldn't get size of \"%s\"",
|
log_error("Couldn't get size of \"%s\"",
|
||||||
dev_name(dev));
|
dev_name(dev));
|
||||||
continue;
|
continue;
|
||||||
@ -55,15 +55,17 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* If user just wants PVs we are done */
|
/* If user just wants PVs we are done */
|
||||||
if (arg_count(cmd,lvmpartition_ARG)) continue;
|
if (arg_count(cmd, lvmpartition_ARG))
|
||||||
|
continue;
|
||||||
|
|
||||||
/* What other device is it? */
|
/* What other device is it? */
|
||||||
if(!_check_device(dev)) continue;
|
if (!_check_device(dev))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
dev_iter_destroy(iter);
|
dev_iter_destroy(iter);
|
||||||
|
|
||||||
/* Display totals */
|
/* Display totals */
|
||||||
if (!arg_count(cmd,lvmpartition_ARG)) {
|
if (!arg_count(cmd, lvmpartition_ARG)) {
|
||||||
log_print("%d disk%s",
|
log_print("%d disk%s",
|
||||||
disks_found, disks_found == 1 ? "" : "s");
|
disks_found, disks_found == 1 ? "" : "s");
|
||||||
log_print("%d partition%s",
|
log_print("%d partition%s",
|
||||||
@ -77,8 +79,8 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _check_device(struct device *dev)
|
||||||
int _check_device(struct device *dev) {
|
{
|
||||||
char buffer;
|
char buffer;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
|
||||||
@ -89,9 +91,8 @@ int _check_device(struct device *dev) {
|
|||||||
dev_close(dev);
|
dev_close(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(!dev_get_size(dev, &size)) {
|
if (!dev_get_size(dev, &size)) {
|
||||||
log_error("Couldn't get size of \"%s\"",
|
log_error("Couldn't get size of \"%s\"", dev_name(dev));
|
||||||
dev_name(dev));
|
|
||||||
}
|
}
|
||||||
_print(dev, size, NULL);
|
_print(dev, size, NULL);
|
||||||
_count(dev, &disks_found, &parts_found);
|
_count(dev, &disks_found, &parts_found);
|
||||||
@ -102,8 +103,8 @@ int _check_device(struct device *dev) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _get_max_dev_name_len(struct dev_filter *filter)
|
||||||
int _get_max_dev_name_len(struct dev_filter *filter) {
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int max_len = 0;
|
int max_len = 0;
|
||||||
struct dev_iter *iter;
|
struct dev_iter *iter;
|
||||||
@ -117,26 +118,30 @@ int _get_max_dev_name_len(struct dev_filter *filter) {
|
|||||||
/* Do scan */
|
/* Do scan */
|
||||||
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
||||||
len = strlen(dev_name(dev));
|
len = strlen(dev_name(dev));
|
||||||
if (len > max_len) max_len = len;
|
if (len > max_len)
|
||||||
|
max_len = len;
|
||||||
}
|
}
|
||||||
dev_iter_destroy(iter);
|
dev_iter_destroy(iter);
|
||||||
|
|
||||||
return max_len;
|
return max_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _count(struct device *dev, int *disks, int *parts)
|
||||||
|
{
|
||||||
|
int c = dev_name(dev)[strlen(dev_name(dev)) - 1];
|
||||||
|
|
||||||
void _count(struct device *dev, int *disks, int *parts) {
|
if (!isdigit(c))
|
||||||
int c = dev_name(dev)[strlen(dev_name(dev))-1];
|
(*disks)++;
|
||||||
|
else
|
||||||
if(!isdigit(c)) (*disks)++;
|
(*parts)++;
|
||||||
else (*parts)++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _print(struct device *dev, uint64_t size, char *what) {
|
void _print(struct device *dev, uint64_t size, char *what)
|
||||||
char *dummy = display_size(size/2, SIZE_SHORT);
|
{
|
||||||
|
char *dummy = display_size(size / 2, SIZE_SHORT);
|
||||||
const char *name = dev_name(dev);
|
const char *name = dev_name(dev);
|
||||||
|
|
||||||
if(!what) {
|
if (!what) {
|
||||||
|
|
||||||
what = "";
|
what = "";
|
||||||
}
|
}
|
||||||
|
@ -57,11 +57,12 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
|
|
||||||
active = lv_active(lv);
|
active = lv_active(lv);
|
||||||
|
|
||||||
if (active && !arg_count(cmd,force_ARG)) {
|
if (active && !arg_count(cmd, force_ARG)) {
|
||||||
if (yes_no_prompt
|
if (yes_no_prompt
|
||||||
("Do you really want to remove active logical volume \"%s\"? "
|
("Do you really want to remove active logical volume \"%s\"? "
|
||||||
"[y/n]: ", lv->name) == 'n') {
|
"[y/n]: ", lv->name) == 'n') {
|
||||||
log_print("Logical volume \"%s\" not removed", lv->name);
|
log_print("Logical volume \"%s\" not removed",
|
||||||
|
lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +71,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
|
||||||
if (active && !lv_deactivate(lv)) {
|
if (active && !lv_deactivate(lv)) {
|
||||||
log_error("Unable to deactivate logical volume \"%s\"", lv->name);
|
log_error("Unable to deactivate logical volume \"%s\"",
|
||||||
|
lv->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Releasing logical volume \"%s\"", lv->name);
|
log_verbose("Releasing logical volume \"%s\"", lv->name);
|
||||||
|
@ -74,7 +74,8 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is_valid_chars(lv_name_new)) {
|
if (!is_valid_chars(lv_name_new)) {
|
||||||
log_error("New logical volume name \"%s\" has invalid characters",
|
log_error
|
||||||
|
("New logical volume name \"%s\" has invalid characters",
|
||||||
lv_name_new);
|
lv_name_new);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,19 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if (!strcmp(cmd_name, "lvextend"))
|
if (!strcmp(cmd_name, "lvextend"))
|
||||||
resize = LV_EXTEND;
|
resize = LV_EXTEND;
|
||||||
|
|
||||||
if (arg_count(cmd,extents_ARG) + arg_count(cmd,size_ARG) != 1) {
|
if (arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG) != 1) {
|
||||||
log_error("Please specify either size or extents (not both)");
|
log_error("Please specify either size or extents (not both)");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,extents_ARG)) {
|
if (arg_count(cmd, extents_ARG)) {
|
||||||
extents = arg_int_value(cmd,extents_ARG, 0);
|
extents = arg_int_value(cmd, extents_ARG, 0);
|
||||||
sign = arg_sign_value(cmd,extents_ARG, SIGN_NONE);
|
sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,size_ARG)) {
|
if (arg_count(cmd, size_ARG)) {
|
||||||
size = arg_int_value(cmd,size_ARG, 0);
|
size = arg_int_value(cmd, size_ARG, 0);
|
||||||
sign = arg_sign_value(cmd,size_ARG, SIGN_NONE);
|
sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resize == LV_EXTEND && sign == SIGN_MINUS) {
|
if (resize == LV_EXTEND && sign == SIGN_MINUS) {
|
||||||
@ -76,12 +76,12 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,stripes_ARG)) {
|
if (arg_count(cmd, stripes_ARG)) {
|
||||||
log_print("Varied striping not yet supported. Ignoring.");
|
log_print("Varied striping not yet supported. Ignoring.");
|
||||||
/* FUTURE stripes = arg_int_value(cmd,stripes_ARG, 1); */
|
/* FUTURE stripes = arg_int_value(cmd,stripes_ARG, 1); */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,stripesize_ARG)) {
|
if (arg_count(cmd, stripesize_ARG)) {
|
||||||
log_print("Varied stripesize not yet supported. Ignoring.");
|
log_print("Varied stripesize not yet supported. Ignoring.");
|
||||||
/* FUTURE stripesize = 2 * arg_int_value(cmd,stripesize_ARG, 0); */
|
/* FUTURE stripesize = 2 * arg_int_value(cmd,stripesize_ARG, 0); */
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
dbg_free(dummy);
|
dbg_free(dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arg_count(cmd,force_ARG)) {
|
if (!arg_count(cmd, force_ARG)) {
|
||||||
if (yes_no_prompt("Do you really want to reduce %s?"
|
if (yes_no_prompt("Do you really want to reduce %s?"
|
||||||
" [y/n]: ", lv_name) == 'n') {
|
" [y/n]: ", lv_name) == 'n') {
|
||||||
log_print("Logical volume %s NOT reduced",
|
log_print("Logical volume %s NOT reduced",
|
||||||
@ -307,8 +307,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((resize == LV_EXTEND && argc) &&
|
if ((resize == LV_EXTEND && argc) &&
|
||||||
!(pvh = create_pv_list(cmd->mem, vg,
|
!(pvh = create_pv_list(cmd->mem, vg, argc - opt, argv + opt))) {
|
||||||
argc - opt, argv + opt))) {
|
|
||||||
stack;
|
stack;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -330,7 +329,6 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
active = lv_active(lv);
|
active = lv_active(lv);
|
||||||
|
|
||||||
/********* FIXME Suspend lv ***********/
|
/********* FIXME Suspend lv ***********/
|
||||||
|
@ -33,17 +33,17 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
struct list *pvh, *pvs;
|
struct list *pvh, *pvs;
|
||||||
|
|
||||||
if (arg_count(cmd,allocatable_ARG) == 0) {
|
if (arg_count(cmd, allocatable_ARG) == 0) {
|
||||||
log_error("Please give the x option");
|
log_error("Please give the x option");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(arg_count(cmd,all_ARG)) && !argc) {
|
if (!(arg_count(cmd, all_ARG)) && !argc) {
|
||||||
log_error("Please give a physical volume path");
|
log_error("Please give a physical volume path");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,all_ARG) && argc) {
|
if (arg_count(cmd, all_ARG) && argc) {
|
||||||
log_error("Option a and PhysicalVolumePath are exclusive");
|
log_error("Option a and PhysicalVolumePath are exclusive");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
for (; opt < argc; opt++) {
|
for (; opt < argc; opt++) {
|
||||||
pv_name = argv[opt];
|
pv_name = argv[opt];
|
||||||
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, pv_name))) {
|
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, pv_name))) {
|
||||||
log_error("Failed to read physical volume \"%s\"",
|
log_error
|
||||||
|
("Failed to read physical volume \"%s\"",
|
||||||
pv_name);
|
pv_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -69,7 +70,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
list_iterate(pvh, pvs) {
|
list_iterate(pvh, pvs) {
|
||||||
total++;
|
total++;
|
||||||
done += pvchange_single(cmd,
|
done += pvchange_single(cmd,
|
||||||
list_item(pvh, struct pv_list)->pv);
|
list_item(pvh,
|
||||||
|
struct pv_list)->pv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +90,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
|
|
||||||
const char *pv_name = dev_name(pv->dev);
|
const char *pv_name = dev_name(pv->dev);
|
||||||
|
|
||||||
int allocatable = !strcmp(arg_str_value(cmd,allocatable_ARG, "n"), "y");
|
int allocatable =
|
||||||
|
!strcmp(arg_str_value(cmd, allocatable_ARG, "n"), "y");
|
||||||
|
|
||||||
/* If in a VG, must change using volume group. */
|
/* If in a VG, must change using volume group. */
|
||||||
if (*pv->vg_name) {
|
if (*pv->vg_name) {
|
||||||
@ -121,7 +124,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
|
|
||||||
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
|
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
|
||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
log_error("Unable to find \"%s\" in volume group \"%s\"",
|
log_error
|
||||||
|
("Unable to find \"%s\" in volume group \"%s\"",
|
||||||
pv_name, vg->name);
|
pv_name, vg->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -132,7 +136,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
|
|
||||||
/* change allocatability for a PV */
|
/* change allocatability for a PV */
|
||||||
if (allocatable && (pv->status & ALLOCATABLE_PV)) {
|
if (allocatable && (pv->status & ALLOCATABLE_PV)) {
|
||||||
log_error("Physical volume \"%s\" is already allocatable", pv_name);
|
log_error("Physical volume \"%s\" is already allocatable",
|
||||||
|
pv_name);
|
||||||
if (*pv->vg_name)
|
if (*pv->vg_name)
|
||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
return 0;
|
return 0;
|
||||||
@ -147,7 +152,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allocatable) {
|
if (allocatable) {
|
||||||
log_verbose("Setting physical volume \"%s\" allocatable", pv_name);
|
log_verbose("Setting physical volume \"%s\" allocatable",
|
||||||
|
pv_name);
|
||||||
pv->status |= ALLOCATABLE_PV;
|
pv->status |= ALLOCATABLE_PV;
|
||||||
} else {
|
} else {
|
||||||
log_verbose("Setting physical volume \"%s\" NOT allocatable",
|
log_verbose("Setting physical volume \"%s\" NOT allocatable",
|
||||||
@ -157,7 +163,7 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
|
|
||||||
log_verbose("Updating physical volume \"%s\"", pv_name);
|
log_verbose("Updating physical volume \"%s\"", pv_name);
|
||||||
if (*pv->vg_name) {
|
if (*pv->vg_name) {
|
||||||
if (!(cmd->fid->ops->vg_write(cmd->fid,vg))) {
|
if (!(cmd->fid->ops->vg_write(cmd->fid, vg))) {
|
||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
log_error("Failed to store physical volume \"%s\" in "
|
log_error("Failed to store physical volume \"%s\" in "
|
||||||
"volume group \"%s\"", pv_name, vg->name);
|
"volume group \"%s\"", pv_name, vg->name);
|
||||||
|
@ -32,7 +32,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
|||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
|
|
||||||
/* is the partition type set correctly ? */
|
/* is the partition type set correctly ? */
|
||||||
if ((arg_count(cmd,force_ARG) < 1) && !is_lvm_partition(name))
|
if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* is there a pv here already */
|
/* is there a pv here already */
|
||||||
@ -45,20 +45,20 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
|||||||
|
|
||||||
/* Allow partial & exported VGs to be destroyed. */
|
/* Allow partial & exported VGs to be destroyed. */
|
||||||
/* we must have -ff to overwrite a non orphan */
|
/* we must have -ff to overwrite a non orphan */
|
||||||
if (arg_count(cmd,force_ARG) < 2) {
|
if (arg_count(cmd, force_ARG) < 2) {
|
||||||
log_error("Can't initialize physical volume \"%s\" of "
|
log_error("Can't initialize physical volume \"%s\" of "
|
||||||
"volume group \"%s\" without -ff", name, pv->vg_name);
|
"volume group \"%s\" without -ff", name, pv->vg_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prompt */
|
/* prompt */
|
||||||
if (!arg_count(cmd,yes_ARG) &&
|
if (!arg_count(cmd, yes_ARG) &&
|
||||||
yes_no_prompt(_really_init, name, pv->vg_name) == 'n') {
|
yes_no_prompt(_really_init, name, pv->vg_name) == 'n') {
|
||||||
log_print("Physical volume \"%s\" not initialized", name);
|
log_print("Physical volume \"%s\" not initialized", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,force_ARG)) {
|
if (arg_count(cmd, force_ARG)) {
|
||||||
log_print("WARNING: Forcing physical volume creation on "
|
log_print("WARNING: Forcing physical volume creation on "
|
||||||
"%s%s%s%s", name,
|
"%s%s%s%s", name,
|
||||||
pv->vg_name[0] ? " of volume group \"" : "",
|
pv->vg_name[0] ? " of volume group \"" : "",
|
||||||
@ -76,8 +76,8 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name)
|
|||||||
char *uuid;
|
char *uuid;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
if (arg_count(cmd,uuidstr_ARG)) {
|
if (arg_count(cmd, uuidstr_ARG)) {
|
||||||
uuid = arg_str_value(cmd,uuidstr_ARG,"");
|
uuid = arg_str_value(cmd, uuidstr_ARG, "");
|
||||||
if (!id_read_format(&id, uuid))
|
if (!id_read_format(&id, uuid))
|
||||||
return;
|
return;
|
||||||
if ((dev = uuid_map_lookup(cmd->um, &id))) {
|
if ((dev = uuid_map_lookup(cmd->um, &id))) {
|
||||||
@ -97,8 +97,7 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
||||||
" sectors",
|
" sectors", pv_name, pv->size);
|
||||||
pv_name, pv->size);
|
|
||||||
|
|
||||||
log_verbose("Writing physical volume data to disk \"%s\"", pv_name);
|
log_verbose("Writing physical volume data to disk \"%s\"", pv_name);
|
||||||
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
||||||
@ -118,12 +117,12 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,uuidstr_ARG) && argc != 1) {
|
if (arg_count(cmd, uuidstr_ARG) && argc != 1) {
|
||||||
log_error("Can only set uuid on one volume at once");
|
log_error("Can only set uuid on one volume at once");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,yes_ARG) && !arg_count(cmd,force_ARG)) {
|
if (arg_count(cmd, yes_ARG) && !arg_count(cmd, force_ARG)) {
|
||||||
log_error("Option y can only be given with option f");
|
log_error("Option y can only be given with option f");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,12 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv);
|
|||||||
|
|
||||||
int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt=0;
|
int opt = 0;
|
||||||
|
|
||||||
struct list *pvh, *pvs;
|
struct list *pvh, *pvs;
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
|
|
||||||
if (arg_count(cmd,colon_ARG) && arg_count(cmd,maps_ARG)) {
|
if (arg_count(cmd, colon_ARG) && arg_count(cmd, maps_ARG)) {
|
||||||
log_error("Option -v not allowed with option -c");
|
log_error("Option -v not allowed with option -c");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
@ -40,8 +40,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
for (; opt < argc; opt++) {
|
for (; opt < argc; opt++) {
|
||||||
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, argv[opt]))) {
|
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, argv[opt]))) {
|
||||||
log_error("Failed to read physical "
|
log_error("Failed to read physical "
|
||||||
"volume \"%s\"",
|
"volume \"%s\"", argv[opt]);
|
||||||
argv[opt]);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pvdisplay_single(cmd, pv);
|
pvdisplay_single(cmd, pv);
|
||||||
@ -70,7 +69,7 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
else
|
else
|
||||||
size = (pv->pe_count - pv->pe_allocated) * pv->pe_size;
|
size = (pv->pe_count - pv->pe_allocated) * pv->pe_size;
|
||||||
|
|
||||||
if (arg_count(cmd,short_ARG)) {
|
if (arg_count(cmd, short_ARG)) {
|
||||||
sz = display_size(size / 2, SIZE_SHORT);
|
sz = display_size(size / 2, SIZE_SHORT);
|
||||||
log_print("Device \"%s\" has a capacity of %s", pv_name, sz);
|
log_print("Device \"%s\" has a capacity of %s", pv_name, sz);
|
||||||
dbg_free(sz);
|
dbg_free(sz);
|
||||||
@ -79,16 +78,15 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
|
|
||||||
if (pv->status & EXPORTED_VG)
|
if (pv->status & EXPORTED_VG)
|
||||||
log_print("Physical volume \"%s\" of volume group \"%s\" "
|
log_print("Physical volume \"%s\" of volume group \"%s\" "
|
||||||
"is exported" , pv_name, pv->vg_name);
|
"is exported", pv_name, pv->vg_name);
|
||||||
|
|
||||||
/********* FIXME
|
/********* FIXME
|
||||||
log_error("no physical volume identifier on \"%s\"" , pv_name);
|
log_error("no physical volume identifier on \"%s\"" , pv_name);
|
||||||
*********/
|
*********/
|
||||||
|
|
||||||
if (!pv->vg_name) {
|
if (!pv->vg_name) {
|
||||||
log_print ( "\"%s\" is a new physical volume of \"%s\"",
|
log_print("\"%s\" is a new physical volume of \"%s\"",
|
||||||
pv_name, ( sz = display_size ( size / 2,
|
pv_name, (sz = display_size(size / 2, SIZE_SHORT)));
|
||||||
SIZE_SHORT)));
|
|
||||||
dbg_free(sz);
|
dbg_free(sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,14 +101,14 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
ret = pv_check_consistency (pv)
|
ret = pv_check_consistency (pv)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (arg_count(cmd,colon_ARG)) {
|
if (arg_count(cmd, colon_ARG)) {
|
||||||
pvdisplay_colons(pv);
|
pvdisplay_colons(pv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pvdisplay_full(pv);
|
pvdisplay_full(pv);
|
||||||
|
|
||||||
if (!arg_count(cmd,maps_ARG))
|
if (!arg_count(cmd, maps_ARG))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/******* FIXME
|
/******* FIXME
|
||||||
@ -129,4 +127,3 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,14 +43,14 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
pv_max_name_len = 0;
|
pv_max_name_len = 0;
|
||||||
vg_max_name_len = 0;
|
vg_max_name_len = 0;
|
||||||
|
|
||||||
if (arg_count(cmd,novolumegroup_ARG) && arg_count(cmd,exported_ARG)) {
|
if (arg_count(cmd, novolumegroup_ARG) && arg_count(cmd, exported_ARG)) {
|
||||||
log_error("Options -e and -n are incompatible");
|
log_error("Options -e and -n are incompatible");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,exported_ARG) || arg_count(cmd,novolumegroup_ARG))
|
if (arg_count(cmd, exported_ARG) || arg_count(cmd, novolumegroup_ARG))
|
||||||
log_print("WARNING: only considering physical volumes %s",
|
log_print("WARNING: only considering physical volumes %s",
|
||||||
arg_count(cmd,exported_ARG) ?
|
arg_count(cmd, exported_ARG) ?
|
||||||
"of exported volume group(s)" : "in no volume group");
|
"of exported volume group(s)" : "in no volume group");
|
||||||
|
|
||||||
log_verbose("Wiping cache of LVM-capable devices");
|
log_verbose("Wiping cache of LVM-capable devices");
|
||||||
@ -65,8 +65,10 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
pvl = list_item(pvh, struct pv_list);
|
pvl = list_item(pvh, struct pv_list);
|
||||||
pv = pvl->pv;
|
pv = pvl->pv;
|
||||||
|
|
||||||
if ((arg_count(cmd,exported_ARG) && !(pv->status & EXPORTED_VG))
|
if (
|
||||||
|| (arg_count(cmd,novolumegroup_ARG) && (*pv->vg_name))) {
|
(arg_count(cmd, exported_ARG)
|
||||||
|
&& !(pv->status & EXPORTED_VG))
|
||||||
|
|| (arg_count(cmd, novolumegroup_ARG) && (*pv->vg_name))) {
|
||||||
list_del(&pvl->list);
|
list_del(&pvl->list);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -83,7 +85,6 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
********/
|
********/
|
||||||
pvs_found++;
|
pvs_found++;
|
||||||
|
|
||||||
|
|
||||||
if (!*pv->vg_name) {
|
if (!*pv->vg_name) {
|
||||||
new_pvs_found++;
|
new_pvs_found++;
|
||||||
size_new += pv->size;
|
size_new += pv->size;
|
||||||
@ -141,12 +142,12 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
char vg_name_this[NAME_LEN] = { 0, };
|
char vg_name_this[NAME_LEN] = { 0, };
|
||||||
|
|
||||||
/* short listing? */
|
/* short listing? */
|
||||||
if (arg_count(cmd,short_ARG) > 0) {
|
if (arg_count(cmd, short_ARG) > 0) {
|
||||||
log_print("%s", dev_name(pv->dev));
|
log_print("%s", dev_name(pv->dev));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,verbose_ARG) > 1) {
|
if (arg_count(cmd, verbose_ARG) > 1) {
|
||||||
/* FIXME As per pv_display! Drop through for now. */
|
/* FIXME As per pv_display! Drop through for now. */
|
||||||
/* pv_show(pv); */
|
/* pv_show(pv); */
|
||||||
|
|
||||||
@ -157,11 +158,11 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
/* return; */
|
/* return; */
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pv_tmp_name, 0, sizeof (pv_tmp_name));
|
memset(pv_tmp_name, 0, sizeof(pv_tmp_name));
|
||||||
|
|
||||||
vg_name_len = strlen(pv->vg_name) + 1;
|
vg_name_len = strlen(pv->vg_name) + 1;
|
||||||
|
|
||||||
if (arg_count(cmd,uuid_ARG)) {
|
if (arg_count(cmd, uuid_ARG)) {
|
||||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||||
stack;
|
stack;
|
||||||
return;
|
return;
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct logical_volume *lv))
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct logical_volume * lv))
|
||||||
{
|
{
|
||||||
int ret_max = 0;
|
int ret_max = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -34,7 +35,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct logical_volume *lv))
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct logical_volume * lv))
|
||||||
{
|
{
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
int ret_max = 0;
|
int ret_max = 0;
|
||||||
@ -114,8 +116,10 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
|||||||
return ret_max;
|
return ret_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_type,
|
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||||
int (*process_single) (struct cmd_context *cmd, const char *vg_name))
|
int lock_type,
|
||||||
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
const char *vg_name))
|
||||||
{
|
{
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
int ret_max = 0;
|
int ret_max = 0;
|
||||||
@ -130,13 +134,13 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_typ
|
|||||||
log_verbose("Using volume group(s) on command line");
|
log_verbose("Using volume group(s) on command line");
|
||||||
for (; opt < argc; opt++) {
|
for (; opt < argc; opt++) {
|
||||||
vg_name = argv[opt];
|
vg_name = argv[opt];
|
||||||
if (!lock_vol((void *)vg_name, LCK_VG | lock_type)) {
|
if (!lock_vol((void *) vg_name, LCK_VG | lock_type)) {
|
||||||
log_error("Can't lock %s: skipping", vg_name);
|
log_error("Can't lock %s: skipping", vg_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((ret = process_single(cmd, vg_name)) > ret_max)
|
if ((ret = process_single(cmd, vg_name)) > ret_max)
|
||||||
ret_max = ret;
|
ret_max = ret;
|
||||||
lock_vol((void *)vg_name, LCK_VG | LCK_NONE);
|
lock_vol((void *) vg_name, LCK_VG | LCK_NONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_verbose("Finding all volume groups");
|
log_verbose("Finding all volume groups");
|
||||||
@ -145,8 +149,8 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_typ
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
list_iterate(vgh, vgs) {
|
list_iterate(vgh, vgs) {
|
||||||
vg_name = list_item (vgh, struct name_list)->name;
|
vg_name = list_item(vgh, struct name_list)->name;
|
||||||
if (!lock_vol((void *)vg_name, LCK_VG | lock_type)) {
|
if (!lock_vol((void *) vg_name, LCK_VG | lock_type)) {
|
||||||
log_error("Can't lock %s: skipping", vg_name);
|
log_error("Can't lock %s: skipping", vg_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -154,7 +158,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_typ
|
|||||||
|
|
||||||
if (ret > ret_max)
|
if (ret > ret_max)
|
||||||
ret_max = ret;
|
ret_max = ret;
|
||||||
lock_vol((void *)vg_name, LCK_VG | LCK_NONE);
|
lock_vol((void *) vg_name, LCK_VG | LCK_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,8 +166,9 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_typ
|
|||||||
}
|
}
|
||||||
|
|
||||||
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct volume_group *vg,
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
struct physical_volume *pv))
|
struct volume_group * vg,
|
||||||
|
struct physical_volume * pv))
|
||||||
{
|
{
|
||||||
int ret_max = 0;
|
int ret_max = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -180,9 +185,11 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
return ret_max;
|
return ret_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv, struct volume_group *vg,
|
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct volume_group *vg,
|
struct volume_group *vg,
|
||||||
struct physical_volume *pv))
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct volume_group * vg,
|
||||||
|
struct physical_volume * pv))
|
||||||
{
|
{
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
int ret_max = 0;
|
int ret_max = 0;
|
||||||
|
@ -29,21 +29,27 @@ int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
|
|||||||
int autobackup);
|
int autobackup);
|
||||||
int autobackup(struct volume_group *vg);
|
int autobackup(struct volume_group *vg);
|
||||||
|
|
||||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_type,
|
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||||
int (*process_single) (struct cmd_context *cmd, const char *vg_name));
|
int lock_type,
|
||||||
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
const char *vg_name));
|
||||||
|
|
||||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv, struct volume_group *vg,
|
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct volume_group * vg,
|
struct volume_group *vg,
|
||||||
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct volume_group * vg,
|
||||||
struct physical_volume * pv));
|
struct physical_volume * pv));
|
||||||
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct logical_volume * lv));
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct logical_volume * lv));
|
||||||
|
|
||||||
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct volume_group * vg,
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct volume_group * vg,
|
||||||
struct physical_volume * pv));
|
struct physical_volume * pv));
|
||||||
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
int (*process_single) (struct cmd_context *cmd, struct logical_volume * lv));
|
int (*process_single) (struct cmd_context * cmd,
|
||||||
|
struct logical_volume * lv));
|
||||||
|
|
||||||
int is_valid_chars(char *n);
|
int is_valid_chars(char *n);
|
||||||
|
|
||||||
@ -55,7 +61,6 @@ char *extract_vgname(struct format_instance *fi, char *lv_name);
|
|||||||
* lvcreate/extend.
|
* lvcreate/extend.
|
||||||
*/
|
*/
|
||||||
struct list *create_pv_list(struct pool *mem,
|
struct list *create_pv_list(struct pool *mem,
|
||||||
struct volume_group *vg,
|
struct volume_group *vg, int argc, char **argv);
|
||||||
int argc, char **argv);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#define MAX_ARGS 64
|
#define MAX_ARGS 64
|
||||||
|
|
||||||
/* command functions */
|
/* command functions */
|
||||||
typedef int (*command_fn)(struct cmd_context *cmd, int argc, char **argv);
|
typedef int (*command_fn) (struct cmd_context * cmd, int argc, char **argv);
|
||||||
|
|
||||||
#define xx(a, b...) int a(struct cmd_context *cmd, int argc, char **argv);
|
#define xx(a, b...) int a(struct cmd_context *cmd, int argc, char **argv);
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
@ -68,7 +68,7 @@ typedef enum {
|
|||||||
struct arg {
|
struct arg {
|
||||||
char short_arg;
|
char short_arg;
|
||||||
char *long_arg;
|
char *long_arg;
|
||||||
int (*fn)(struct arg *a);
|
int (*fn) (struct arg * a);
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
char *value;
|
char *value;
|
||||||
@ -101,11 +101,13 @@ int permission_arg(struct arg *a);
|
|||||||
char yes_no_prompt(const char *prompt, ...);
|
char yes_no_prompt(const char *prompt, ...);
|
||||||
|
|
||||||
/* we use the enums to access the switches */
|
/* we use the enums to access the switches */
|
||||||
static inline int arg_count(struct cmd_context *cmd, int a) {
|
static inline int arg_count(struct cmd_context *cmd, int a)
|
||||||
|
{
|
||||||
return cmd->args[a].count;
|
return cmd->args[a].count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *arg_value(struct cmd_context *cmd, int a) {
|
static inline char *arg_value(struct cmd_context *cmd, int a)
|
||||||
|
{
|
||||||
return cmd->args[a].value;
|
return cmd->args[a].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +116,8 @@ static inline char *arg_str_value(struct cmd_context *cmd, int a, char *def)
|
|||||||
return arg_count(cmd, a) ? cmd->args[a].value : def;
|
return arg_count(cmd, a) ? cmd->args[a].value : def;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t arg_int_value(struct cmd_context *cmd, int a, uint32_t def)
|
static inline uint32_t arg_int_value(struct cmd_context *cmd, int a,
|
||||||
|
uint32_t def)
|
||||||
{
|
{
|
||||||
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
|
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,file_ARG)) {
|
if (arg_count(cmd, file_ARG)) {
|
||||||
_backup_to_file(arg_value(cmd,file_ARG), vg);
|
_backup_to_file(arg_value(cmd, file_ARG), vg);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* just use the normal backup code */
|
/* just use the normal backup code */
|
||||||
@ -56,4 +56,3 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
{
|
{
|
||||||
return process_each_vg(cmd, argc, argv, LCK_READ, &vg_backup_single);
|
return process_each_vg(cmd, argc, argv, LCK_READ, &vg_backup_single);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,16 +17,16 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
* FIXME: overloading the -l arg for now to display a
|
* FIXME: overloading the -l arg for now to display a
|
||||||
* list of archive files for a particular vg
|
* list of archive files for a particular vg
|
||||||
*/
|
*/
|
||||||
if (arg_count(cmd,list_ARG)) {
|
if (arg_count(cmd, list_ARG)) {
|
||||||
if (!archive_display(cmd, argv[0]))
|
if (!archive_display(cmd, argv[0]))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(arg_count(cmd,file_ARG) ?
|
if (!(arg_count(cmd, file_ARG) ?
|
||||||
backup_restore_from_file(cmd, argv[0],
|
backup_restore_from_file(cmd, argv[0],
|
||||||
arg_str_value(cmd,file_ARG, "")) :
|
arg_str_value(cmd, file_ARG, "")) :
|
||||||
backup_restore(cmd, argv[0]))) {
|
backup_restore(cmd, argv[0]))) {
|
||||||
log_err("Restore failed.");
|
log_err("Restore failed.");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
@ -27,27 +27,28 @@ void vgchange_logicalvolume(struct cmd_context *cmd, struct volume_group *vg);
|
|||||||
|
|
||||||
int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (!(arg_count(cmd,available_ARG) + arg_count(cmd,logicalvolume_ARG) +
|
if (!
|
||||||
arg_count(cmd,resizeable_ARG))) {
|
(arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
||||||
|
arg_count(cmd, resizeable_ARG))) {
|
||||||
log_error("One of -a, -l or -x options required");
|
log_error("One of -a, -l or -x options required");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,available_ARG) + arg_count(cmd,logicalvolume_ARG) +
|
if (arg_count(cmd, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
||||||
arg_count(cmd,resizeable_ARG) > 1) {
|
arg_count(cmd, resizeable_ARG) > 1) {
|
||||||
log_error("Only one of -a, -l or -x options allowed");
|
log_error("Only one of -a, -l or -x options allowed");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,available_ARG) == 1 && arg_count(cmd,autobackup_ARG)) {
|
if (arg_count(cmd, available_ARG) == 1
|
||||||
|
&& arg_count(cmd, autobackup_ARG)) {
|
||||||
log_error("-A option not necessary with -a option");
|
log_error("-A option not necessary with -a option");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_each_vg(cmd, argc, argv,
|
return process_each_vg(cmd, argc, argv,
|
||||||
(arg_count(cmd,available_ARG)) ?
|
(arg_count(cmd, available_ARG)) ?
|
||||||
LCK_READ : LCK_WRITE,
|
LCK_READ : LCK_WRITE, &vgchange_single);
|
||||||
&vgchange_single);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vgchange_single(struct cmd_context *cmd, const char *vg_name)
|
static int vgchange_single(struct cmd_context *cmd, const char *vg_name)
|
||||||
@ -59,7 +60,7 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg->status & LVM_WRITE) && !arg_count(cmd,available_ARG)) {
|
if (!(vg->status & LVM_WRITE) && !arg_count(cmd, available_ARG)) {
|
||||||
log_error("Volume group \"%s\" is read-only", vg->name);
|
log_error("Volume group \"%s\" is read-only", vg->name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
@ -69,13 +70,13 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,available_ARG))
|
if (arg_count(cmd, available_ARG))
|
||||||
vgchange_available(cmd, vg);
|
vgchange_available(cmd, vg);
|
||||||
|
|
||||||
if (arg_count(cmd,resizeable_ARG))
|
if (arg_count(cmd, resizeable_ARG))
|
||||||
vgchange_resizeable(cmd, vg);
|
vgchange_resizeable(cmd, vg);
|
||||||
|
|
||||||
if (arg_count(cmd,logicalvolume_ARG))
|
if (arg_count(cmd, logicalvolume_ARG))
|
||||||
vgchange_logicalvolume(cmd, vg);
|
vgchange_logicalvolume(cmd, vg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -84,7 +85,7 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
||||||
{
|
{
|
||||||
int lv_open, lv_active;
|
int lv_open, lv_active;
|
||||||
int available = !strcmp(arg_str_value(cmd,available_ARG, "n"), "y");
|
int available = !strcmp(arg_str_value(cmd, available_ARG, "n"), "y");
|
||||||
|
|
||||||
/* FIXME: Force argument to deactivate them? */
|
/* FIXME: Force argument to deactivate them? */
|
||||||
if (!available && (lv_open = lvs_in_vg_opened(vg))) {
|
if (!available && (lv_open = lvs_in_vg_opened(vg))) {
|
||||||
@ -112,10 +113,11 @@ void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
|
|
||||||
void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
|
void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
|
||||||
{
|
{
|
||||||
int resizeable = !strcmp(arg_str_value(cmd,resizeable_ARG, "n"), "y");
|
int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
|
||||||
|
|
||||||
if (resizeable && (vg->status & RESIZEABLE_VG)) {
|
if (resizeable && (vg->status & RESIZEABLE_VG)) {
|
||||||
log_error("Volume group \"%s\" is already resizeable", vg->name);
|
log_error("Volume group \"%s\" is already resizeable",
|
||||||
|
vg->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +147,7 @@ void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
|
|
||||||
void vgchange_logicalvolume(struct cmd_context *cmd, struct volume_group *vg)
|
void vgchange_logicalvolume(struct cmd_context *cmd, struct volume_group *vg)
|
||||||
{
|
{
|
||||||
int max_lv = arg_int_value(cmd,logicalvolume_ARG, 0);
|
int max_lv = arg_int_value(cmd, logicalvolume_ARG, 0);
|
||||||
|
|
||||||
if (!(vg->status & RESIZEABLE_VG)) {
|
if (!(vg->status & RESIZEABLE_VG)) {
|
||||||
log_error("Volume group \"%s\" must be resizeable "
|
log_error("Volume group \"%s\" must be resizeable "
|
||||||
|
@ -52,4 +52,3 @@ static int vgck_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
/* FIXME: free */
|
/* FIXME: free */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vg_name = argv[0];
|
vg_name = argv[0];
|
||||||
max_lv = arg_int_value(cmd,maxlogicalvolumes_ARG, DEFAULT_LV);
|
max_lv = arg_int_value(cmd, maxlogicalvolumes_ARG, DEFAULT_LV);
|
||||||
max_pv = arg_int_value(cmd,maxphysicalvolumes_ARG, DEFAULT_PV);
|
max_pv = arg_int_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
|
||||||
|
|
||||||
/* Units of 512-byte sectors */
|
/* Units of 512-byte sectors */
|
||||||
extent_size = arg_int_value(cmd,physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
|
extent_size =
|
||||||
|
arg_int_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
|
||||||
|
|
||||||
if (max_lv < 1) {
|
if (max_lv < 1) {
|
||||||
log_error("maxlogicalvolumes too low");
|
log_error("maxlogicalvolumes too low");
|
||||||
|
@ -24,12 +24,12 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name);
|
|||||||
|
|
||||||
int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
|
int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (arg_count(cmd,colon_ARG) && arg_count(cmd,short_ARG)) {
|
if (arg_count(cmd, colon_ARG) && arg_count(cmd, short_ARG)) {
|
||||||
log_error("Option -c is not allowed with option -s");
|
log_error("Option -c is not allowed with option -s");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc && arg_count(cmd,activevolumegroups_ARG)) {
|
if (argc && arg_count(cmd, activevolumegroups_ARG)) {
|
||||||
log_error("Option -A is not allowed with volume group names");
|
log_error("Option -A is not allowed with volume group names");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
@ -78,19 +78,19 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
if (vg->status & EXPORTED_VG)
|
if (vg->status & EXPORTED_VG)
|
||||||
log_print("WARNING: volume group \"%s\" is exported", vg_name);
|
log_print("WARNING: volume group \"%s\" is exported", vg_name);
|
||||||
|
|
||||||
if (arg_count(cmd,colon_ARG)) {
|
if (arg_count(cmd, colon_ARG)) {
|
||||||
vgdisplay_colons(vg);
|
vgdisplay_colons(vg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd,short_ARG)) {
|
if (arg_count(cmd, short_ARG)) {
|
||||||
vgdisplay_short(vg);
|
vgdisplay_short(vg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vgdisplay_full(vg); /* was vg_show */
|
vgdisplay_full(vg); /* was vg_show */
|
||||||
|
|
||||||
if (arg_count(cmd,verbose_ARG)) {
|
if (arg_count(cmd, verbose_ARG)) {
|
||||||
vgdisplay_extents(vg);
|
vgdisplay_extents(vg);
|
||||||
|
|
||||||
process_each_lv_in_vg(cmd, vg, &lvdisplay_full);
|
process_each_lv_in_vg(cmd, vg, &lvdisplay_full);
|
||||||
@ -101,4 +101,3 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ static int vgexport_single(struct cmd_context *cmd, const char *vg_name);
|
|||||||
|
|
||||||
int vgexport(struct cmd_context *cmd, int argc, char **argv)
|
int vgexport(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (!argc && !arg_count(cmd,all_ARG)) {
|
if (!argc && !arg_count(cmd, all_ARG)) {
|
||||||
log_error("Please supply volume groups or use -a for all.");
|
log_error("Please supply volume groups or use -a for all.");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc && arg_count(cmd,all_ARG)) {
|
if (argc && arg_count(cmd, all_ARG)) {
|
||||||
log_error("No arguments permitted when using -a for all.");
|
log_error("No arguments permitted when using -a for all.");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ static int vgexport_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
|
|
||||||
vg->status |= EXPORTED_VG;
|
vg->status |= EXPORTED_VG;
|
||||||
|
|
||||||
if (!cmd->fid->ops->vg_write(cmd->fid,vg))
|
if (!cmd->fid->ops->vg_write(cmd->fid, vg))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
backup(vg);
|
backup(vg);
|
||||||
|
@ -24,12 +24,12 @@ static int vgimport_single(struct cmd_context *cmd, const char *vg_name);
|
|||||||
|
|
||||||
int vgimport(struct cmd_context *cmd, int argc, char **argv)
|
int vgimport(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (!argc && !arg_count(cmd,all_ARG)) {
|
if (!argc && !arg_count(cmd, all_ARG)) {
|
||||||
log_error("Please supply volume groups or use -a for all.");
|
log_error("Please supply volume groups or use -a for all.");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc && arg_count(cmd,all_ARG)) {
|
if (argc && arg_count(cmd, all_ARG)) {
|
||||||
log_error("No arguments permitted when using -a for all.");
|
log_error("No arguments permitted when using -a for all.");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ static int vgimport_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
|
|
||||||
vg->status &= ~EXPORTED_VG;
|
vg->status &= ~EXPORTED_VG;
|
||||||
|
|
||||||
if (!cmd->fid->ops->vg_write(cmd->fid,vg))
|
if (!cmd->fid->ops->vg_write(cmd->fid, vg))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
backup(vg);
|
backup(vg);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, const char *vg_name_from);
|
int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||||
|
const char *vg_name_from);
|
||||||
|
|
||||||
int vgmerge(struct cmd_context *cmd, int argc, char **argv)
|
int vgmerge(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -46,7 +47,8 @@ int vgmerge(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ret_max;
|
return ret_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, const char *vg_name_from)
|
int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||||
|
const char *vg_name_from)
|
||||||
{
|
{
|
||||||
struct volume_group *vg_to, *vg_from;
|
struct volume_group *vg_to, *vg_from;
|
||||||
struct list *lvh1, *lvh2;
|
struct list *lvh1, *lvh2;
|
||||||
@ -143,8 +145,7 @@ int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, const char *
|
|||||||
log_error("Duplicate logical volume "
|
log_error("Duplicate logical volume "
|
||||||
"name \"%s\" "
|
"name \"%s\" "
|
||||||
"in \"%s\" and \"%s\"",
|
"in \"%s\" and \"%s\"",
|
||||||
name1, vg_to->name,
|
name1, vg_to->name, vg_from->name);
|
||||||
vg_from->name);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, struct physical_volume *pv);
|
static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
|
struct physical_volume *pv);
|
||||||
|
|
||||||
int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -34,12 +35,12 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1 && !arg_count(cmd,all_ARG)) {
|
if (argc == 1 && !arg_count(cmd, all_ARG)) {
|
||||||
log_error("Please enter physical volume paths or option -a");
|
log_error("Please enter physical volume paths or option -a");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1 && arg_count(cmd,all_ARG)) {
|
if (argc > 1 && arg_count(cmd, all_ARG)) {
|
||||||
log_error("Option -a and physical volume paths mutually "
|
log_error("Option -a and physical volume paths mutually "
|
||||||
"exclusive");
|
"exclusive");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
@ -105,7 +106,8 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Or take pv_name instead? */
|
/* Or take pv_name instead? */
|
||||||
static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, struct physical_volume *pv)
|
static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||||
|
struct physical_volume *pv)
|
||||||
{
|
{
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
const char *name = dev_name(pv->dev);
|
const char *name = dev_name(pv->dev);
|
||||||
@ -144,8 +146,7 @@ static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, str
|
|||||||
|
|
||||||
if (!(cmd->fid->ops->vg_write(cmd->fid, vg))) {
|
if (!(cmd->fid->ops->vg_write(cmd->fid, vg))) {
|
||||||
log_error("Removal of physical volume \"%s\" from "
|
log_error("Removal of physical volume \"%s\" from "
|
||||||
"\"%s\" failed",
|
"\"%s\" failed", name, vg->name);
|
||||||
name, vg->name);
|
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
|
|
||||||
if (vg->lv_count) {
|
if (vg->lv_count) {
|
||||||
log_error("Volume group \"%s\" still contains %d "
|
log_error("Volume group \"%s\" still contains %d "
|
||||||
"logical volume(s)",
|
"logical volume(s)", vg_name, vg->lv_count);
|
||||||
vg_name, vg->lv_count);
|
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +83,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
list_iterate(pvh, &vg->pvs) {
|
list_iterate(pvh, &vg->pvs) {
|
||||||
pv = list_item(pvh, struct pv_list)->pv;
|
pv = list_item(pvh, struct pv_list)->pv;
|
||||||
log_verbose("Removing physical volume \"%s\" from "
|
log_verbose("Removing physical volume \"%s\" from "
|
||||||
"volume group \"%s\"",
|
"volume group \"%s\"", dev_name(pv->dev), vg_name);
|
||||||
dev_name(pv->dev), vg_name);
|
|
||||||
*pv->vg_name = '\0';
|
*pv->vg_name = '\0';
|
||||||
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
||||||
log_error("Failed to remove physical volume \"%s\""
|
log_error("Failed to remove physical volume \"%s\""
|
||||||
|
@ -52,8 +52,7 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_print("Found %svolume group \"%s\"",
|
log_print("Found %svolume group \"%s\"",
|
||||||
(vg->status & EXPORTED_VG) ? "exported " : "",
|
(vg->status & EXPORTED_VG) ? "exported " : "", vg_name);
|
||||||
vg_name);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user