diff options
author | Hiroki Sato <hrs@FreeBSD.org> | 2013-06-20 17:01:02 +0000 |
---|---|---|
committer | Hiroki Sato <hrs@FreeBSD.org> | 2013-06-20 17:01:02 +0000 |
commit | dc017e34013bdb2e1c4cd665674adc8ab1802d3e (patch) | |
tree | 205988fbddab6a4c5d0a3699e1451ff30a0a4a63 /sbin | |
parent | b78ae23fdd506b0f2f67d6206cb28d0a0b295cd7 (diff) | |
download | src-dc017e34013bdb2e1c4cd665674adc8ab1802d3e.tar.gz src-dc017e34013bdb2e1c4cd665674adc8ab1802d3e.zip |
eturn -1 when the specified backing store file is not found in the md
device list.
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=252036
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mdconfig/mdconfig.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index c04b876e0072..28221d48993e 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); |