Fix exit code when using -l on a non-existent md(4) device.
PR: conf/116177 Submitted by: Remi Guyomarch <rguyom@pobox.com> MFC after: 3 days
This commit is contained in:
parent
d949071d71
commit
69fcb5379c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173676
@ -284,7 +284,7 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
md_list(NULL, OPT_LIST);
|
md_list(NULL, OPT_LIST);
|
||||||
} else {
|
} else {
|
||||||
md_query(mdunit);
|
return (md_query(mdunit));
|
||||||
}
|
}
|
||||||
} else if (action == ATTACH) {
|
} else if (action == ATTACH) {
|
||||||
if (cmdline < 2)
|
if (cmdline < 2)
|
||||||
@ -323,7 +323,7 @@ md_list(char *units, int opt)
|
|||||||
struct ggeom *gg;
|
struct ggeom *gg;
|
||||||
struct gclass *gcl;
|
struct gclass *gcl;
|
||||||
void *sq;
|
void *sq;
|
||||||
int retcode;
|
int retcode, found;
|
||||||
char *type, *file, *length;
|
char *type, *file, *length;
|
||||||
|
|
||||||
type = file = length = NULL;
|
type = file = length = NULL;
|
||||||
@ -338,6 +338,7 @@ md_list(char *units, int opt)
|
|||||||
if (sq == NULL)
|
if (sq == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
found = 0;
|
||||||
while ((gsp = geom_stats_snapshot_next(sq)) != NULL) {
|
while ((gsp = geom_stats_snapshot_next(sq)) != NULL) {
|
||||||
gid = geom_lookupid(&gm, gsp->id);
|
gid = geom_lookupid(&gm, gsp->id);
|
||||||
if (gid == NULL)
|
if (gid == NULL)
|
||||||
@ -352,6 +353,8 @@ md_list(char *units, int opt)
|
|||||||
retcode = md_find(units, pp->lg_name);
|
retcode = md_find(units, pp->lg_name);
|
||||||
if (retcode != 1)
|
if (retcode != 1)
|
||||||
continue;
|
continue;
|
||||||
|
else
|
||||||
|
found = 1;
|
||||||
}
|
}
|
||||||
gc = &pp->lg_config;
|
gc = &pp->lg_config;
|
||||||
printf("%s", pp->lg_name);
|
printf("%s", pp->lg_name);
|
||||||
@ -380,7 +383,10 @@ md_list(char *units, int opt)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
/* XXX: Check if it's enough to clean everything. */
|
/* XXX: Check if it's enough to clean everything. */
|
||||||
geom_stats_snapshot_free(sq);
|
geom_stats_snapshot_free(sq);
|
||||||
return (-1);
|
if ((opt & OPT_UNIT) && found)
|
||||||
|
return (0);
|
||||||
|
else
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user