svn commit: r252036 - head/sbin/mdconfig
Hiroki Sato
hrs at FreeBSD.org
Thu Jun 20 17:01:02 UTC 2013
Author: hrs
Date: Thu Jun 20 17:01:02 2013
New Revision: 252036
URL: http://svnweb.freebsd.org/changeset/base/252036
Log:
eturn -1 when the specified backing store file is not found in the md
device list.
MFC after: 1 week
Modified:
head/sbin/mdconfig/mdconfig.c
Modified: head/sbin/mdconfig/mdconfig.c
==============================================================================
--- head/sbin/mdconfig/mdconfig.c Thu Jun 20 16:51:25 2013 (r252035)
+++ head/sbin/mdconfig/mdconfig.c Thu Jun 20 17:01:02 2013 (r252036)
@@ -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, cons
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, cons
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, cons
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, cons
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, cons
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);
More information about the svn-src-head
mailing list