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                                               [EMAIL PROTECTED]
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 <ctype.h>
 #include <err.h>
 #include <errno.h>
+#include <fstab.h>
 #include <paths.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -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.
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to