summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/archive.c8
-rw-r--r--tools/lvchange.c8
-rw-r--r--tools/lvcreate.c28
-rw-r--r--tools/lvdisplay.c6
-rw-r--r--tools/lvm.c91
-rw-r--r--tools/lvmdiskscan.c14
-rw-r--r--tools/lvrename.c6
-rw-r--r--tools/lvresize.c58
-rw-r--r--tools/lvscan.c3
-rw-r--r--tools/pvchange.c22
-rw-r--r--tools/pvcreate.c14
-rw-r--r--tools/pvdisplay.c6
-rw-r--r--tools/pvremove.c1
-rw-r--r--tools/pvscan.c38
-rw-r--r--tools/report.c15
-rw-r--r--tools/toollib.c12
-rw-r--r--tools/toollib.h2
-rw-r--r--tools/tools.h51
-rw-r--r--tools/vgchange.c17
-rw-r--r--tools/vgconvert.c8
-rw-r--r--tools/vgcreate.c8
-rw-r--r--tools/vgmerge.c6
-rw-r--r--tools/vgreduce.c4
-rw-r--r--tools/vgremove.c4
-rw-r--r--tools/vgrename.c11
-rw-r--r--tools/vgsplit.c2
26 files changed, 234 insertions, 209 deletions
diff --git a/tools/archive.c b/tools/archive.c
index 8fdafc26..bd8ef4c8 100644
--- a/tools/archive.c
+++ b/tools/archive.c
@@ -204,7 +204,7 @@ int backup_remove(const char *vg_name)
struct volume_group *backup_read_vg(struct cmd_context *cmd,
const char *vg_name, const char *file)
{
- struct volume_group *vg;
+ struct volume_group *vg = NULL;
struct format_instance *tf;
struct list *mdah;
struct metadata_area *mda;
@@ -262,8 +262,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
return 0;
}
if (!vg->fid->fmt->ops->
- pv_setup(vg->fid->fmt, 0, 0, 0, 0, 0,
- &vg->fid->metadata_areas, pv, vg)) {
+ pv_setup(vg->fid->fmt, __UINT64_C(0), 0, 0, 0,
+ __UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) {
log_error("Format-specific setup for %s failed",
dev_name(pv->dev));
return 0;
@@ -310,7 +310,7 @@ int backup_restore(struct cmd_context *cmd, const char *vg_name)
int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
{
- int r;
+ int r = 0;
struct format_instance *tf;
struct list *mdah;
struct metadata_area *mda;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 24cc73d0..e073fed3 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -23,9 +23,9 @@
static int lvchange_permission(struct cmd_context *cmd,
struct logical_volume *lv)
{
- int lv_access;
+ uint32_t lv_access;
- lv_access = arg_int_value(cmd, permission_ARG, 0);
+ lv_access = arg_uint_value(cmd, permission_ARG, 0);
if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
log_error("Logical volume \"%s\" is already writable",
@@ -162,9 +162,9 @@ static int lvchange_contiguous(struct cmd_context *cmd,
static int lvchange_readahead(struct cmd_context *cmd,
struct logical_volume *lv)
{
- int read_ahead = 0;
+ unsigned int read_ahead = 0;
- read_ahead = arg_int_value(cmd, readahead_ARG, 0);
+ read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
/******* FIXME Ranges?
if (read_ahead < LVM_MIN_READ_AHEAD || read_ahead > LVM_MAX_READ_AHEAD) {
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index b7ca5315..06c129b1 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -17,8 +17,8 @@ struct lvcreate_params {
int minor;
char *origin;
- char *vg_name;
- char *lv_name;
+ const char *vg_name;
+ const char *lv_name;
uint32_t stripes;
uint32_t stripe_size;
@@ -140,11 +140,11 @@ static int _read_size_params(struct lvcreate_params *lp,
}
if (arg_count(cmd, extents_ARG))
- lp->extents = arg_int_value(cmd, extents_ARG, 0);
+ lp->extents = arg_uint_value(cmd, extents_ARG, 0);
/* Size returned in kilobyte units; held in sectors */
if (arg_count(cmd, size_ARG))
- lp->size = arg_uint64_value(cmd, size_ARG, 0) * 2ull;
+ lp->size = arg_uint64_value(cmd, size_ARG, __UINT64_C(0)) * 2;
return 1;
}
@@ -158,13 +158,13 @@ static int _read_stripe_params(struct lvcreate_params *lp,
lp->stripes = 1;
if (arg_count(cmd, stripes_ARG)) {
- lp->stripes = arg_int_value(cmd, stripes_ARG, 1);
+ lp->stripes = arg_uint_value(cmd, stripes_ARG, 1);
if (lp->stripes == 1)
log_print("Redundant stripes argument: default is 1");
}
if (arg_count(cmd, stripesize_ARG))
- lp->stripe_size = 2 * arg_int_value(cmd, stripesize_ARG, 0);
+ lp->stripe_size = 2 * arg_uint_value(cmd, stripesize_ARG, 0);
if (lp->stripes == 1 && lp->stripe_size) {
log_print("Ignoring stripesize argument with single stripe");
@@ -172,7 +172,9 @@ static int _read_stripe_params(struct lvcreate_params *lp,
}
if (lp->stripes > 1 && !lp->stripe_size) {
- lp->stripe_size = 2 * STRIPE_SIZE_DEFAULT;
+ lp->stripe_size = find_config_int(cmd->cf->root,
+ "metadata/stripesize", '/',
+ DEFAULT_STRIPESIZE) * 2;
log_print("Using default stripesize %dKB", lp->stripe_size / 2);
}
@@ -211,7 +213,7 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
log_error("-s and -Z are incompatible");
return 0;
}
- lp->chunk_size = 2 * arg_int_value(cmd, chunksize_ARG, 8);
+ lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8);
log_verbose("Setting chunksize to %d sectors.", lp->chunk_size);
} else {
if (arg_count(cmd, chunksize_ARG)) {
@@ -239,13 +241,13 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
* Read ahead.
*/
if (arg_count(cmd, readahead_ARG))
- lp->read_ahead = arg_int_value(cmd, readahead_ARG, 0);
+ lp->read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
/*
* Permissions.
*/
if (arg_count(cmd, permission_ARG))
- lp->permission = arg_int_value(cmd, permission_ARG, 0);
+ lp->permission = arg_uint_value(cmd, permission_ARG, 0);
else
lp->permission = LVM_READ | LVM_WRITE;
@@ -309,7 +311,7 @@ static int _zero_lv(struct cmd_context *cmd, struct logical_volume *lv)
if (!(dev_open(dev, O_WRONLY)))
return 0;
- dev_zero(dev, 0, 4096);
+ dev_zero(dev, __UINT64_C(0), (size_t) 4096);
dev_close(dev);
return 1;
@@ -321,7 +323,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
uint32_t status = 0;
alloc_policy_t alloc = ALLOC_DEFAULT;
struct volume_group *vg;
- struct logical_volume *lv, *org;
+ struct logical_volume *lv, *org = NULL;
struct list *pvh;
int consistent = 1;
@@ -381,7 +383,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
lp->extents += vg->extent_size - lp->extents %
vg->extent_size;
log_print("Rounding up size to full physical extent %s",
- display_size(cmd, lp->extents / 2,
+ display_size(cmd, (uint64_t) lp->extents / 2,
SIZE_SHORT));
}
diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c
index 47d546da..4361aaed 100644
--- a/tools/lvdisplay.c
+++ b/tools/lvdisplay.c
@@ -20,8 +20,8 @@
#include "tools.h"
-int lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
+ void *handle)
{
if (arg_count(cmd, colon_ARG))
lvdisplay_colons(lv);
@@ -57,5 +57,5 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
}
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
- &lvdisplay_single);
+ &_lvdisplay_single);
}
diff --git a/tools/lvm.c b/tools/lvm.c
index 66550319..cd0ea989 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -5,13 +5,11 @@
*/
#include "tools.h"
-#include "defaults.h"
#include "label.h"
#include "version.h"
#include "stub.h"
-#include <assert.h>
#include <getopt.h>
#include <signal.h>
#include <syslog.h>
@@ -32,7 +30,7 @@
*/
struct arg the_args[ARG_COUNT + 1] = {
-#define arg(a, b, c, d) {b, "--" c, d, 0, NULL},
+#define arg(a, b, c, d) {b, "--" c, d, 0, NULL, 0, 0, __INT64_C(0), __UINT64_C(0), 0, NULL},
#include "args.h"
#undef arg
@@ -48,11 +46,15 @@ int yes_no_arg(struct cmd_context *cmd, struct arg *a)
{
a->sign = SIGN_NONE;
- if (!strcmp(a->value, "y"))
+ if (!strcmp(a->value, "y")) {
a->i_value = 1;
+ a->ui_value = 1;
+ }
- else if (!strcmp(a->value, "n"))
+ else if (!strcmp(a->value, "n")) {
a->i_value = 0;
+ a->ui_value = 0;
+ }
else
return 0;
@@ -82,7 +84,7 @@ int metadatatype_arg(struct cmd_context *cmd, struct arg *a)
return 0;
}
-int _get_int_arg(struct arg *a, char **ptr)
+static int _get_int_arg(struct arg *a, char **ptr)
{
char *val;
long v;
@@ -109,7 +111,9 @@ int _get_int_arg(struct arg *a, char **ptr)
if (*ptr == val)
return 0;
- a->i_value = (uint32_t) v;
+ a->i_value = (int32_t) v;
+ a->ui_value = (uint32_t) v;
+
return 1;
}
@@ -117,7 +121,7 @@ static int _size_arg(struct cmd_context *cmd, struct arg *a, int factor)
{
char *ptr;
int i;
- static char *suffixes = "kmgt";
+ static const char *suffixes = "kmgt";
char *val;
double v;
@@ -156,7 +160,8 @@ static int _size_arg(struct cmd_context *cmd, struct arg *a, int factor)
} else
v *= factor;
- a->i_value = (uint32_t) v;
+ a->i_value = (int32_t) v;
+ a->ui_value = (uint32_t) v;
a->i64_value = (int64_t) v;
a->ui64_value = (uint64_t) v;
@@ -218,10 +223,10 @@ int permission_arg(struct cmd_context *cmd, struct arg *a)
a->sign = SIGN_NONE;
if ((!strcmp(a->value, "rw")) || (!strcmp(a->value, "wr")))
- a->i_value = LVM_READ | LVM_WRITE;
+ a->ui_value = LVM_READ | LVM_WRITE;
else if (!strcmp(a->value, "r"))
- a->i_value = LVM_READ;
+ a->ui_value = LVM_READ;
else
return 0;
@@ -268,7 +273,7 @@ static void _alloc_command(void)
}
static void _create_new_command(const char *name, command_fn command,
- const char *desc, const char *usage,
+ const char *desc, const char *usagestr,
int nargs, int *args)
{
struct command *nc;
@@ -279,21 +284,21 @@ static void _create_new_command(const char *name, command_fn command,
nc->name = name;
nc->desc = desc;
- nc->usage = usage;
+ nc->usage = usagestr;
nc->fn = command;
nc->num_args = nargs;
nc->valid_args = args;
}
static void _register_command(const char *name, command_fn fn,
- const char *desc, const char *usage, ...)
+ const char *desc, const char *usagestr, ...)
{
int nargs = 0, i;
int *args;
va_list ap;
/* count how many arguments we have */
- va_start(ap, usage);
+ va_start(ap, usagestr);
while (va_arg(ap, int) >= 0)
nargs++;
va_end(ap);
@@ -305,13 +310,13 @@ static void _register_command(const char *name, command_fn fn,
}
/* fill them in */
- va_start(ap, usage);
+ va_start(ap, usagestr);
for (i = 0; i < nargs; i++)
args[i] = va_arg(ap, int);
va_end(ap);
/* enter the command in the register */
- _create_new_command(name, fn, desc, usage, nargs, args);
+ _create_new_command(name, fn, desc, usagestr, nargs, args);
}
static void _register_commands()
@@ -346,7 +351,7 @@ static struct command *_find_command(const char *name)
return _commands + i;
}
-void usage(const char *name)
+static void _usage(const char *name)
{
struct command *com = _find_command(name);
@@ -416,12 +421,15 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
struct arg *a;
for (i = 0; i < ARG_COUNT; i++) {
- struct arg *a = the_args + i;
+ a = the_args + i;
/* zero the count and arg */
a->count = 0;
a->value = 0;
a->i_value = 0;
+ a->ui_value = 0;
+ a->i64_value = 0;
+ a->ui64_value = 0;
}
/* fill in the short and long opts */
@@ -471,7 +479,8 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
{
- struct arg *old, *new;
+ const struct arg *old;
+ struct arg *new;
if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) {
log_error("%s and %s are synonyms. Please only supply one.",
@@ -488,6 +497,9 @@ static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
new->count = old->count;
new->value = old->value;
new->i_value = old->i_value;
+ new->ui_value = old->ui_value;
+ new->i64_value = old->i64_value;
+ new->ui64_value = old->ui64_value;
new->sign = old->sign;
return 1;
@@ -495,13 +507,13 @@ static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
int version(struct cmd_context *cmd, int argc, char **argv)
{
- char version[80];
+ char vsn[80];
log_print("LVM version: %s", LVM_VERSION);
- if (library_version(version, sizeof(version)))
- log_print("Library version: %s", version);
- if (driver_version(version, sizeof(version)))
- log_print("Driver version: %s", version);
+ if (library_version(vsn, sizeof(vsn)))
+ log_print("Library version: %s", vsn);
+ if (driver_version(vsn, sizeof(vsn)))
+ log_print("Driver version: %s", vsn);
return ECMD_PROCESSED;
}
@@ -572,7 +584,7 @@ static int _get_settings(struct cmd_context *cmd)
static int _process_common_commands(struct cmd_context *cmd)
{
if (arg_count(cmd, help_ARG) || arg_count(cmd, help2_ARG)) {
- usage(cmd->command->name);
+ _usage(cmd->command->name);
return ECMD_PROCESSED;
}
@@ -606,7 +618,7 @@ int help(struct cmd_context *cmd, int argc, char **argv)
else {
int i;
for (i = 0; i < argc; i++)
- usage(argv[i]);
+ _usage(argv[i]);
}
return 0;
@@ -646,7 +658,8 @@ static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
goto bad;
if (i < (argc - 1))
- if (!pool_grow_object(cmd->mem, " ", 1)) ;
+ if (!pool_grow_object(cmd->mem, " ", 1))
+ goto bad;
}
/*
@@ -721,7 +734,7 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
pool_empty(cmd->mem);
if (ret == EINVALID_CMD_LINE && !_interactive)
- usage(cmd->command->name);
+ _usage(cmd->command->name);
return ret;
}
@@ -761,7 +774,7 @@ static void _init_rand(void)
static int _init_backup(struct cmd_context *cmd, struct config_tree *cf)
{
- int days, min;
+ uint32_t days, min;
char default_dir[PATH_MAX];
const char *dir;
@@ -777,11 +790,11 @@ static int _init_backup(struct cmd_context *cmd, struct config_tree *cf)
find_config_bool(cmd->cf->root, "backup/archive", '/',
DEFAULT_ARCHIVE_ENABLED);
- days = find_config_int(cmd->cf->root, "backup/retain_days", '/',
- DEFAULT_ARCHIVE_DAYS);
+ days = (uint32_t) find_config_int(cmd->cf->root, "backup/retain_days",
+ '/', DEFAULT_ARCHIVE_DAYS);
- min = find_config_int(cmd->cf->root, "backup/retain_min", '/',
- DEFAULT_ARCHIVE_NUMBER);
+ min = (uint32_t) find_config_int(cmd->cf->root, "backup/retain_min",
+ '/', DEFAULT_ARCHIVE_NUMBER);
if (lvm_snprintf
(default_dir, sizeof(default_dir), "%s/%s", cmd->sys_dir,
@@ -909,7 +922,7 @@ static int _run_script(struct cmd_context *cmd, int argc, char **argv)
static char *_list_cmds(const char *text, int state)
{
static int i = 0;
- static int len = 0;
+ static size_t len = 0;
/* Initialise if this is a new completion attempt */
if (!state) {
@@ -928,7 +941,7 @@ static char *_list_cmds(const char *text, int state)
static char *_list_args(const char *text, int state)
{
static int match_no = 0;
- static int len = 0;
+ static size_t len = 0;
static struct command *com;
/* Initialise if this is a new completion attempt */
@@ -946,10 +959,10 @@ static char *_list_args(const char *text, int state)
/* Look for word in list of commands */
for (j = 0; j < _num_commands; j++) {
- char *p;
+ const char *p;
char *q = s;
- p = (char *) _commands[j].name;
+ p = _commands[j].name;
while (*p == *q) {
p++;
q++;
@@ -984,7 +997,7 @@ static char *_list_args(const char *text, int state)
match_no = com->num_args;
while (match_no - com->num_args < com->num_args) {
- char *l;
+ const char *l;
l = (the_args +
com->valid_args[match_no++ - com->num_args])->long_arg;
if (*(l + 2) && !strncmp(text, l, len))
diff --git a/tools/lvmdiskscan.c b/tools/lvmdiskscan.c
index a33c128e..e83a82de 100644
--- a/tools/lvmdiskscan.c
+++ b/tools/lvmdiskscan.c
@@ -22,7 +22,7 @@ int max_len;
static int _get_max_dev_name_len(struct dev_filter *filter)
{
int len = 0;
- int max_len = 0;
+ int maxlen = 0;
struct dev_iter *iter;
struct device *dev;
@@ -34,12 +34,12 @@ static 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 > maxlen)
+ maxlen = len;
}
dev_iter_destroy(iter);
- return max_len;
+ return maxlen;
}
static void _count(struct device *dev, int *disks, int *parts)
@@ -52,8 +52,8 @@ static void _count(struct device *dev, int *disks, int *parts)
(*parts)++;
}
-static void _print(struct cmd_context *cmd, struct device *dev, uint64_t size,
- char *what)
+static void _print(struct cmd_context *cmd, const struct device *dev,
+ uint64_t size, const char *what)
{
log_print("%-*s [%15s] %s", max_len, dev_name(dev),
display_size(cmd, size / 2, SIZE_SHORT), what ? : "");
@@ -67,7 +67,7 @@ static int _check_device(struct cmd_context *cmd, struct device *dev)
if (!dev_open(dev, 0)) {
return 0;
}
- if (dev_read(dev, 0, 1, &buffer) != 1) {
+ if (dev_read(dev, __UINT64_C(0), (size_t) 1, &buffer) != 1) {
dev_close(dev);
return 0;
}
diff --git a/tools/lvrename.c b/tools/lvrename.c
index b061abd8..c4ebce76 100644
--- a/tools/lvrename.c
+++ b/tools/lvrename.c
@@ -22,9 +22,9 @@
int lvrename(struct cmd_context *cmd, int argc, char **argv)
{
- int maxlen;
+ size_t maxlen;
char *lv_name_old, *lv_name_new;
- char *vg_name, *vg_name_new, *vg_name_old;
+ const char *vg_name, *vg_name_new, *vg_name_old;
char *st;
int consistent = 1;
@@ -78,7 +78,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
maxlen = NAME_LEN - strlen(vg_name) - strlen(cmd->dev_dir) - 3;
if (strlen(lv_name_new) > maxlen) {
log_error("New logical volume path exceeds maximum length "
- "of %d!", maxlen);
+ "of %u!", maxlen);
return ECMD_FAILED;
}
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 163450b0..a02d638a 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -27,12 +27,13 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
struct dm_info info;
uint32_t extents = 0;
uint32_t size = 0;
- uint32_t stripes = 0, stripesize = 0, stripesize_extents = 0;
+ uint32_t stripes = 0, ssize = 0, stripesize_extents = 0;
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
uint32_t extents_used = 0;
uint32_t size_rest;
sign_t sign = SIGN_NONE;
- char *lv_name, *vg_name;
+ char *lv_name;
+ const char *vg_name;
char *st;
const char *cmd_name;
struct list *pvh, *segh;
@@ -58,12 +59,12 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
}
if (arg_count(cmd, extents_ARG)) {
- extents = arg_int_value(cmd, extents_ARG, 0);
+ extents = arg_uint_value(cmd, extents_ARG, 0);
sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
}
if (arg_count(cmd, size_ARG)) {
- size = arg_int_value(cmd, size_ARG, 0);
+ size = arg_uint_value(cmd, size_ARG, 0);
sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
}
@@ -125,14 +126,14 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, stripes_ARG)) {
if (vg->fid->fmt->features & FMT_SEGMENTS)
- stripes = arg_int_value(cmd, stripes_ARG, 1);
+ stripes = arg_uint_value(cmd, stripes_ARG, 1);
else
log_print("Varied striping not supported. Ignoring.");
}
if (arg_count(cmd, stripesize_ARG)) {
if (vg->fid->fmt->features & FMT_SEGMENTS)
- stripesize = 2 * arg_int_value(cmd, stripesize_ARG, 0);
+ ssize = 2 * arg_uint_value(cmd, stripesize_ARG, 0);
else
log_print("Varied stripesize not supported. Ignoring.");
}
@@ -151,7 +152,8 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
(extents % vg->extent_size);
log_print("Rounding up size to full physical extent %s",
- display_size(cmd, extents / 2, SIZE_SHORT));
+ display_size(cmd, (uint64_t) extents / 2,
+ SIZE_SHORT));
}
extents /= vg->extent_size;
@@ -184,8 +186,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
seg_size = extents - lv->le_count;
/* If extending, find stripes, stripesize & size of last segment */
- if (extents > lv->le_count &&
- !(stripes == 1 || (stripes > 1 && stripesize))) {
+ if (extents > lv->le_count && !(stripes == 1 || (stripes > 1 && ssize))) {
list_iterate(segh, &lv->segments) {
struct lv_segment *seg;
uint32_t sz, str;
@@ -195,7 +196,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
str = seg->stripes;
if ((seg_stripesize && seg_stripesize != sz
- && !stripesize) ||
+ && !ssize) ||
(seg_stripes && seg_stripes != str && !stripes)) {
log_error("Please specify number of "
"stripes (-i) and stripesize (-I)");
@@ -209,15 +210,18 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
if (!stripes)
stripes = seg_stripes;
- if (!stripesize && stripes > 1) {
+ if (!ssize && stripes > 1) {
if (seg_stripesize) {
log_print("Using stripesize of last segment "
"%dKB", seg_stripesize / 2);
- stripesize = seg_stripesize;
+ ssize = seg_stripesize;
} else {
+ ssize = find_config_int(cmd->cf->root,
+ "metadata/stripesize",
+ '/',
+ DEFAULT_STRIPESIZE) * 2;
log_print("Using default stripesize %dKB",
- STRIPE_SIZE_DEFAULT);
- stripesize = 2 * STRIPE_SIZE_DEFAULT;
+ ssize / 2);
}
}
}
@@ -226,7 +230,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
if (extents < lv->le_count) {
extents_used = 0;
- if (stripes || stripesize)
+ if (stripes || ssize)
log_error("Ignoring stripes and stripesize arguments "
"when reducing");
@@ -247,17 +251,17 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
}
seg_size = extents - extents_used;
- stripesize = seg_stripesize;
+ ssize = seg_stripesize;
stripes = seg_stripes;
}
- if (stripes > 1 && !stripesize) {
+ if (stripes > 1 && !ssize) {
log_error("Stripesize for striped segment should not be 0!");
goto error_cmdline;
}
if ((stripes > 1)) {
- if (!(stripesize_extents = stripesize / vg->extent_size))
+ if (!(stripesize_extents = ssize / vg->extent_size))
stripesize_extents = 1;
if ((size_rest = seg_size % (stripes * stripesize_extents))) {
@@ -332,26 +336,22 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
goto error;
}
- if ((resize == LV_EXTEND && argc) &&
- !(pvh = create_pv_list(cmd->mem, vg, argc - opt, argv + opt))) {
- stack;
- goto error;
- }
-
if (resize == LV_EXTEND) {
+ if (!(pvh = argc ? create_pv_list(cmd->mem, vg, argc - opt,
+ argv + opt) : &vg->pvs)) {
+ stack;
+ goto error;
+ }
+
if (!archive(vg))
goto error;
- if (!argc) {
- /* Use full list from VG */
- pvh = &vg->pvs;
- }
log_print("Extending logical volume %s to %s", lv_name,
display_size(cmd, (uint64_t)
extents * (vg->extent_size / 2),
SIZE_SHORT));
- if (!lv_extend(vg->fid, lv, stripes, stripesize,
+ if (!lv_extend(vg->fid, lv, stripes, ssize,
extents - lv->le_count, pvh))
goto error;
}
diff --git a/tools/lvscan.c b/tools/lvscan.c
index fd93d58e..27b447ae 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -29,6 +29,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
const char *active_str, *snapshot_str;
+/* FIXME Add -D arg to skip this! */
if (lv_info(lv, &info) && info.exists)
active_str = "ACTIVE ";
else
@@ -46,6 +47,8 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
display_size(cmd, lv->size / 2, SIZE_SHORT),
get_alloc_string(lv->alloc));
+ /* FIXME sprintf? */
+
lv_total++;
lv_capacity_total += lv->size;
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 189c94d3..5f33c183 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -22,8 +22,8 @@
/* FIXME Locking. PVs in VG. */
-int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
- void *handle)
+static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
+ void *handle)
{
struct volume_group *vg = NULL;
struct pv_list *pvl;
@@ -131,7 +131,7 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
backup(vg);
unlock_vg(cmd, pv->vg_name);
} else {
- if (!(pv_write(cmd, pv, &mdas, sector))) {
+ if (!(pv_write(cmd, pv, &mdas, (int64_t) sector))) {
unlock_vg(cmd, ORPHAN);
log_error("Failed to store physical volume \"%s\"",
pv_name);
@@ -154,7 +154,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
struct physical_volume *pv;
char *pv_name;
- struct list *pvh, *pvs;
+ struct list *pvh, *pvslist;
struct list mdas;
list_init(&mdas);
@@ -186,20 +186,20 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
continue;
}
total++;
- done += pvchange_single(cmd, pv, NULL);
+ done += _pvchange_single(cmd, pv, NULL);
}
} else {
log_verbose("Scanning for physical volume names");
- if (!(pvs = get_pvs(cmd))) {
+ if (!(pvslist = get_pvs(cmd))) {
return ECMD_FAILED;
}
- list_iterate(pvh, pvs) {
+ list_iterate(pvh, pvslist) {
total++;
- done += pvchange_single(cmd,
- list_item(pvh,
- struct pv_list)->pv,
- NULL);
+ done += _pvchange_single(cmd,
+ list_item(pvh,
+ struct pv_list)->pv,
+ NULL);
}
}
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 5534437d..c0b98d34 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -19,7 +19,6 @@
*/
#include "tools.h"
-#include "defaults.h"
const char _really_init[] =
"Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
@@ -78,14 +77,14 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
{
struct physical_volume *pv, *existing_pv;
struct id id, *idp = NULL;
- char *uuid;
+ const char *uuid = NULL;
uint64_t size = 0;
struct device *dev;
struct list mdas;
int pvmetadatacopies;
uint64_t pvmetadatasize;
struct volume_group *vg;
- char *restorefile;
+ const char *restorefile;
uint64_t pe_start = 0;
uint32_t extent_count = 0, extent_size = 0;
@@ -130,9 +129,10 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
if (!pvcreate_check(cmd, pv_name))
goto error;
- size = arg_uint64_value(cmd, physicalvolumesize_ARG, 0) * 2;
+ size = arg_uint64_value(cmd, physicalvolumesize_ARG, __UINT64_C(0)) * 2;
- pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
+ pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, __UINT64_C(0))
+ * 2;
if (!pvmetadatasize)
pvmetadatasize = find_config_int(cmd->cf->root,
"metadata/pvmetadatasize",
@@ -169,8 +169,8 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
log_very_verbose("Writing physical volume data to disk \"%s\"",
pv_name);
- if (!(pv_write(cmd, pv, &mdas, arg_int_value(cmd, labelsector_ARG,
- DEFAULT_LABELSECTOR)))) {
+ if (!(pv_write(cmd, pv, &mdas, arg_int64_value(cmd, labelsector_ARG,
+ DEFAULT_LABELSECTOR)))) {
log_error("Failed to write physical volume \"%s\"", pv_name);
goto error;
}
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 2bb74ea4..c6e958b4 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -20,8 +20,8 @@
#include "tools.h"
-int pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
- struct physical_volume *pv, void *handle)
+static int _pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
+ struct physical_volume *pv, void *handle)
{
uint64_t size;
@@ -82,7 +82,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- process_each_pv(cmd, argc, argv, NULL, NULL, pvdisplay_single);
+ process_each_pv(cmd, argc, argv, NULL, NULL, _pvdisplay_single);
return 0;
}
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 3410378f..f23ed7d8 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -19,7 +19,6 @@
*/
#include "tools.h"
-#include "defaults.h"
const char _really_wipe[] =
"Really WIPE LABELS from physical volume \"%s\" of volume group \"%s\" [y/n]? ";
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 395a245a..b5245871 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -23,11 +23,11 @@
int pv_max_name_len = 0;
int vg_max_name_len = 0;
-void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
- void *handle)
+static void _pvscan_display_single(struct cmd_context *cmd,
+ struct physical_volume *pv, void *handle)
{
char uuid[64];
- int vg_name_len = 0;
+ unsigned int vg_name_len = 0;
char pv_tmp_name[NAME_LEN] = { 0, };
char vg_tmp_name[NAME_LEN] = { 0, };
@@ -81,10 +81,10 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
"[%s / %s free]",
pv_max_name_len, pv_tmp_name,
vg_name_this,
- display_size(cmd, pv->pe_count *
- pv->pe_size / 2,
- SIZE_SHORT),
- display_size(cmd, (pv->pe_count - pv->pe_alloc_count)
+ display_size(cmd, (uint64_t) pv->pe_count *
+ pv->pe_size / 2, SIZE_SHORT),
+ display_size(cmd, (uint64_t) (pv->pe_count -
+ pv->pe_alloc_count)
* pv->pe_size / 2, SIZE_SHORT));
return;
}
@@ -94,10 +94,12 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
pv_tmp_name, vg_max_name_len, vg_tmp_name,
pv->fmt ? pv->fmt->name : " ",
- display_size(cmd, pv->pe_count * pv->pe_size / 2, SIZE_SHORT),
- display_size(cmd,
- (pv->pe_count - pv->pe_alloc_count) * pv->pe_size / 2,
- SIZE_SHORT));
+ display_size(cmd, (uint64_t) pv->pe_count * pv->pe_size / 2,
+ SIZE_SHORT), display_size(cmd, (uint64_t)
+ (pv->pe_count -
+ pv->pe_alloc_count) *
+ pv->pe_size / 2,
+ SIZE_SHORT));
return;
}
@@ -106,7 +108,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
int new_pvs_found = 0;
int pvs_found = 0;
- struct list *pvs;
+ struct list *pvslist;
struct list *pvh;
struct pv_list *pvl;
struct physical_volume *pv;
@@ -135,11 +137,11 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
cache_destroy();
log_verbose("Walking through all physical volumes");
- if (!(pvs = get_pvs(cmd)))
+ if (!(pvslist = get_pvs(cmd)))
return ECMD_FAILED;
/* eliminate exported/new if required */
- list_iterate(pvh, pvs) {
+ list_iterate(pvh, pvslist) {
pvl = list_item(pvh, struct pv_list);
pv = pvl->pv;
@@ -173,7 +175,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
/* find maximum pv name length */
pv_max_name_len = vg_max_name_len = 0;
- list_iterate(pvh, pvs) {
+ list_iterate(pvh, pvslist) {
pv = list_item(pvh, struct pv_list)->pv;
len = strlen(dev_name(pv->dev));
if (pv_max_name_len < len)
@@ -185,9 +187,9 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
pv_max_name_len += 2;
vg_max_name_len += 2;
- list_iterate(pvh, pvs)
- pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv,
- NULL);
+ list_iterate(pvh, pvslist)
+ _pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv,
+ NULL);
if (!pvs_found) {
log_print("No matching physical volumes found");
diff --git a/tools/report.c b/tools/report.c
index 21b4afc1..4b6e0177 100644
--- a/tools/report.c
+++ b/tools/report.c
@@ -20,7 +20,6 @@
#include "tools.h"
#include "report.h"
-#include "defaults.h"
static int _vgs_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent, void *handle)
@@ -83,8 +82,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
report_type_t report_type)
{
void *report_handle;
- char *opts, *str;
- const char *keys, *options, *separator;
+ const char *opts;
+ char *str;
+ const char *keys = NULL, *options = NULL, *separator;
int aligned, buffered, headings;
@@ -156,12 +156,11 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
return 0;
}
if (*opts == '+') {
- *opts = ',';
- str =
- pool_alloc(cmd->mem,
- strlen(options) + strlen(opts) + 1);
+ str = pool_alloc(cmd->mem,
+ strlen(options) + strlen(opts) + 1);
strcpy(str, options);
- strcat(str, opts);
+ strcat(str, ",");
+ strcat(str, opts + 1);
options = str;
} else
options = opts;
diff --git a/tools/toollib.c b/tools/toollib.c
index 80d0fbee..54fbb1ac 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -70,7 +70,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
struct logical_volume *lv;
struct lv_list *lvl;
- char *vgname;
+ const char *vgname;
if (argc) {
log_verbose("Using logical volume(s) on command line");
@@ -326,7 +326,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
struct pv_list *pvl;
struct physical_volume *pv;
- struct list *pvs, *pvh;
+ struct list *pvslist, *pvh;
if (argc) {
log_verbose("Using physical volume(s) on command line");
@@ -359,10 +359,10 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
process_each_pv_in_vg(cmd, vg, handle, process_single);
} else {
log_verbose("Scanning for physical volume names");
- if (!(pvs = get_pvs(cmd)))
+ if (!(pvslist = get_pvs(cmd)))
return ECMD_FAILED;
- list_iterate(pvh, pvs) {
+ list_iterate(pvh, pvslist) {
pv = list_item(pvh, struct pv_list)->pv;
ret = process_single(cmd, NULL, pv, handle);
if (ret > ret_max)
@@ -374,9 +374,9 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
return ret_max;
}
-char *extract_vgname(struct cmd_context *cmd, char *lv_name)
+const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
{
- char *vg_name = lv_name;
+ const char *vg_name = lv_name;
char *st;
char *dev_dir = cmd->dev_dir;
diff --git a/tools/toollib.h b/tools/toollib.h
index 9390ff3e..45cb8573 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -72,7 +72,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
void *handle));
char *default_vgname(struct cmd_context *cmd);
-char *extract_vgname(struct cmd_context *cmd, char *lv_name);
+const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
/*
* Builds a list of pv's from the names in argv. Used in
diff --git a/tools/tools.h b/tools/tools.h
index 7e5fc9b7..7f131b2d 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -9,10 +9,14 @@
#define _GNU_SOURCE
+#include <assert.h>
+
+#include "log.h"
#include "activate.h"
#include "archive.h"
#include "cache.h"
#include "config.h"
+#include "defaults.h"
#include "dbg_malloc.h"
#include "dev-cache.h"
#include "device.h"
@@ -26,20 +30,17 @@
#include "metadata.h"
#include "list.h"
#include "locking.h"
-#include "log.h"
#include "lvm-file.h"
#include "lvm-string.h"
#include "pool.h"
#include "toolcontext.h"
#include "toollib.h"
+#include <stdlib.h>
+#include <unistd.h>
#include <ctype.h>
#include <limits.h>
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include <sys/types.h>
#define CMD_LEN 256
@@ -67,13 +68,14 @@ typedef enum {
/* a global table of possible arguments */
struct arg {
- char short_arg;
- char *long_arg;
+ const char short_arg;
+ const char *long_arg;
int (*fn) (struct cmd_context * cmd, struct arg * a);
int count;
char *value;
- uint32_t i_value;
+ int32_t i_value;
+ uint32_t ui_value;
int64_t i64_value;
uint64_t ui64_value;
sign_t sign;
@@ -108,50 +110,59 @@ int units_arg(struct cmd_context *cmd, 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 const 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 const char *arg_value(struct cmd_context *cmd, int a)
{
return cmd->args[a].value;
}
-static inline char *arg_str_value(struct cmd_context *cmd, int a, char *def)
+static inline const char *arg_str_value(struct cmd_context *cmd, int a,
+ const 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 const int32_t arg_int_value(struct cmd_context *cmd, int a,
+ const int32_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
}
-static inline int64_t arg_int64_value(struct cmd_context *cmd, int a,
- uint64_t def)
+static inline const uint32_t arg_uint_value(struct cmd_context *cmd, int a,
+ const uint32_t def)
+{
+ return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
+}
+
+static inline const int64_t arg_int64_value(struct cmd_context *cmd, int a,
+ const uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
}
-static inline uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
- uint64_t def)
+static inline const uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
+ const uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
}
-static inline void *arg_ptr_value(struct cmd_context *cmd, int a, void *def)
+static inline const void *arg_ptr_value(struct cmd_context *cmd, int a,
+ const void *def)
{
return arg_count(cmd, a) ? cmd->args[a].ptr : def;
}
-static inline sign_t arg_sign_value(struct cmd_context *cmd, int a, sign_t def)
+static inline const sign_t arg_sign_value(struct cmd_context *cmd, int a,
+ const sign_t def)
{
return arg_count(cmd, a) ? cmd->args[a].sign : def;
}
-static inline int arg_count_increment(struct cmd_context *cmd, int a)
+static inline const int arg_count_increment(struct cmd_context *cmd, int a)
{
return cmd->args[a].count++;
}
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 9579bef3..4c6e6085 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -43,7 +43,8 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
return count;
}
-void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
+static void _vgchange_available(struct cmd_context *cmd,
+ struct volume_group *vg)
{
int lv_open, active;
int available = !strcmp(arg_str_value(cmd, available_ARG, "n"), "y");
@@ -72,7 +73,8 @@ void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
return;
}
-void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
+static void _vgchange_resizeable(struct cmd_context *cmd,
+ struct volume_group *vg)
{
int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
@@ -106,9 +108,10 @@ void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
return;
}
-void vgchange_logicalvolume(struct cmd_context *cmd, struct volume_group *vg)
+static void _vgchange_logicalvolume(struct cmd_context *cmd,
+ struct volume_group *vg)
{
- int max_lv = arg_int_value(cmd, logicalvolume_ARG, 0);
+ uint32_t max_lv = arg_uint_value(cmd, logicalvolume_ARG, 0);
if (!(vg->status & RESIZEABLE_VG)) {
log_error("Volume group \"%s\" must be resizeable "
@@ -165,13 +168,13 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
}
if (arg_count(cmd, available_ARG))
- vgchange_available(cmd, vg);
+ _vgchange_available(cmd, vg);
if (arg_count(cmd, resizeable_ARG))
- vgchange_resizeable(cmd, vg);
+ _vgchange_resizeable(cmd, vg);
if (arg_count(cmd, logicalvolume_ARG))
- vgchange_logicalvolume(cmd, vg);
+ _vgchange_logicalvolume(cmd, vg);
return 0;
}
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 5116b382..16c5e575 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -19,7 +19,6 @@
*/
#include "tools.h"
-#include "defaults.h"
static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, int consistent,
@@ -63,7 +62,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
}
if (cmd->fmt->features & FMT_MDAS) {
- pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
+ pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG,
+ __UINT64_C(0)) * 2;
if (!pvmetadatasize)
pvmetadatasize =
find_config_int(cmd->cf->root,
@@ -122,8 +122,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
log_very_verbose("Writing physical volume data to disk \"%s\"",
dev_name(pv->dev));
if (!(pv_write(cmd, pv, &mdas,
- arg_int_value(cmd, labelsector_ARG,
- DEFAULT_LABELSECTOR)))) {
+ arg_int64_value(cmd, labelsector_ARG,
+ DEFAULT_LABELSECTOR)))) {
log_error("Failed to write physical volume \"%s\"",
dev_name(pv->dev));
log_error("Use pvcreate and vgcfgrestore to repair "
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 23a8389c..0ba620f4 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -28,7 +28,7 @@
int vgcreate(struct cmd_context *cmd, int argc, char **argv)
{
- int max_lv, max_pv;
+ size_t max_lv, max_pv;
uint32_t extent_size;
char *vg_name;
char vg_path[PATH_MAX];
@@ -46,12 +46,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
}
vg_name = argv[0];
- max_lv = arg_int_value(cmd, maxlogicalvolumes_ARG, DEFAULT_LV);
- max_pv = arg_int_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
+ max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, DEFAULT_LV);
+ max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
/* Units of 512-byte sectors */
extent_size =
- arg_int_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
+ arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
if (max_lv < 1) {
log_error("maxlogicalvolumes too low");
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index 6a705658..959edc66 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -20,8 +20,8 @@
#include "tools.h"
-int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
- const char *vg_name_from)
+static 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;
@@ -202,7 +202,7 @@ int vgmerge(struct cmd_context *cmd, int argc, char **argv)
argv++;
for (; opt < argc; opt++) {
- ret = vgmerge_single(cmd, vg_name_to, argv[opt]);
+ ret = _vgmerge_single(cmd, vg_name_to, argv[opt]);
if (ret > ret_max)
ret_max = ret;
}
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index a0855731..1132a88a 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -48,7 +48,7 @@ static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
if (pvl)
list_del(&pvl->list);
- *pv->vg_name = '\0';
+ pv->vg_name = ORPHAN;
vg->pv_count--;
vg->free_count -= pv->pe_count - pv->pe_alloc_count;
vg->extent_count -= pv->pe_count;
@@ -59,7 +59,7 @@ static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED;
}
- if (!pv_write(cmd, pv, NULL, -1)) {
+ if (!pv_write(cmd, pv, NULL, __INT64_C(-1))) {
log_error("Failed to clear metadata from physical "
"volume \"%s\" "
"after removal from \"%s\"", name, vg->name);
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 14a0fcf3..2e974474 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -63,9 +63,9 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
pv = list_item(pvh, struct pv_list)->pv;
log_verbose("Removing physical volume \"%s\" from "
"volume group \"%s\"", dev_name(pv->dev), vg_name);
- *pv->vg_name = '\0';
+ pv->vg_name = ORPHAN;
/* FIXME Write to same sector label was read from */
- if (!pv_write(cmd, pv, NULL, -1)) {
+ if (!pv_write(cmd, pv, NULL, __INT64_C(-1))) {
log_error("Failed to remove physical volume \"%s\""
" from volume group \"%s\"",
dev_name(pv->dev), vg_name);
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 50c04512..c9f84724 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -23,7 +23,7 @@
int vgrename(struct cmd_context *cmd, int argc, char **argv)
{
char *dev_dir;
- int length;
+ unsigned int length;
int consistent = 1;
char *vg_name_old, *vg_name_new;
@@ -31,7 +31,6 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
char old_path[NAME_LEN], new_path[NAME_LEN];
struct volume_group *vg_old, *vg_new;
- struct list *pvh;
if (argc != 2) {
log_error("Old and new volume group names need specifying");
@@ -124,13 +123,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
goto error;
/* Change the volume group name */
- strcpy(vg_old->name, vg_name_new);
-
- /* FIXME Should vg_write fix these implicitly? It has to check them. */
- list_iterate(pvh, &vg_old->pvs) {
- strcpy(list_item(pvh, struct pv_list)->pv->vg_name,
- vg_name_new);
- }
+ vg_rename(cmd, vg_old, vg_name_new);
sprintf(old_path, "%s%s", dev_dir, vg_name_old);
sprintf(new_path, "%s%s", dev_dir, vg_name_new);
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 00a77ff1..e95cbb2b 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -68,7 +68,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
struct lv_segment *seg;
struct physical_volume *pv;
struct volume_group *vg_with;
- int s;
+ unsigned int s;
list_iterate_safe(lvh, lvht, &vg_from->lvs) {
lv = list_item(lvh, struct lv_list)->lv;