1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Fix return values for reporting commands when run with no PVs, LVs, or VGs.

The new error checking code caught some commands that were returning '0' as
an exit status for success.  This is incorrect and resulted in a benign error
message displayed (see below).  As of today, all commands should return a
value defined in lib/commands/errors.h (1-5).  This results in an exit code of
0 on success, or > 0 on failure (as stated in the lvm.8 man page).

Before change:
1. Make sure no PVs are on the system
2. Run 'pvs'
  Command failed with status code 0.

After change:
<no output>
This commit is contained in:
Dave Wysochanski 2008-06-10 20:07:04 +00:00
parent a3678fa186
commit 3a30d1db20
3 changed files with 11 additions and 10 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.38 - Version 2.02.38 -
================================= =================================
Fix return values for reporting commands when run with no PVs, LVs, or VGs.
Add omitted unlock_vg() call when sigint_caught() during vg processing. Add omitted unlock_vg() call when sigint_caught() during vg processing.
Fix wrong free_count on imported vg from pool device Fix wrong free_count on imported vg from pool device
Fix segfault when calling pvcreate on the pool device Fix segfault when calling pvcreate on the pool device

View File

@ -145,7 +145,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
void *handle, void *handle,
process_single_lv_fn_t process_single) process_single_lv_fn_t process_single)
{ {
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret = 0; int ret = 0;
unsigned process_all = 0; unsigned process_all = 0;
unsigned process_lv = 0; unsigned process_lv = 0;
@ -223,7 +223,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
void *handle)) void *handle))
{ {
int opt = 0; int opt = 0;
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret = 0; int ret = 0;
int consistent; int consistent;
@ -421,7 +421,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
{ {
struct pv_segment *pvseg; struct pv_segment *pvseg;
const char *vg_name = NULL; const char *vg_name = NULL;
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret; int ret;
if (!vg && !is_orphan(pv)) { if (!vg && !is_orphan(pv)) {
@ -456,7 +456,7 @@ int process_each_segment_in_lv(struct cmd_context *cmd,
void *handle)) void *handle))
{ {
struct lv_segment *seg; struct lv_segment *seg;
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret; int ret;
list_iterate_items(seg, &lv->segments) { list_iterate_items(seg, &lv->segments) {
@ -464,7 +464,7 @@ int process_each_segment_in_lv(struct cmd_context *cmd,
if (ret > ret_max) if (ret > ret_max)
ret_max = ret; ret_max = ret;
if (sigint_caught()) if (sigint_caught())
return ret_max; break;
} }
return ret_max; return ret_max;
@ -527,7 +527,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int consistent, void *handle)) int consistent, void *handle))
{ {
int opt = 0; int opt = 0;
int ret_max = 0; int ret_max = ECMD_PROCESSED;
struct str_list *sl; struct str_list *sl;
struct list *vgnames, *vgids; struct list *vgnames, *vgids;
@ -613,7 +613,7 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
const struct list *tags, void *handle, const struct list *tags, void *handle,
process_single_pv_fn_t process_single) process_single_pv_fn_t process_single)
{ {
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret = 0; int ret = 0;
struct pv_list *pvl; struct pv_list *pvl;
@ -642,7 +642,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
struct dev_iter *iter; struct dev_iter *iter;
struct device *dev; struct device *dev;
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret = 0; int ret = 0;
if (!scan_vgs_for_pvs(cmd)) { if (!scan_vgs_for_pvs(cmd)) {
@ -684,7 +684,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
void *handle)) void *handle))
{ {
int opt = 0; int opt = 0;
int ret_max = 0; int ret_max = ECMD_PROCESSED;
int ret = 0; int ret = 0;
struct pv_list *pvl; struct pv_list *pvl;

View File

@ -113,5 +113,5 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
} }
************/ ************/
return 0; return ECMD_PROCESSED;
} }