From owner-svn-src-head@FreeBSD.ORG Thu Jun 20 17:01:02 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BF23226C; Thu, 20 Jun 2013 17:01:02 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 98C131709; Thu, 20 Jun 2013 17:01:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5KH12Xe099238; Thu, 20 Jun 2013 17:01:02 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5KH129Q099237; Thu, 20 Jun 2013 17:01:02 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201306201701.r5KH129Q099237@svn.freebsd.org> From: Hiroki Sato Date: Thu, 20 Jun 2013 17:01:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252036 - head/sbin/mdconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jun 2013 17:01:02 -0000 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);