mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
More consistent error code usage.
This commit is contained in:
parent
0cf96f33ea
commit
cfb7bfc7d9
@ -7,9 +7,9 @@
|
||||
#ifndef _LVM_ERRORS_H
|
||||
#define _LVM_ERRORS_H
|
||||
|
||||
#define EINVALID_CMD_LINE 1
|
||||
#define ENO_SUCH_CMD 3
|
||||
#define ECMD_PROCESSED 4
|
||||
#define ECMD_PROCESSED 1
|
||||
#define ENO_SUCH_CMD 2
|
||||
#define EINVALID_CMD_LINE 3
|
||||
#define ECMD_FAILED 5
|
||||
|
||||
#endif
|
||||
|
@ -376,7 +376,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (!lvchange_availability(cmd, lv))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int lvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -563,11 +563,11 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
memset(&lp, 0, sizeof(lp));
|
||||
|
||||
if (!_read_params(&lp, cmd, argc, argv))
|
||||
return -EINVALID_CMD_LINE;
|
||||
return EINVALID_CMD_LINE;
|
||||
|
||||
if (!lock_vol(cmd, lp.vg_name, LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for %s", lp.vg_name);
|
||||
return 0;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!_lvcreate(cmd, &lp)) {
|
||||
@ -575,7 +575,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
r = 0;
|
||||
r = ECMD_PROCESSED;
|
||||
|
||||
out:
|
||||
unlock_vg(cmd, lp.vg_name);
|
||||
|
@ -31,7 +31,7 @@ static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
lvdisplay_segments(lv);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -22,6 +22,6 @@
|
||||
|
||||
int lvmchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
log_print("With the device mapper, this program is obsolete.");
|
||||
return 0;
|
||||
log_print("With LVM2 and the device mapper, this program is obsolete.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter))) {
|
||||
log_error("dev_iter_create failed");
|
||||
return 0;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
/* Do scan */
|
||||
@ -135,5 +135,5 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_print("%d LVM physical volume%s",
|
||||
pv_parts_found, pv_parts_found == 1 ? "" : "s");
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
lv->name) == 'n') {
|
||||
log_print("Logical volume \"%s\" not removed",
|
||||
lv->name);
|
||||
return 0;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return ECMD_FAILED;
|
||||
|
||||
log_print("Logical volume \"%s\" successfully removed", lv->name);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int lvremove(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -184,7 +184,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_print("Renamed \"%s\" to \"%s\" in volume group \"%s\"",
|
||||
lv_name_old, lv_name_new, vg_name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, vg_name);
|
||||
|
@ -401,7 +401,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
log_print("Logical volume %s successfully resized", lv_name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, vg_name);
|
||||
|
@ -51,7 +51,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
lv_capacity_total += lv->size;
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int lvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -206,5 +206,5 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
done, done > 1 ? "s" : "",
|
||||
total - done, total - done > 1 ? "s" : "");
|
||||
|
||||
return 0;
|
||||
return (total == done) ? ECMD_PROCESSED : ECMD_FAILED;
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
void *handle)
|
||||
static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
void *handle)
|
||||
{
|
||||
struct physical_volume *pv, *existing_pv;
|
||||
struct id id, *idp = NULL;
|
||||
@ -92,12 +92,12 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
if (arg_count(cmd, uuidstr_ARG)) {
|
||||
uuid = arg_str_value(cmd, uuidstr_ARG, "");
|
||||
if (!id_read_format(&id, uuid))
|
||||
return;
|
||||
return EINVALID_CMD_LINE;
|
||||
if ((dev = device_from_pvid(cmd, &id)) &&
|
||||
(dev != dev_cache_get(pv_name, cmd->filter))) {
|
||||
log_error("uuid %s already in use on \"%s\"", uuid,
|
||||
dev_name(dev));
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
idp = &id;
|
||||
}
|
||||
@ -109,13 +109,13 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!(vg = backup_read_vg(cmd, NULL, restorefile))) {
|
||||
log_error("Unable to read volume group from %s",
|
||||
restorefile);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
init_partial(0);
|
||||
if (!(existing_pv = find_pv_in_vg_by_uuid(vg, idp))) {
|
||||
log_error("Can't find uuid %s in backup file %s",
|
||||
uuid, restorefile);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
pe_start = existing_pv->pe_start;
|
||||
extent_size = existing_pv->pe_size;
|
||||
@ -124,7 +124,7 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
|
||||
if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!pvcreate_check(cmd, pv_name))
|
||||
@ -186,14 +186,18 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
|
||||
log_print("Physical volume \"%s\" successfully created", pv_name);
|
||||
|
||||
unlock_vg(cmd, "");
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, "");
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int i, r;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (!argc) {
|
||||
log_error("Please enter a physical volume path");
|
||||
@ -235,9 +239,10 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
pvcreate_single(cmd, argv[i], NULL);
|
||||
pool_empty(cmd->mem);
|
||||
r = pvcreate_single(cmd, argv[i], NULL);
|
||||
if (r > ret)
|
||||
ret = r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ static int _pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
if (arg_count(cmd, short_ARG)) {
|
||||
log_print("Device \"%s\" has a capacity of %s", pv_name,
|
||||
display_size(cmd, size / 2, SIZE_SHORT));
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
if (pv->status & EXPORTED_VG)
|
||||
@ -48,13 +48,13 @@ static int _pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
if (arg_count(cmd, colon_ARG)) {
|
||||
pvdisplay_colons(pv);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
pvdisplay_full(cmd, pv, handle);
|
||||
|
||||
if (!arg_count(cmd, maps_ARG))
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -82,7 +82,5 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
process_each_pv(cmd, argc, argv, NULL, NULL, _pvdisplay_single);
|
||||
|
||||
return 0;
|
||||
return process_each_pv(cmd, argc, argv, NULL, NULL, _pvdisplay_single);
|
||||
}
|
||||
|
@ -72,14 +72,14 @@ static int pvremove_check(struct cmd_context *cmd, const char *name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void pvremove_single(struct cmd_context *cmd, const char *pv_name,
|
||||
void *handle)
|
||||
static int pvremove_single(struct cmd_context *cmd, const char *pv_name,
|
||||
void *handle)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
if (!lock_vol(cmd, "", LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!pvremove_check(cmd, pv_name))
|
||||
@ -99,14 +99,18 @@ static void pvremove_single(struct cmd_context *cmd, const char *pv_name,
|
||||
log_print("Labels on physical volume \"%s\" successfully wiped",
|
||||
pv_name);
|
||||
|
||||
unlock_vg(cmd, "");
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, "");
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
int pvremove(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int i, r;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (!argc) {
|
||||
log_error("Please enter a physical volume path");
|
||||
@ -119,9 +123,10 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
pvremove_single(cmd, argv[i], NULL);
|
||||
pool_empty(cmd->mem);
|
||||
r = pvremove_single(cmd, argv[i], NULL);
|
||||
if (r > ret)
|
||||
ret = r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
if (!pvs_found) {
|
||||
log_print("No matching physical volumes found");
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
log_print("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]",
|
||||
@ -200,5 +200,5 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
display_size(cmd, (size_total - size_new) / 2, SIZE_SHORT),
|
||||
new_pvs_found, display_size(cmd, size_new / 2, SIZE_SHORT));
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ static int _vgs_single(struct cmd_context *cmd, const char *vg_name,
|
||||
if (!report_object(handle, vg, NULL, NULL, NULL))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
@ -41,7 +41,7 @@ static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (!report_object(handle, lv->vg, lv, NULL, NULL))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static int _segs_single(struct cmd_context *cmd, struct lv_segment *seg,
|
||||
@ -50,7 +50,7 @@ static int _segs_single(struct cmd_context *cmd, struct lv_segment *seg,
|
||||
if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
@ -66,12 +66,12 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", pv->vg_name);
|
||||
return 0;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
if (!(vg = vg_read(cmd, pv->vg_name, &consistent))) {
|
||||
log_error("Can't read %s: skipping", pv->vg_name);
|
||||
unlock_vg(cmd, pv->vg_name);
|
||||
return 0;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!report_object(handle, vg, NULL, pv, NULL))
|
||||
@ -79,7 +79,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
unlock_vg(cmd, pv->vg_name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
@ -89,6 +89,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
const char *opts;
|
||||
char *str;
|
||||
const char *keys = NULL, *options = NULL, *separator;
|
||||
int r = ECMD_PROCESSED;
|
||||
|
||||
int aligned, buffered, headings;
|
||||
|
||||
@ -192,27 +193,27 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
|
||||
switch (report_type) {
|
||||
case LVS:
|
||||
process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvs_single);
|
||||
r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvs_single);
|
||||
break;
|
||||
case VGS:
|
||||
process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, report_handle,
|
||||
&_vgs_single);
|
||||
r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0,
|
||||
report_handle, &_vgs_single);
|
||||
break;
|
||||
case PVS:
|
||||
process_each_pv(cmd, argc, argv, NULL, report_handle,
|
||||
&_pvs_single);
|
||||
r = process_each_pv(cmd, argc, argv, NULL, report_handle,
|
||||
&_pvs_single);
|
||||
break;
|
||||
case SEGS:
|
||||
process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvsegs_single);
|
||||
r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvsegs_single);
|
||||
break;
|
||||
}
|
||||
|
||||
report_output(report_handle);
|
||||
|
||||
report_free(report_handle);
|
||||
return ECMD_PROCESSED;
|
||||
return r;
|
||||
}
|
||||
|
||||
int lvs(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -357,6 +357,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
"found in Volume Group "
|
||||
"\"%s\"", argv[opt],
|
||||
vg->name);
|
||||
ret_max = ECMD_FAILED;
|
||||
continue;
|
||||
}
|
||||
pv = pvl->pv;
|
||||
@ -364,6 +365,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
if (!(pv = pv_read(cmd, argv[opt], NULL, NULL))) {
|
||||
log_error("Failed to read physical "
|
||||
"volume \"%s\"", argv[opt]);
|
||||
ret_max = ECMD_FAILED;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -376,7 +378,9 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
if (vg) {
|
||||
log_verbose("Using all physical volume(s) in "
|
||||
"volume group");
|
||||
process_each_pv_in_vg(cmd, vg, handle, process_single);
|
||||
ret = process_each_pv_in_vg(cmd, vg, handle, process_single);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
} else {
|
||||
log_verbose("Scanning for physical volume names");
|
||||
if (!(pvslist = get_pvs(cmd)))
|
||||
|
@ -38,7 +38,7 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
log_print("Volume group \"%s\" successfully backed up.", vg_name);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -33,7 +33,7 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
|
||||
if (!archive_display(cmd, vg_name))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, ORPHAN, LCK_VG_WRITE)) {
|
||||
@ -61,5 +61,5 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
unlock_vg(cmd, vg_name);
|
||||
unlock_vg(cmd, ORPHAN);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
|
||||
return count;
|
||||
}
|
||||
|
||||
static void _vgchange_available(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
static int _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");
|
||||
@ -66,7 +66,7 @@ static void _vgchange_available(struct cmd_context *cmd,
|
||||
if (!available && (lv_open = lvs_in_vg_opened(vg))) {
|
||||
log_error("Can't deactivate volume group \"%s\" with %d open "
|
||||
"logical volume(s)", vg->name, lv_open);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (available && (active = lvs_in_vg_activated(vg)))
|
||||
@ -83,28 +83,28 @@ static void _vgchange_available(struct cmd_context *cmd,
|
||||
|
||||
log_print("%d logical volume(s) in volume group \"%s\" now active",
|
||||
lvs_in_vg_activated(vg), vg->name);
|
||||
return;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static void _vgchange_resizeable(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
static int _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);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!resizeable && !(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" is already not resizeable",
|
||||
vg->name);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!archive(vg))
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
|
||||
if (resizeable)
|
||||
vg->status |= RESIZEABLE_VG;
|
||||
@ -112,52 +112,54 @@ static void _vgchange_resizeable(struct cmd_context *cmd,
|
||||
vg->status &= ~RESIZEABLE_VG;
|
||||
|
||||
if (!vg_write(vg) || !vg_commit(vg))
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
|
||||
backup(vg);
|
||||
|
||||
log_print("Volume group \"%s\" successfully changed", vg->name);
|
||||
|
||||
return;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static void _vgchange_logicalvolume(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
static int _vgchange_logicalvolume(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
uint32_t max_lv = arg_uint_value(cmd, logicalvolume_ARG, 0);
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" must be resizeable "
|
||||
"to change MaxLogicalVolume", vg->name);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (max_lv < vg->lv_count) {
|
||||
log_error("MaxLogicalVolume is less than the current number "
|
||||
"%d of logical volume(s) for \"%s\"", vg->lv_count,
|
||||
vg->name);
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!archive(vg))
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
|
||||
vg->max_lv = max_lv;
|
||||
|
||||
if (!vg_write(vg) || !vg_commit(vg))
|
||||
return;
|
||||
return ECMD_FAILED;
|
||||
|
||||
backup(vg);
|
||||
|
||||
log_print("Volume group \"%s\" successfully changed", vg->name);
|
||||
|
||||
return;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
|
||||
struct volume_group *vg, int consistent,
|
||||
void *handle)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
if (!vg) {
|
||||
log_error("Unable to find volume group \"%s\"", vg_name);
|
||||
return ECMD_FAILED;
|
||||
@ -181,15 +183,15 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
if (arg_count(cmd, available_ARG))
|
||||
_vgchange_available(cmd, vg);
|
||||
r = _vgchange_available(cmd, vg);
|
||||
|
||||
if (arg_count(cmd, resizeable_ARG))
|
||||
_vgchange_resizeable(cmd, vg);
|
||||
else if (arg_count(cmd, resizeable_ARG))
|
||||
r = _vgchange_resizeable(cmd, vg);
|
||||
|
||||
if (arg_count(cmd, logicalvolume_ARG))
|
||||
_vgchange_logicalvolume(cmd, vg);
|
||||
else if (arg_count(cmd, logicalvolume_ARG))
|
||||
r = _vgchange_logicalvolume(cmd, vg);
|
||||
|
||||
return 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int vgchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -38,8 +38,7 @@ static int vgck_single(struct cmd_context *cmd, const char *vg_name,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
/* FIXME: free */
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgck(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -153,7 +153,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
if (test_mode()) {
|
||||
log_verbose("Test mode: Skipping metadata writing for VG %s in"
|
||||
" format %s", vg_name, cmd->fmt->name);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
log_verbose("Writing metadata for VG %s using format %s", vg_name,
|
||||
@ -168,7 +168,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
backup(vg);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgconvert(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -127,5 +127,5 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
log_print("Volume group \"%s\" successfully created", vg->name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
if (arg_count(cmd, colon_ARG)) {
|
||||
vgdisplay_colons(vg);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, short_ARG)) {
|
||||
vgdisplay_short(vg);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
vgdisplay_full(vg); /* was vg_show */
|
||||
@ -57,7 +57,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
|
||||
process_each_pv_in_vg(cmd, vg, NULL, &pvdisplay_short);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -62,7 +62,7 @@ static int vgexport_single(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
log_print("Volume group \"%s\" successfully exported", vg->name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
return ECMD_FAILED;
|
||||
|
@ -102,7 +102,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
log_print("Volume group \"%s\" successfully extended", vg_name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, vg_name);
|
||||
|
@ -52,7 +52,7 @@ static int vgimport_single(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
log_print("Volume group \"%s\" successfully imported", vg->name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
return ECMD_FAILED;
|
||||
|
@ -177,7 +177,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
|
||||
log_print("Volume group \"%s\" successfully merged into \"%s\"",
|
||||
vg_from->name, vg_to->name);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, vg_name_from);
|
||||
|
@ -220,7 +220,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -26,7 +26,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
{
|
||||
struct physical_volume *pv;
|
||||
struct pv_list *pvl;
|
||||
int ret = 0;
|
||||
int ret = ECMD_PROCESSED;
|
||||
|
||||
if (!vg || !consistent) {
|
||||
log_error("Volume group \"%s\" doesn't exist", vg_name);
|
||||
|
@ -151,7 +151,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_print("Volume group \"%s\" successfully renamed to \"%s\"",
|
||||
vg_name_old, vg_name_new);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, vg_name_new);
|
||||
|
@ -40,7 +40,7 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
|
||||
(vg->status & EXPORTED_VG) ? "exported " : "", vg_name,
|
||||
vg->fid->fmt->name);
|
||||
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int vgscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
@ -287,7 +287,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
log_print("Volume group \"%s\" successfully split from \"%s\"",
|
||||
vg_to->name, vg_from->name);
|
||||
return 0;
|
||||
return ECMD_PROCESSED;
|
||||
|
||||
error:
|
||||
unlock_vg(cmd, vg_name_from);
|
||||
|
Loading…
x
Reference in New Issue
Block a user