From owner-freebsd-current@FreeBSD.ORG Mon Oct 27 13:26:25 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 805EB16A4B3 for ; Mon, 27 Oct 2003 13:26:25 -0800 (PST) Received: from smtp.omnis.com (smtp.omnis.com [216.239.128.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 038A243FE1 for ; Mon, 27 Oct 2003 13:26:25 -0800 (PST) (envelope-from wes@softweyr.com) Received: from softweyr.homeunix.net (66-91-236-204.san.rr.com [66.91.236.204]) by smtp-relay.omnis.com (Postfix) with ESMTP id B1DF95B623 for ; Mon, 27 Oct 2003 13:21:44 -0800 (PST) From: Wes Peters Organization: Softweyr To: current@freebsd.org Date: Mon, 27 Oct 2003 13:26:23 -0800 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_/1Yn/kpBvKRGMaD" Message-Id: <200310271326.23562.wes@softweyr.com> Subject: newfs by fstab directory name? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: wes@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2003 21:26:25 -0000 --Boundary-00=_/1Yn/kpBvKRGMaD Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline At work we do a lot of dynamic filesystem creation, so we added the ability to specify the 'special file' argument to newfs via the fstab mount point directory. Please see the attached patch. If nobody objects, I'll commit this in a couple of days. -- Where am I, and what am I doing in this handbasket? Wes Peters wes@softweyr.com --Boundary-00=_/1Yn/kpBvKRGMaD Content-Type: text/x-diff; charset="us-ascii"; name="foo" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="foo" Index: newfs.c =================================================================== RCS file: /big/ncvs/src/sbin/newfs/newfs.c,v retrieving revision 1.73 diff -u -r1.73 newfs.c --- newfs.c 3 May 2003 18:41:58 -0000 1.73 +++ newfs.c 27 Oct 2003 21:23:45 -0000 @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +152,7 @@ struct disklabel *lp; struct partition oldpartition; struct stat st; + struct fstab *fst; char *cp, *special; int ch, i; off_t mediasize; @@ -264,15 +266,19 @@ usage(); special = argv[0]; - cp = strrchr(special, '/'); - if (cp == 0) { - /* - * No path prefix; try prefixing _PATH_DEV. - */ - snprintf(device, sizeof(device), "%s%s", _PATH_DEV, special); - special = device; + if ((fst = getfsfile(special)) != NULL) + special = strdup(fst->fs_spec); + else { + cp = strrchr(special, '/'); + if (cp == 0) { + /* + * No path prefix; try prefixing _PATH_DEV. + */ + snprintf(device, sizeof(device), "%s%s", _PATH_DEV, + special); + special = device; + } } - if (ufs_disk_fillout_blank(&disk, special) == -1 || (!Nflag && ufs_disk_write(&disk) == -1)) { if (disk.d_error != NULL) Index: newfs.8 =================================================================== RCS file: /big/ncvs/src/sbin/newfs/newfs.8,v retrieving revision 1.64 diff -u -r1.64 newfs.8 --- newfs.8 11 Oct 2003 08:24:07 -0000 1.64 +++ newfs.8 27 Oct 2003 21:17:17 -0000 @@ -74,7 +74,11 @@ as the .Dq disk , although the special file need not be a physical disk. -In fact, it need not even be special.) +In fact, it need not even be special.) The special file argument +may also reference a directory the filesystem is normally mounted +on, as configured in +.Pa /etc/fstab . +.Pp Typically the defaults are reasonable, however .Nm has numerous options to allow the defaults to be selectively overridden. --Boundary-00=_/1Yn/kpBvKRGMaD--