summaryrefslogtreecommitdiffstats
path: root/sbin/mdconfig
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2013-06-20 17:01:02 +0000
committerhrs <hrs@FreeBSD.org>2013-06-20 17:01:02 +0000
commit53795e137482aa52cde35040e4111b75cb2296a1 (patch)
tree205988fbddab6a4c5d0a3699e1451ff30a0a4a63 /sbin/mdconfig
parent7d32f7dfe8a0f0c6e71a6a3de35fa0d21ca1fef4 (diff)
downloadFreeBSD-src-53795e137482aa52cde35040e4111b75cb2296a1.zip
FreeBSD-src-53795e137482aa52cde35040e4111b75cb2296a1.tar.gz
eturn -1 when the specified backing store file is not found in the md
device list. MFC after: 1 week
Diffstat (limited to 'sbin/mdconfig')
-rw-r--r--sbin/mdconfig/mdconfig.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index c04b876..28221d4 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -362,7 +362,7 @@ main(int argc, char **argv)
* Listing all devices. This is why we pass NULL
* together with OPT_LIST.
*/
- md_list(NULL, OPT_LIST | vflag, fflag);
+ return (md_list(NULL, OPT_LIST | vflag, fflag));
} else
return (md_query(uflag, vflag, fflag));
} else
@@ -408,7 +408,7 @@ md_list(const char *units, int opt, const char *fflag)
struct ggeom *gg;
struct gclass *gcl;
void *sq;
- int retcode, found;
+ int retcode, ffound, ufound;
char *type, *file, *length;
type = file = length = NULL;
@@ -423,7 +423,7 @@ md_list(const char *units, int opt, const char *fflag)
if (sq == NULL)
return (-1);
- found = 0;
+ ffound = ufound = 0;
while ((gsp = geom_stats_snapshot_next(sq)) != NULL) {
gid = geom_lookupid(&gm, gsp->id);
if (gid == NULL)
@@ -439,7 +439,7 @@ md_list(const char *units, int opt, const char *fflag)
if (retcode != 1)
continue;
else
- found = 1;
+ ufound = 1;
}
gc = &pp->lg_config;
type = geom_config_get(gc, "type");
@@ -448,6 +448,8 @@ md_list(const char *units, int opt, const char *fflag)
if (fflag != NULL &&
strcmp(fflag, file) != 0)
continue;
+ else
+ ffound = 1;
}
if (nflag && strncmp(pp->lg_name, MD_NAME, 2) == 0)
printf("%s", pp->lg_name + 2);
@@ -476,7 +478,9 @@ md_list(const char *units, int opt, const char *fflag)
printf("\n");
/* XXX: Check if it's enough to clean everything. */
geom_stats_snapshot_free(sq);
- if ((opt & OPT_UNIT) && found)
+ if (((opt & OPT_UNIT) && (fflag == NULL) && ufound) ||
+ ((opt & OPT_UNIT) == 0 && (fflag != NULL) && ffound) ||
+ ((opt & OPT_UNIT) && (fflag != NULL) && ufound && ffound))
return (0);
else
return (-1);
OpenPOWER on IntegriCloud