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 <limits.h>
|
||||
|
||||
|
||||
static struct {
|
||||
int enabled;
|
||||
char *dir;
|
||||
@ -25,8 +24,7 @@ static struct {
|
||||
|
||||
} _archive_params;
|
||||
|
||||
int archive_init(const char *dir,
|
||||
unsigned int keep_days, unsigned int keep_min)
|
||||
int archive_init(const char *dir, unsigned int keep_days, unsigned int keep_min)
|
||||
{
|
||||
_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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct {
|
||||
int enabled;
|
||||
char *dir;
|
||||
@ -232,8 +228,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
|
||||
struct volume_group *vg;
|
||||
struct format_instance *tf;
|
||||
|
||||
if (!(tf = text_format_create(cmd, file, cmd->um,
|
||||
cmd->cmd_line))) {
|
||||
if (!(tf = text_format_create(cmd, file, cmd->um, cmd->cmd_line))) {
|
||||
log_error("Couldn't create text format object.");
|
||||
return NULL;
|
||||
}
|
||||
@ -245,7 +240,8 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
|
||||
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;
|
||||
|
||||
|
@ -42,7 +42,8 @@ void backup_enable(int flag);
|
||||
int backup(struct volume_group *vg);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
@ -2,4 +2,3 @@
|
||||
#define xx(a, b, c...) a
|
||||
|
||||
#include "commands.h"
|
||||
|
||||
|
@ -21,11 +21,16 @@
|
||||
#include "tools.h"
|
||||
|
||||
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_availability(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);
|
||||
static int lvchange_permission(struct cmd_context *cmd,
|
||||
struct logical_volume *lv);
|
||||
static int lvchange_availability(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)
|
||||
{
|
||||
@ -117,31 +122,35 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
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;
|
||||
|
||||
lv_access = arg_int_value(cmd, permission_ARG, 0);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (lv_access & 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 {
|
||||
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);
|
||||
if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg))
|
||||
return 0;
|
||||
@ -155,7 +164,8 @@ static int lvchange_permission(struct cmd_context *cmd, struct logical_volume *l
|
||||
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 active;
|
||||
@ -204,7 +214,8 @@ static int lvchange_availability(struct cmd_context *cmd, struct logical_volume
|
||||
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;
|
||||
|
||||
@ -220,7 +231,8 @@ static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *l
|
||||
|
||||
if (!(lv_allocation & ALLOC_CONTIGUOUS) &&
|
||||
!(lv->status & ALLOC_CONTIGUOUS)) {
|
||||
log_error("Allocation policy of logical volume \"%s\" is already"
|
||||
log_error
|
||||
("Allocation policy of logical volume \"%s\" is already"
|
||||
" not contiguous", lv->name);
|
||||
return 0;
|
||||
}
|
||||
@ -252,7 +264,8 @@ static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *l
|
||||
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;
|
||||
|
||||
@ -272,7 +285,8 @@ static int lvchange_readahead(struct cmd_context *cmd, struct logical_volume *lv
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -284,7 +298,8 @@ static int lvchange_readahead(struct cmd_context *cmd, struct logical_volume *lv
|
||||
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 (!(lv->status & FIXED_MINOR)) {
|
||||
@ -319,4 +334,3 @@ static int lvchange_persistent(struct cmd_context *cmd, struct logical_volume *l
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
if (stripesize > vg->extent_size) {
|
||||
log_error("Setting stripe size %d KB to physical extent "
|
||||
"size %u KB",
|
||||
stripesize / 2, vg->extent_size / 2);
|
||||
"size %u KB", stripesize / 2, vg->extent_size / 2);
|
||||
stripesize = vg->extent_size;
|
||||
}
|
||||
|
||||
@ -210,8 +209,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto error;
|
||||
|
||||
if (!(lv = lv_create(cmd->fid, lv_name, status,
|
||||
stripes, stripesize, extents,
|
||||
vg, pvh)))
|
||||
stripes, stripesize, extents, vg, pvh)))
|
||||
goto error;
|
||||
|
||||
if (arg_count(cmd, readahead_ARG)) {
|
||||
@ -228,8 +226,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
if (arg_count(cmd, persistent_ARG)) {
|
||||
if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "n"))
|
||||
lv->status &= ~FIXED_MINOR;
|
||||
else
|
||||
if (!arg_count(cmd,minor_ARG)) {
|
||||
else if (!arg_count(cmd, minor_ARG)) {
|
||||
log_error("Please specify minor number with "
|
||||
"--minor when using -My");
|
||||
goto error;
|
||||
|
@ -44,4 +44,3 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
return process_each_lv(cmd, argc, argv, &lvdisplay_single);
|
||||
}
|
||||
|
||||
|
18
tools/lvm.c
18
tools/lvm.c
@ -42,7 +42,6 @@ struct arg the_args[ARG_COUNT + 1] = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
static int _array_size;
|
||||
static int _num_commands;
|
||||
static struct command *_commands;
|
||||
@ -57,7 +56,6 @@ static FILE *_log;
|
||||
/* lvm1 label handler */
|
||||
static struct labeller *_lvm1_label;
|
||||
|
||||
|
||||
/*
|
||||
* This structure only contains those options that
|
||||
* 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 _current_settings;
|
||||
|
||||
|
||||
/*
|
||||
* The lvm_sys_dir contains:
|
||||
*
|
||||
@ -553,8 +550,7 @@ static int merge_synonym(int oldarg, int newarg)
|
||||
|
||||
if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) {
|
||||
log_error("%s and %s are synonyms. Please only supply one.",
|
||||
the_args[oldarg].long_arg,
|
||||
the_args[newarg].long_arg);
|
||||
the_args[oldarg].long_arg, the_args[newarg].long_arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -625,8 +621,7 @@ static int process_common_commands(struct command *com)
|
||||
init_partial(1);
|
||||
log_print("Partial mode. Incomplete volume groups will "
|
||||
"be activated read-only.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
init_partial(0);
|
||||
|
||||
/* Handle synonyms */
|
||||
@ -761,7 +756,6 @@ static int run_command(int argc, char **argv)
|
||||
if (ret == EINVALID_CMD_LINE && !_interactive)
|
||||
usage(cmd->command->name);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -804,7 +798,6 @@ static void __init_log(struct config_file *cf)
|
||||
|
||||
const char *log_file, *prefix;
|
||||
|
||||
|
||||
_default_settings.syslog =
|
||||
find_config_int(cf->root, "log/syslog", '/', 1);
|
||||
if (_default_settings.syslog != 1)
|
||||
@ -989,8 +982,7 @@ static struct dev_filter *filter_setup(struct config_file *cf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
lvm_cache = find_config_str(cf->root, "devices/cache", '/',
|
||||
cache_file);
|
||||
lvm_cache = find_config_str(cf->root, "devices/cache", '/', cache_file);
|
||||
|
||||
if (!(f4 = persistent_filter_create(f3, lvm_cache))) {
|
||||
log_error("Failed to create persistent device filter");
|
||||
@ -1092,8 +1084,7 @@ static int init(void)
|
||||
if (stat(config_file, &info) != -1) {
|
||||
/* we've found a config file */
|
||||
if (!read_config(cmd->cf, config_file)) {
|
||||
log_error("Failed to load config file %s",
|
||||
config_file);
|
||||
log_error("Failed to load config file %s", config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1358,7 +1349,6 @@ static int _hist_file(char *buffer, size_t size)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void _read_history(void)
|
||||
{
|
||||
char hist_file[PATH_MAX];
|
||||
|
@ -55,10 +55,12 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
/* 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? */
|
||||
if(!_check_device(dev)) continue;
|
||||
if (!_check_device(dev))
|
||||
continue;
|
||||
}
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
@ -77,8 +79,8 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int _check_device(struct device *dev) {
|
||||
int _check_device(struct device *dev)
|
||||
{
|
||||
char buffer;
|
||||
uint64_t size;
|
||||
|
||||
@ -90,8 +92,7 @@ int _check_device(struct device *dev) {
|
||||
return 0;
|
||||
}
|
||||
if (!dev_get_size(dev, &size)) {
|
||||
log_error("Couldn't get size of \"%s\"",
|
||||
dev_name(dev));
|
||||
log_error("Couldn't get size of \"%s\"", dev_name(dev));
|
||||
}
|
||||
_print(dev, size, NULL);
|
||||
_count(dev, &disks_found, &parts_found);
|
||||
@ -102,8 +103,8 @@ int _check_device(struct device *dev) {
|
||||
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 max_len = 0;
|
||||
struct dev_iter *iter;
|
||||
@ -117,22 +118,26 @@ int _get_max_dev_name_len(struct dev_filter *filter) {
|
||||
/* 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;
|
||||
if (len > max_len)
|
||||
max_len = len;
|
||||
}
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
return max_len;
|
||||
}
|
||||
|
||||
|
||||
void _count(struct device *dev, int *disks, int *parts) {
|
||||
void _count(struct device *dev, int *disks, int *parts)
|
||||
{
|
||||
int c = dev_name(dev)[strlen(dev_name(dev)) - 1];
|
||||
|
||||
if(!isdigit(c)) (*disks)++;
|
||||
else (*parts)++;
|
||||
if (!isdigit(c))
|
||||
(*disks)++;
|
||||
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);
|
||||
const char *name = dev_name(dev);
|
||||
|
||||
|
@ -61,7 +61,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
if (yes_no_prompt
|
||||
("Do you really want to remove active logical volume \"%s\"? "
|
||||
"[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;
|
||||
}
|
||||
}
|
||||
@ -70,7 +71,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
return ECMD_FAILED;
|
||||
|
||||
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);
|
||||
|
@ -74,7 +74,8 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!is_valid_chars(lv_name_new)) {
|
||||
log_error("New logical volume name \"%s\" has invalid characters",
|
||||
log_error
|
||||
("New logical volume name \"%s\" has invalid characters",
|
||||
lv_name_new);
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
@ -307,8 +307,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
if ((resize == LV_EXTEND && argc) &&
|
||||
!(pvh = create_pv_list(cmd->mem, vg,
|
||||
argc - opt, argv + opt))) {
|
||||
!(pvh = create_pv_list(cmd->mem, vg, argc - opt, argv + opt))) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
@ -330,7 +329,6 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
active = lv_active(lv);
|
||||
|
||||
/********* FIXME Suspend lv ***********/
|
||||
|
@ -53,7 +53,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
for (; opt < argc; opt++) {
|
||||
pv_name = argv[opt];
|
||||
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, pv_name))) {
|
||||
log_error("Failed to read physical volume \"%s\"",
|
||||
log_error
|
||||
("Failed to read physical volume \"%s\"",
|
||||
pv_name);
|
||||
continue;
|
||||
}
|
||||
@ -69,7 +70,8 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
list_iterate(pvh, pvs) {
|
||||
total++;
|
||||
done += pvchange_single(cmd,
|
||||
list_item(pvh, struct pv_list)->pv);
|
||||
list_item(pvh,
|
||||
struct pv_list)->pv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +90,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
|
||||
const char *pv_name = dev_name(pv->dev);
|
||||
|
||||
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 (*pv->vg_name) {
|
||||
@ -121,7 +124,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
|
||||
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
|
||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||
log_error("Unable to find \"%s\" in volume group \"%s\"",
|
||||
log_error
|
||||
("Unable to find \"%s\" in volume group \"%s\"",
|
||||
pv_name, vg->name);
|
||||
return 0;
|
||||
}
|
||||
@ -132,7 +136,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
|
||||
/* change allocatability for a 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)
|
||||
lock_vol(pv->vg_name, LCK_VG | LCK_NONE);
|
||||
return 0;
|
||||
@ -147,7 +152,8 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
}
|
||||
|
||||
if (allocatable) {
|
||||
log_verbose("Setting physical volume \"%s\" allocatable", pv_name);
|
||||
log_verbose("Setting physical volume \"%s\" allocatable",
|
||||
pv_name);
|
||||
pv->status |= ALLOCATABLE_PV;
|
||||
} else {
|
||||
log_verbose("Setting physical volume \"%s\" NOT allocatable",
|
||||
|
@ -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
|
||||
" sectors",
|
||||
pv_name, pv->size);
|
||||
" sectors", pv_name, pv->size);
|
||||
|
||||
log_verbose("Writing physical volume data to disk \"%s\"", pv_name);
|
||||
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
||||
|
@ -40,8 +40,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
for (; opt < argc; opt++) {
|
||||
if (!(pv = cmd->fid->ops->pv_read(cmd->fid, argv[opt]))) {
|
||||
log_error("Failed to read physical "
|
||||
"volume \"%s\"",
|
||||
argv[opt]);
|
||||
"volume \"%s\"", argv[opt]);
|
||||
continue;
|
||||
}
|
||||
pvdisplay_single(cmd, pv);
|
||||
@ -87,8 +86,7 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
|
||||
if (!pv->vg_name) {
|
||||
log_print("\"%s\" is a new physical volume of \"%s\"",
|
||||
pv_name, ( sz = display_size ( size / 2,
|
||||
SIZE_SHORT)));
|
||||
pv_name, (sz = display_size(size / 2, SIZE_SHORT)));
|
||||
dbg_free(sz);
|
||||
}
|
||||
|
||||
@ -129,4 +127,3 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,9 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
pvl = list_item(pvh, struct pv_list);
|
||||
pv = pvl->pv;
|
||||
|
||||
if ((arg_count(cmd,exported_ARG) && !(pv->status & EXPORTED_VG))
|
||||
if (
|
||||
(arg_count(cmd, exported_ARG)
|
||||
&& !(pv->status & EXPORTED_VG))
|
||||
|| (arg_count(cmd, novolumegroup_ARG) && (*pv->vg_name))) {
|
||||
list_del(&pvl->list);
|
||||
continue;
|
||||
@ -83,7 +85,6 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
********/
|
||||
pvs_found++;
|
||||
|
||||
|
||||
if (!*pv->vg_name) {
|
||||
new_pvs_found++;
|
||||
size_new += pv->size;
|
||||
|
@ -9,7 +9,8 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
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 = 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_single) (struct cmd_context *cmd, struct logical_volume *lv))
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct logical_volume * lv))
|
||||
{
|
||||
int opt = 0;
|
||||
int ret_max = 0;
|
||||
@ -114,8 +116,10 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_type,
|
||||
int (*process_single) (struct cmd_context *cmd, const char *vg_name))
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
int lock_type,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
const char *vg_name))
|
||||
{
|
||||
int opt = 0;
|
||||
int ret_max = 0;
|
||||
@ -162,7 +166,8 @@ 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_single) (struct cmd_context *cmd, struct volume_group *vg,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct volume_group * vg,
|
||||
struct physical_volume * pv))
|
||||
{
|
||||
int ret_max = 0;
|
||||
@ -180,8 +185,10 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv, struct volume_group *vg,
|
||||
int (*process_single) (struct cmd_context *cmd, struct volume_group *vg,
|
||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
struct volume_group *vg,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct volume_group * vg,
|
||||
struct physical_volume * pv))
|
||||
{
|
||||
int opt = 0;
|
||||
|
@ -29,21 +29,27 @@ int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
|
||||
int autobackup);
|
||||
int autobackup(struct volume_group *vg);
|
||||
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv, int lock_type,
|
||||
int (*process_single) (struct cmd_context *cmd, const char *vg_name));
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
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_single) (struct cmd_context *cmd, struct volume_group * vg,
|
||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
struct volume_group *vg,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct volume_group * vg,
|
||||
struct physical_volume * pv));
|
||||
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_single) (struct cmd_context *cmd, struct volume_group * vg,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct volume_group * vg,
|
||||
struct physical_volume * pv));
|
||||
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);
|
||||
|
||||
@ -55,7 +61,6 @@ char *extract_vgname(struct format_instance *fi, char *lv_name);
|
||||
* lvcreate/extend.
|
||||
*/
|
||||
struct list *create_pv_list(struct pool *mem,
|
||||
struct volume_group *vg,
|
||||
int argc, char **argv);
|
||||
struct volume_group *vg, int argc, char **argv);
|
||||
|
||||
#endif
|
||||
|
@ -101,11 +101,13 @@ int permission_arg(struct arg *a);
|
||||
char yes_no_prompt(const char *prompt, ...);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,8 @@ void vgchange_logicalvolume(struct cmd_context *cmd, struct volume_group *vg);
|
||||
|
||||
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, available_ARG) + arg_count(cmd, logicalvolume_ARG) +
|
||||
arg_count(cmd, resizeable_ARG))) {
|
||||
log_error("One of -a, -l or -x options required");
|
||||
return EINVALID_CMD_LINE;
|
||||
@ -39,15 +40,15 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
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");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
return process_each_vg(cmd, argc, argv,
|
||||
(arg_count(cmd, available_ARG)) ?
|
||||
LCK_READ : LCK_WRITE,
|
||||
&vgchange_single);
|
||||
LCK_READ : LCK_WRITE, &vgchange_single);
|
||||
}
|
||||
|
||||
static int vgchange_single(struct cmd_context *cmd, const char *vg_name)
|
||||
@ -115,7 +116,8 @@ void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
|
||||
int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -52,4 +52,3 @@ static int vgck_single(struct cmd_context *cmd, const char *vg_name)
|
||||
/* FIXME: free */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,8 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
max_pv = arg_int_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
|
||||
|
||||
/* 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) {
|
||||
log_error("maxlogicalvolumes too low");
|
||||
|
@ -101,4 +101,3 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -46,7 +47,8 @@ int vgmerge(struct cmd_context *cmd, int argc, char **argv)
|
||||
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 list *lvh1, *lvh2;
|
||||
@ -143,8 +145,7 @@ int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, const char *
|
||||
log_error("Duplicate logical volume "
|
||||
"name \"%s\" "
|
||||
"in \"%s\" and \"%s\"",
|
||||
name1, vg_to->name,
|
||||
vg_from->name);
|
||||
name1, vg_to->name, vg_from->name);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -105,7 +106,8 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
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))) {
|
||||
log_error("Removal of physical volume \"%s\" from "
|
||||
"\"%s\" failed",
|
||||
name, vg->name);
|
||||
"\"%s\" failed", name, vg->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
|
||||
|
||||
if (vg->lv_count) {
|
||||
log_error("Volume group \"%s\" still contains %d "
|
||||
"logical volume(s)",
|
||||
vg_name, vg->lv_count);
|
||||
"logical volume(s)", vg_name, vg->lv_count);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
@ -84,8 +83,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name)
|
||||
list_iterate(pvh, &vg->pvs) {
|
||||
pv = list_item(pvh, struct pv_list)->pv;
|
||||
log_verbose("Removing physical volume \"%s\" from "
|
||||
"volume group \"%s\"",
|
||||
dev_name(pv->dev), vg_name);
|
||||
"volume group \"%s\"", dev_name(pv->dev), vg_name);
|
||||
*pv->vg_name = '\0';
|
||||
if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) {
|
||||
log_error("Failed to remove physical volume \"%s\""
|
||||
|
@ -52,8 +52,7 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name)
|
||||
}
|
||||
|
||||
log_print("Found %svolume group \"%s\"",
|
||||
(vg->status & EXPORTED_VG) ? "exported " : "",
|
||||
vg_name);
|
||||
(vg->status & EXPORTED_VG) ? "exported " : "", vg_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user