From owner-svn-src-head@FreeBSD.ORG Sat Jan 10 17:17:19 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 234F610656C7; Sat, 10 Jan 2009 17:17:19 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 103C98FC16; Sat, 10 Jan 2009 17:17:19 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0AHHIA5004168; Sat, 10 Jan 2009 17:17:18 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0AHHIMM004165; Sat, 10 Jan 2009 17:17:18 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <200901101717.n0AHHIMM004165@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 10 Jan 2009 17:17:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187027 - in head: sbin/mdconfig sys/dev/md X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 10 Jan 2009 17:17:20 -0000 Author: trasz Date: Sat Jan 10 17:17:18 2009 New Revision: 187027 URL: http://svn.freebsd.org/changeset/base/187027 Log: Add the possibility to specify "-o force" with "mdconfig -du". Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: head/sbin/mdconfig/mdconfig.8 head/sbin/mdconfig/mdconfig.c head/sys/dev/md/md.c Modified: head/sbin/mdconfig/mdconfig.8 ============================================================================== --- head/sbin/mdconfig/mdconfig.8 Sat Jan 10 16:57:22 2009 (r187026) +++ head/sbin/mdconfig/mdconfig.8 Sat Jan 10 17:17:18 2009 (r187027) @@ -62,6 +62,7 @@ .Nm .Fl d .Fl u Ar unit +.Op Fl o Oo Cm no Oc Ns Ar force .Nm .Fl l .Op Fl n Modified: head/sbin/mdconfig/mdconfig.c ============================================================================== --- head/sbin/mdconfig/mdconfig.c Sat Jan 10 16:57:22 2009 (r187026) +++ head/sbin/mdconfig/mdconfig.c Sat Jan 10 17:17:18 2009 (r187027) @@ -58,7 +58,7 @@ usage() "usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n" " [-s size] [-S sectorsize] [-u unit]\n" " [-x sectors/track] [-y heads/cyl]\n" -" mdconfig -d -u unit\n" +" mdconfig -d -u unit [-o [no]force]\n" " mdconfig -l [-v] [-n] [-u unit]\n"); fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n"); fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n"); @@ -160,6 +160,16 @@ main(int argc, char **argv) close(fd); break; case 'o': + if (action == DETACH) { + if (!strcmp(optarg, "force")) + mdio.md_options |= MD_FORCE; + else if (!strcmp(optarg, "noforce")) + mdio.md_options &= ~MD_FORCE; + else + errx(1, "Unknown option: %s.", optarg); + break; + } + if (cmdline != 2) usage(); if (!strcmp(optarg, "async")) Modified: head/sys/dev/md/md.c ============================================================================== --- head/sys/dev/md/md.c Sat Jan 10 16:57:22 2009 (r187026) +++ head/sys/dev/md/md.c Sat Jan 10 17:17:18 2009 (r187027) @@ -1133,13 +1133,15 @@ xmdctlioctl(struct cdev *dev, u_long cmd mdinit(sc); return (0); case MDIOCDETACH: - if (mdio->md_mediasize != 0 || mdio->md_options != 0) + if (mdio->md_mediasize != 0 || + (mdio->md_options & ~MD_FORCE) != 0) return (EINVAL); sc = mdfind(mdio->md_unit); if (sc == NULL) return (ENOENT); - if (sc->opencount != 0 && !(sc->flags & MD_FORCE)) + if (sc->opencount != 0 && !(sc->flags & MD_FORCE) && + !(mdio->md_options & MD_FORCE)) return (EBUSY); return (mddestroy(sc, td)); case MDIOCQUERY: