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;
|
||||||
@ -227,13 +223,12 @@ int backup_remove(const char *vg_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct volume_group *_read_vg(struct cmd_context *cmd,
|
static struct volume_group *_read_vg(struct cmd_context *cmd,
|
||||||
const char *vg_name, const char *file)
|
const char *vg_name, const char *file)
|
||||||
{
|
{
|
||||||
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"
|
||||||
|
|
||||||
|
106
tools/lvchange.c
106
tools/lvchange.c
@ -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;
|
||||||
}
|
}
|
||||||
@ -54,9 +59,9 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
int doit = 0;
|
int doit = 0;
|
||||||
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;
|
||||||
@ -69,13 +74,13 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lv->status & SNAPSHOT) {
|
if (lv->status & SNAPSHOT) {
|
||||||
log_error("Can't change snapshot logical volume \"%s\"",
|
log_error("Can't change snapshot logical volume \"%s\"",
|
||||||
lv->name);
|
lv->name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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) {
|
||||||
@ -173,24 +183,24 @@ static int lvchange_availability(struct cmd_context *cmd, struct logical_volume
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (activate && active) {
|
if (activate && active) {
|
||||||
log_verbose("Logical volume \"%s\" is already active",
|
log_verbose("Logical volume \"%s\" is already active",
|
||||||
lv->name);
|
lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activate && !active) {
|
if (!activate && !active) {
|
||||||
log_verbose("Logical volume \"%s\" is already inactive",
|
log_verbose("Logical volume \"%s\" is already inactive",
|
||||||
lv->name);
|
lv->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activate & lv_suspended(lv)) {
|
if (activate & lv_suspended(lv)) {
|
||||||
log_verbose("Reactivating logical volume \"%s\"", lv->name);
|
log_verbose("Reactivating logical volume \"%s\"", lv->name);
|
||||||
if (!lv_reactivate(lv))
|
if (!lv_reactivate(lv))
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activate) {
|
if (activate) {
|
||||||
log_verbose("Activating logical volume \"%s\"", lv->name);
|
log_verbose("Activating logical volume \"%s\"", lv->name);
|
||||||
if (!lv_activate(lv))
|
if (!lv_activate(lv))
|
||||||
@ -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,8 +231,9 @@ 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
|
||||||
" not contiguous", lv->name);
|
("Allocation policy of logical volume \"%s\" is already"
|
||||||
|
" 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) {
|
||||||
@ -104,7 +104,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if (strcmp(vg_name, argv[0])) {
|
if (strcmp(vg_name, argv[0])) {
|
||||||
log_error("Inconsistent volume group names "
|
log_error("Inconsistent volume group names "
|
||||||
"given: \"%s\" and \"%s\"",
|
"given: \"%s\" and \"%s\"",
|
||||||
vg_name, argv[0]);
|
vg_name, argv[0]);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,10 +119,10 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
/* does VG exist? */
|
/* does VG exist? */
|
||||||
log_verbose("Finding volume group \"%s\"", vg_name);
|
log_verbose("Finding volume group \"%s\"", vg_name);
|
||||||
|
|
||||||
if (!lock_vol(vg_name, LCK_VG | LCK_WRITE)) {
|
if (!lock_vol(vg_name, LCK_VG | LCK_WRITE)) {
|
||||||
log_error("Can't get lock for %s", vg_name);
|
log_error("Can't get lock for %s", vg_name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg = cmd->fid->ops->vg_read(cmd->fid, vg_name))) {
|
if (!(vg = cmd->fid->ops->vg_read(cmd->fid, vg_name))) {
|
||||||
log_error("Volume group \"%s\" doesn't exist", vg_name);
|
log_error("Volume group \"%s\" doesn't exist", vg_name);
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,42 +198,40 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
extents /= vg->extent_size;
|
extents /= vg->extent_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size_rest = extents % stripes)) {
|
if ((size_rest = extents % stripes)) {
|
||||||
log_print("Rounding size (%d extents) up to stripe boundary "
|
log_print("Rounding size (%d extents) up to stripe boundary "
|
||||||
"size (%d extents)", extents,
|
"size (%d extents)", extents,
|
||||||
extents - size_rest + stripes);
|
extents - size_rest + stripes);
|
||||||
extents = extents - size_rest + stripes;
|
extents = extents - size_rest + stripes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!archive(vg))
|
if (!archive(vg))
|
||||||
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;
|
}
|
||||||
}
|
lv->status |= FIXED_MINOR;
|
||||||
lv->status |= FIXED_MINOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store vg on disk(s) */
|
/* store vg on disk(s) */
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
100
tools/lvm.c
100
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,18 +688,18 @@ 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)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Terminate.
|
* Terminate.
|
||||||
*/
|
*/
|
||||||
if (!pool_grow_object(mem, "\0", 1))
|
if (!pool_grow_object(mem, "\0", 1))
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
return pool_end_object(mem);
|
return pool_end_object(mem);
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
log_err("Couldn't copy command line.");
|
log_err("Couldn't copy command line.");
|
||||||
pool_abandon_object(mem);
|
pool_abandon_object(mem);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -733,7 +728,7 @@ static int run_command(int argc, char **argv)
|
|||||||
|
|
||||||
_use_settings(&_current_settings);
|
_use_settings(&_current_settings);
|
||||||
|
|
||||||
locking_type = find_config_int(cmd->cf->root, "global/locking_type",
|
locking_type = find_config_int(cmd->cf->root, "global/locking_type",
|
||||||
'/', 1);
|
'/', 1);
|
||||||
if (!init_locking(locking_type, cmd->cf)) {
|
if (!init_locking(locking_type, cmd->cf)) {
|
||||||
log_error("Locking type %d initialisation failed.",
|
log_error("Locking type %d initialisation failed.",
|
||||||
@ -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,9 +798,8 @@ 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)
|
||||||
fin_syslog();
|
fin_syslog();
|
||||||
|
|
||||||
@ -814,11 +807,11 @@ static void __init_log(struct config_file *cf)
|
|||||||
init_syslog(_default_settings.syslog);
|
init_syslog(_default_settings.syslog);
|
||||||
|
|
||||||
_default_settings.debug =
|
_default_settings.debug =
|
||||||
find_config_int(cf->root, "log/level", '/', 0);
|
find_config_int(cf->root, "log/level", '/', 0);
|
||||||
init_debug(_default_settings.debug);
|
init_debug(_default_settings.debug);
|
||||||
|
|
||||||
_default_settings.verbose =
|
_default_settings.verbose =
|
||||||
find_config_int(cf->root, "log/verbose", '/', 0);
|
find_config_int(cf->root, "log/verbose", '/', 0);
|
||||||
init_verbose(_default_settings.verbose);
|
init_verbose(_default_settings.verbose);
|
||||||
|
|
||||||
init_indent(find_config_int(cf->root, "log/indent", '/', 1));
|
init_indent(find_config_int(cf->root, "log/indent", '/', 1));
|
||||||
@ -858,14 +851,14 @@ static int _init_backup(struct config_file *cf)
|
|||||||
|
|
||||||
/* set up archiving */
|
/* set up archiving */
|
||||||
_default_settings.archive =
|
_default_settings.archive =
|
||||||
find_config_bool(cmd->cf->root, "backup/archive", '/',
|
find_config_bool(cmd->cf->root, "backup/archive", '/',
|
||||||
DEFAULT_ARCHIVE_ENABLED);
|
DEFAULT_ARCHIVE_ENABLED);
|
||||||
|
|
||||||
days = find_config_int(cmd->cf->root, "backup/retain_days", '/',
|
days = find_config_int(cmd->cf->root, "backup/retain_days", '/',
|
||||||
DEFAULT_ARCHIVE_DAYS);
|
DEFAULT_ARCHIVE_DAYS);
|
||||||
|
|
||||||
min = find_config_int(cmd->cf->root, "backup/retain_min", '/',
|
min = find_config_int(cmd->cf->root, "backup/retain_min", '/',
|
||||||
DEFAULT_ARCHIVE_NUMBER);
|
DEFAULT_ARCHIVE_NUMBER);
|
||||||
|
|
||||||
if (lvm_snprintf(default_dir, sizeof(default_dir), "%s/%s", _sys_dir,
|
if (lvm_snprintf(default_dir, sizeof(default_dir), "%s/%s", _sys_dir,
|
||||||
DEFAULT_ARCHIVE_SUBDIR) == -1) {
|
DEFAULT_ARCHIVE_SUBDIR) == -1) {
|
||||||
@ -884,8 +877,8 @@ static int _init_backup(struct config_file *cf)
|
|||||||
|
|
||||||
/* set up the backup */
|
/* set up the backup */
|
||||||
_default_settings.backup =
|
_default_settings.backup =
|
||||||
find_config_bool(cmd->cf->root, "backup/backup", '/',
|
find_config_bool(cmd->cf->root, "backup/backup", '/',
|
||||||
DEFAULT_BACKUP_ENABLED);
|
DEFAULT_BACKUP_ENABLED);
|
||||||
|
|
||||||
if (lvm_snprintf(default_dir, sizeof(default_dir), "%s/%s", _sys_dir,
|
if (lvm_snprintf(default_dir, sizeof(default_dir), "%s/%s", _sys_dir,
|
||||||
DEFAULT_BACKUP_SUBDIR) == -1) {
|
DEFAULT_BACKUP_SUBDIR) == -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,15 +1092,15 @@ static int init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_default_settings.umask = find_config_int(cmd->cf->root,
|
_default_settings.umask = find_config_int(cmd->cf->root,
|
||||||
"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/",
|
||||||
find_config_str(cmd->cf->root, "devices/dir",
|
find_config_str(cmd->cf->root, "devices/dir",
|
||||||
'/', DEFAULT_DEV_DIR)) < 0) {
|
'/', DEFAULT_DEV_DIR)) < 0) {
|
||||||
log_error("Device directory given in config file too long");
|
log_error("Device directory given in config file too long");
|
||||||
return 0;
|
return 0;
|
||||||
@ -1121,7 +1112,7 @@ static int init(void)
|
|||||||
dm_log_init(print_log);
|
dm_log_init(print_log);
|
||||||
|
|
||||||
if (lvm_snprintf(_proc_dir, sizeof(_proc_dir), "%s",
|
if (lvm_snprintf(_proc_dir, sizeof(_proc_dir), "%s",
|
||||||
find_config_str(cmd->cf->root, "global/proc",
|
find_config_str(cmd->cf->root, "global/proc",
|
||||||
'/', DEFAULT_PROC_DIR)) < 0) {
|
'/', DEFAULT_PROC_DIR)) < 0) {
|
||||||
log_error("Device directory given in config file too long");
|
log_error("Device directory given in config file too long");
|
||||||
return 0;
|
return 0;
|
||||||
@ -1301,7 +1292,7 @@ static char *_list_args(const char *text, int state)
|
|||||||
char c;
|
char c;
|
||||||
if (!(c = (the_args +
|
if (!(c = (the_args +
|
||||||
com->valid_args[match_no++])->short_arg))
|
com->valid_args[match_no++])->short_arg))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sprintf(s, "-%c", c);
|
sprintf(s, "-%c", c);
|
||||||
if (!strncmp(text, s, len))
|
if (!strncmp(text, s, len))
|
||||||
@ -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];
|
||||||
@ -1369,7 +1359,7 @@ static void _read_history(void)
|
|||||||
if (read_history(hist_file))
|
if (read_history(hist_file))
|
||||||
log_very_verbose("Couldn't read history from %s.", hist_file);
|
log_very_verbose("Couldn't read history from %s.", hist_file);
|
||||||
|
|
||||||
stifle_history(find_config_int(cmd->cf->root, "shell/history_size",
|
stifle_history(find_config_int(cmd->cf->root, "shell/history_size",
|
||||||
'/', DEFAULT_MAX_HISTORY));
|
'/', DEFAULT_MAX_HISTORY));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
@ -27,25 +27,25 @@ int max_len;
|
|||||||
int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
struct dev_iter *iter;
|
struct dev_iter *iter;
|
||||||
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);
|
||||||
|
|
||||||
if (!(iter = dev_iter_create(cmd->filter))) {
|
if (!(iter = dev_iter_create(cmd->filter))) {
|
||||||
log_error("dev_iter_create failed");
|
log_error("dev_iter_create failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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,55 +91,58 @@ 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);
|
||||||
if (!dev_close(dev)) {
|
if (!dev_close(dev)) {
|
||||||
log_error("dev_close on \"%s\" failed", dev_name(dev));
|
log_error("dev_close on \"%s\" failed", dev_name(dev));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
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;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
if (!(iter = dev_iter_create(filter))) {
|
if (!(iter = dev_iter_create(filter))) {
|
||||||
log_error("dev_iter_create failed");
|
log_error("dev_iter_create failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
/* Do scan */
|
|
||||||
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
|
||||||
len = strlen(dev_name(dev));
|
|
||||||
if (len > max_len) max_len = len;
|
|
||||||
}
|
}
|
||||||
dev_iter_destroy(iter);
|
|
||||||
|
/* Do scan */
|
||||||
|
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
||||||
|
len = strlen(dev_name(dev));
|
||||||
|
if (len > max_len)
|
||||||
|
max_len = len;
|
||||||
|
}
|
||||||
|
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,8 +74,9 @@ 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
|
||||||
lv_name_new);
|
("New logical volume name \"%s\" has invalid characters",
|
||||||
|
lv_name_new);
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,15 +97,15 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & EXPORTED_VG) {
|
if (vg->status & EXPORTED_VG) {
|
||||||
log_error("Volume group \"%s\" is exported", vg->name);
|
log_error("Volume group \"%s\" is exported", vg->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg->status & LVM_WRITE)) {
|
if (!(vg->status & LVM_WRITE)) {
|
||||||
log_error("Volume group \"%s\" is read-only", vg_name);
|
log_error("Volume group \"%s\" is read-only", vg_name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (find_lv_in_vg(vg, lv_name_new)) {
|
if (find_lv_in_vg(vg, lv_name_new)) {
|
||||||
log_error("Logical volume \"%s\" already exists in "
|
log_error("Logical volume \"%s\" already exists in "
|
||||||
|
@ -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); */
|
||||||
}
|
}
|
||||||
@ -115,15 +115,15 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & EXPORTED_VG) {
|
if (vg->status & EXPORTED_VG) {
|
||||||
log_error("Volume group %s is exported", vg->name);
|
log_error("Volume group %s is exported", vg->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg->status & LVM_WRITE)) {
|
if (!(vg->status & LVM_WRITE)) {
|
||||||
log_error("Volume group %s is read-only", vg_name);
|
log_error("Volume group %s is read-only", vg_name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does LV exist? */
|
/* does LV exist? */
|
||||||
if (!(lvl = find_lv_in_vg(vg, lv_name))) {
|
if (!(lvl = find_lv_in_vg(vg, lv_name))) {
|
||||||
@ -186,7 +186,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
struct stripe_segment *seg;
|
struct stripe_segment *seg;
|
||||||
uint32_t sz, str;
|
uint32_t sz, str;
|
||||||
|
|
||||||
seg = list_item(segh, struct stripe_segment);
|
seg = list_item(segh, struct stripe_segment);
|
||||||
sz = seg->stripe_size;
|
sz = seg->stripe_size;
|
||||||
str = seg->stripes;
|
str = seg->stripes;
|
||||||
|
|
||||||
@ -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 ***********/
|
||||||
@ -339,7 +337,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
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);
|
||||||
|
|
||||||
if (active && !lv_reactivate(lv))
|
if (active && !lv_reactivate(lv))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -95,7 +95,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv)
|
|||||||
dbg_free(dummy);
|
dbg_free(dummy);
|
||||||
|
|
||||||
/* FIXME sprintf? */
|
/* FIXME sprintf? */
|
||||||
|
|
||||||
/*********** FIXME Handle segments?
|
/*********** FIXME Handle segments?
|
||||||
if (lv->segments[0]->stripes > 1 && !(lv->status & SNAPSHOT))
|
if (lv->segments[0]->stripes > 1 && !(lv->status & SNAPSHOT))
|
||||||
log_print(" striped[%u]", lv->segments[0]->stripes);
|
log_print(" striped[%u]", lv->segments[0]->stripes);
|
||||||
|
@ -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,8 +53,9 @@ 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
|
||||||
pv_name);
|
("Failed to read physical volume \"%s\"",
|
||||||
|
pv_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
total++;
|
total++;
|
||||||
@ -69,14 +70,15 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_print("%d physical volume%s changed / %d physical volume%s "
|
log_print("%d physical volume%s changed / %d physical volume%s "
|
||||||
"not changed",
|
"not changed",
|
||||||
done, done > 1 ? "s" : "",
|
done, done > 1 ? "s" : "",
|
||||||
total - done, total - done > 1 ? "s" : "");
|
total - done, total - done > 1 ? "s" : "");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -88,11 +90,12 @@ 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) {
|
||||||
log_verbose("Finding volume group of physical volume \"%s\"",
|
log_verbose("Finding volume group of physical volume \"%s\"",
|
||||||
pv_name);
|
pv_name);
|
||||||
|
|
||||||
if (!lock_vol(pv->vg_name, LCK_VG | LCK_WRITE)) {
|
if (!lock_vol(pv->vg_name, LCK_VG | LCK_WRITE)) {
|
||||||
@ -103,17 +106,17 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
if (!(vg = cmd->fid->ops->vg_read(cmd->fid, pv->vg_name))) {
|
if (!(vg = cmd->fid->ops->vg_read(cmd->fid, pv->vg_name))) {
|
||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
log_error("Unable to find volume group of \"%s\"",
|
log_error("Unable to find volume group of \"%s\"",
|
||||||
pv_name);
|
pv_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & EXPORTED_VG) {
|
if (vg->status & EXPORTED_VG) {
|
||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
log_error("Volume group \"%s\" is exported", vg->name);
|
log_error("Volume group \"%s\" is exported", vg->name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg->status & LVM_WRITE)) {
|
if (!(vg->status & LVM_WRITE)) {
|
||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
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;
|
||||||
@ -121,8 +124,9 @@ 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
|
||||||
pv_name, vg->name);
|
("Unable to find \"%s\" in volume group \"%s\"",
|
||||||
|
pv_name, vg->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pv = pvl->pv;
|
pv = pvl->pv;
|
||||||
@ -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);
|
||||||
@ -167,7 +173,7 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||||
} else {
|
} else {
|
||||||
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
||||||
log_error("Failed to store physical volume \"%s\"",
|
log_error("Failed to store physical volume \"%s\"",
|
||||||
pv_name);
|
pv_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -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,35 +24,34 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc) {
|
if (argc) {
|
||||||
log_very_verbose("Using physical volume(s) on command line");
|
log_very_verbose("Using physical volume(s) on command line");
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_verbose("Scanning for physical volume names");
|
log_verbose("Scanning for physical volume names");
|
||||||
if (!(pvs = cmd->fid->ops->get_pvs(cmd->fid)))
|
if (!(pvs = cmd->fid->ops->get_pvs(cmd->fid)))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
|
||||||
list_iterate(pvh, pvs)
|
list_iterate(pvh, pvs)
|
||||||
pvdisplay_single(cmd, list_item(pvh, struct pv_list)->pv);
|
pvdisplay_single(cmd, list_item(pvh, struct pv_list)->pv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -61,7 +60,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||||
{
|
{
|
||||||
char *sz;
|
char *sz;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
|
||||||
const char *pv_name = dev_name(pv->dev);
|
const char *pv_name = dev_name(pv->dev);
|
||||||
|
|
||||||
@ -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);
|
||||||
@ -78,17 +77,16 @@ 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,14 +85,13 @@ 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;
|
||||||
size_total += pv->size;
|
size_total += pv->size;
|
||||||
} else
|
} else
|
||||||
size_total += (pv->pe_count - pv->pe_allocated)
|
size_total += (pv->pe_count - pv->pe_allocated)
|
||||||
* pv->pe_size;
|
* pv->pe_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find maximum pv name length */
|
/* find maximum pv name length */
|
||||||
@ -108,7 +109,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
vg_max_name_len += 2;
|
vg_max_name_len += 2;
|
||||||
|
|
||||||
list_iterate(pvh, pvs)
|
list_iterate(pvh, pvs)
|
||||||
pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv);
|
pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv);
|
||||||
|
|
||||||
if (!pvs_found) {
|
if (!pvs_found) {
|
||||||
log_print("No matching physical volumes found");
|
log_print("No matching physical volumes found");
|
||||||
@ -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;
|
||||||
@ -174,7 +175,7 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!*pv->vg_name) {
|
if (!*pv->vg_name) {
|
||||||
log_print("PV %-*s %-*s [%s]",
|
log_print("PV %-*s %-*s [%s]",
|
||||||
pv_max_name_len, pv_tmp_name,
|
pv_max_name_len, pv_tmp_name,
|
||||||
vg_max_name_len, " ",
|
vg_max_name_len, " ",
|
||||||
(s1 = display_size(pv->size / 2, SIZE_SHORT)));
|
(s1 = display_size(pv->size / 2, SIZE_SHORT)));
|
||||||
|
@ -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,16 +149,16 @@ 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;
|
||||||
}
|
}
|
||||||
ret = process_single(cmd, vg_name);
|
ret = process_single(cmd, vg_name);
|
||||||
|
|
||||||
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 physical_volume * pv));
|
struct volume_group * vg,
|
||||||
|
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;
|
||||||
@ -78,13 +78,13 @@ struct arg {
|
|||||||
|
|
||||||
/* a register of the lvm commands */
|
/* a register of the lvm commands */
|
||||||
struct command {
|
struct command {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *desc;
|
const char *desc;
|
||||||
const char *usage;
|
const char *usage;
|
||||||
command_fn fn;
|
command_fn fn;
|
||||||
|
|
||||||
int num_args;
|
int num_args;
|
||||||
int *valid_args;
|
int *valid_args;
|
||||||
};
|
};
|
||||||
|
|
||||||
void usage(const char *name);
|
void usage(const char *name);
|
||||||
@ -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 "
|
||||||
|
@ -47,9 +47,8 @@ static int vgck_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
log_error("not all physical volumes of volume group \"%s\" online",
|
log_error("not all physical volumes of volume group \"%s\" online",
|
||||||
log_error("volume group \"%s\" has physical volumes with ",
|
log_error("volume group \"%s\" has physical volumes with ",
|
||||||
"invalid version",
|
"invalid version",
|
||||||
********/
|
********/
|
||||||
|
|
||||||
/* FIXME: free */
|
/* FIXME: free */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define DEFAULT_PV 255
|
#define DEFAULT_PV 255
|
||||||
#define DEFAULT_LV 255
|
#define DEFAULT_LV 255
|
||||||
|
|
||||||
#define DEFAULT_EXTENT 4096 /* In KB */
|
#define DEFAULT_EXTENT 4096 /* In KB */
|
||||||
|
|
||||||
int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -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");
|
||||||
@ -62,25 +63,25 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Strip dev_dir if present */
|
/* Strip dev_dir if present */
|
||||||
if (!strncmp(vg_name, cmd->dev_dir, strlen(cmd->dev_dir)))
|
if (!strncmp(vg_name, cmd->dev_dir, strlen(cmd->dev_dir)))
|
||||||
vg_name += strlen(cmd->dev_dir);
|
vg_name += strlen(cmd->dev_dir);
|
||||||
|
|
||||||
snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
|
snprintf(vg_path, PATH_MAX, "%s%s", cmd->dev_dir, vg_name);
|
||||||
if (path_exists(vg_path)) {
|
if (path_exists(vg_path)) {
|
||||||
log_error("%s: already exists in filesystem", vg_path);
|
log_error("%s: already exists in filesystem", vg_path);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_valid_chars(vg_name)) {
|
if (!is_valid_chars(vg_name)) {
|
||||||
log_error("New volume group name \"%s\" has invalid characters",
|
log_error("New volume group name \"%s\" has invalid characters",
|
||||||
vg_name);
|
vg_name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the new VG */
|
/* Create the new VG */
|
||||||
if (!(vg = vg_create(cmd->fid, vg_name, extent_size, max_pv, max_lv,
|
if (!(vg = vg_create(cmd->fid, vg_name, extent_size, max_pv, max_lv,
|
||||||
argc - 1, argv + 1)))
|
argc - 1, argv + 1)))
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
|
|
||||||
if (max_lv != vg->max_lv)
|
if (max_lv != vg->max_lv)
|
||||||
@ -91,16 +92,16 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
log_error("Warning: Setting maxphysicalvolumes to %d",
|
log_error("Warning: Setting maxphysicalvolumes to %d",
|
||||||
vg->max_pv);
|
vg->max_pv);
|
||||||
|
|
||||||
if (!lock_vol("", LCK_VG | LCK_WRITE)) {
|
if (!lock_vol("", LCK_VG | LCK_WRITE)) {
|
||||||
log_error("Can't get lock for orphan PVs");
|
log_error("Can't get lock for orphan PVs");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lock_vol(vg_name, LCK_VG | LCK_WRITE | LCK_NONBLOCK)) {
|
if (!lock_vol(vg_name, LCK_VG | LCK_WRITE | LCK_NONBLOCK)) {
|
||||||
log_error("Can't get lock for %s", vg_name);
|
log_error("Can't get lock for %s", vg_name);
|
||||||
lock_vol("", LCK_VG | LCK_NONE);
|
lock_vol("", LCK_VG | LCK_NONE);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!archive(vg)) {
|
if (!archive(vg)) {
|
||||||
lock_vol(vg_name, LCK_VG | LCK_NONE);
|
lock_vol(vg_name, LCK_VG | LCK_NONE);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ static int vgexport_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lvs_in_vg_activated(vg)) {
|
if (lvs_in_vg_activated(vg)) {
|
||||||
log_error("Volume group \"%s\" has active logical volumes",
|
log_error("Volume group \"%s\" has active logical volumes",
|
||||||
vg_name);
|
vg_name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -67,15 +67,15 @@ 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);
|
||||||
|
|
||||||
log_print("Volume group \"%s\" successfully exported", vg->name);
|
log_print("Volume group \"%s\" successfully exported", vg->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
log_error("Please enter volume group name and "
|
log_error("Please enter volume group name and "
|
||||||
"physical volume(s)");
|
"physical volume(s)");
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|
||||||
if (!lock_vol("", LCK_VG | LCK_WRITE)) {
|
if (!lock_vol("", LCK_VG | LCK_WRITE)) {
|
||||||
log_error("Can't get lock for orphan PVs");
|
log_error("Can't get lock for orphan PVs");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Checking for volume group \"%s\"", vg_name);
|
log_verbose("Checking for volume group \"%s\"", vg_name);
|
||||||
if (!lock_vol(vg_name, LCK_VG | LCK_WRITE | LCK_NONBLOCK)) {
|
if (!lock_vol(vg_name, LCK_VG | LCK_WRITE | LCK_NONBLOCK)) {
|
||||||
@ -57,10 +57,10 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & EXPORTED_VG) {
|
if (vg->status & EXPORTED_VG) {
|
||||||
log_error("Volume group \"%s\" is exported", vg->name);
|
log_error("Volume group \"%s\" is exported", vg->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg->status & LVM_WRITE)) {
|
if (!(vg->status & LVM_WRITE)) {
|
||||||
log_error("Volume group \"%s\" is read-only", vg_name);
|
log_error("Volume group \"%s\" is read-only", vg_name);
|
||||||
@ -90,7 +90,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
log_verbose("Volume group \"%s\" will be extended by %d new "
|
log_verbose("Volume group \"%s\" will be extended by %d new "
|
||||||
"physical volumes", vg_name, argc);
|
"physical volumes", vg_name, argc);
|
||||||
|
|
||||||
/* store vg on disk(s) */
|
/* store vg on disk(s) */
|
||||||
if (!cmd->fid->ops->vg_write(cmd->fid, vg))
|
if (!cmd->fid->ops->vg_write(cmd->fid, vg))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_each_vg(cmd, argc, argv, LCK_WRITE, &vgimport_single);
|
return process_each_vg(cmd, argc, argv, LCK_WRITE, &vgimport_single);
|
||||||
}
|
}
|
||||||
@ -62,13 +62,13 @@ 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);
|
||||||
|
|
||||||
log_print("Volume group \"%s\" successfully imported", vg->name);
|
log_print("Volume group \"%s\" successfully imported", vg->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -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;
|
||||||
@ -69,11 +71,11 @@ int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, const char *
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg_to->status & EXPORTED_VG) {
|
if (vg_to->status & EXPORTED_VG) {
|
||||||
log_error("Volume group \"%s\" is exported", vg_to->name);
|
log_error("Volume group \"%s\" is exported", vg_to->name);
|
||||||
lock_vol(vg_name_to, LCK_VG | LCK_NONE);
|
lock_vol(vg_name_to, LCK_VG | LCK_NONE);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg_to->status & LVM_WRITE)) {
|
if (!(vg_to->status & LVM_WRITE)) {
|
||||||
log_error("Volume group \"%s\" is read-only", vg_to->name);
|
log_error("Volume group \"%s\" is read-only", vg_to->name);
|
||||||
@ -93,10 +95,10 @@ int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, const char *
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg_from->status & EXPORTED_VG) {
|
if (vg_from->status & EXPORTED_VG) {
|
||||||
log_error("Volume group \"%s\" is exported", vg_from->name);
|
log_error("Volume group \"%s\" is exported", vg_from->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg_from->status & LVM_WRITE)) {
|
if (!(vg_from->status & LVM_WRITE)) {
|
||||||
log_error("Volume group \"%s\" is read-only", vg_from->name);
|
log_error("Volume group \"%s\" is read-only", vg_from->name);
|
||||||
@ -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;
|
||||||
@ -61,11 +62,11 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & EXPORTED_VG) {
|
if (vg->status & EXPORTED_VG) {
|
||||||
log_error("Volume group \"%s\" is exported", vg->name);
|
log_error("Volume group \"%s\" is exported", vg->name);
|
||||||
lock_vol(vg_name, LCK_VG | LCK_NONE);
|
lock_vol(vg_name, LCK_VG | LCK_NONE);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg->status & LVM_WRITE)) {
|
if (!(vg->status & LVM_WRITE)) {
|
||||||
log_error("Volume group \"%s\" is read-only", vg_name);
|
log_error("Volume group \"%s\" is read-only", vg_name);
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
log_error("Can't get lock for orphan PVs");
|
log_error("Can't get lock for orphan PVs");
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = process_each_vg(cmd, argc, argv, LCK_WRITE | LCK_NONBLOCK,
|
ret = process_each_vg(cmd, argc, argv, LCK_WRITE | LCK_NONBLOCK,
|
||||||
&vgremove_single);
|
&vgremove_single);
|
||||||
|
|
||||||
lock_vol("", LCK_VG | LCK_NONE);
|
lock_vol("", LCK_VG | LCK_NONE);
|
||||||
@ -52,10 +52,10 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & EXPORTED_VG) {
|
if (vg->status & EXPORTED_VG) {
|
||||||
log_error("Volume group \"%s\" is exported", vg->name);
|
log_error("Volume group \"%s\" is exported", vg->name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg->status & PARTIAL_VG) {
|
if (vg->status & PARTIAL_VG) {
|
||||||
log_error("Cannot remove partial volume group \"%s\"",
|
log_error("Cannot remove partial volume group \"%s\"",
|
||||||
@ -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\""
|
||||||
|
@ -69,10 +69,10 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
|
log_verbose("Checking for existing volume group \"%s\"", vg_name_old);
|
||||||
|
|
||||||
if (!lock_vol(vg_name_old, LCK_VG | LCK_WRITE)) {
|
if (!lock_vol(vg_name_old, LCK_VG | LCK_WRITE)) {
|
||||||
log_error("Can't get lock for %s", vg_name_old);
|
log_error("Can't get lock for %s", vg_name_old);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg_old = cmd->fid->ops->vg_read(cmd->fid, vg_name_old))) {
|
if (!(vg_old = cmd->fid->ops->vg_read(cmd->fid, vg_name_old))) {
|
||||||
log_error("Volume group \"%s\" doesn't exist", vg_name_old);
|
log_error("Volume group \"%s\" doesn't exist", vg_name_old);
|
||||||
@ -80,11 +80,11 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vg_old->status & EXPORTED_VG) {
|
if (vg_old->status & EXPORTED_VG) {
|
||||||
lock_vol(vg_name_old, LCK_VG | LCK_NONE);
|
lock_vol(vg_name_old, LCK_VG | LCK_NONE);
|
||||||
log_error("Volume group \"%s\" is exported", vg_old->name);
|
log_error("Volume group \"%s\" is exported", vg_old->name);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(vg_old->status & LVM_WRITE)) {
|
if (!(vg_old->status & LVM_WRITE)) {
|
||||||
lock_vol(vg_name_old, LCK_VG | LCK_NONE);
|
lock_vol(vg_name_old, LCK_VG | LCK_NONE);
|
||||||
@ -143,7 +143,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
log_verbose("Renaming \"%s\" to \"%s\"", old_path, new_path);
|
log_verbose("Renaming \"%s\" to \"%s\"", old_path, new_path);
|
||||||
if (rename(old_path, new_path)) {
|
if (rename(old_path, new_path)) {
|
||||||
log_error("Renaming \"%s\" to \"%s\" failed: %s",
|
log_error("Renaming \"%s\" to \"%s\" failed: %s",
|
||||||
old_path, new_path, strerror(errno));
|
old_path, new_path, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,8 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
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