From root@gits.dyndns.org  Wed Feb 21 19:56:24 2001
Return-Path: <root@gits.dyndns.org>
Received: from racine.cybercable.fr (racine.cybercable.fr [212.198.0.201])
	by hub.freebsd.org (Postfix) with SMTP id 49D2637B4EC
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 21 Feb 2001 19:56:23 -0800 (PST)
	(envelope-from root@gits.dyndns.org)
Received: (qmail 8106045 invoked from network); 22 Feb 2001 03:56:20 -0000
Received: from d165.dhcp212-231.cybercable.fr (HELO gits.dyndns.org) ([212.198.231.165]) (envelope-sender <root@gits.dyndns.org>)
          by racine.cybercable.fr (qmail-ldap-1.03) with SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 22 Feb 2001 03:56:20 -0000
Received: (from root@localhost)
	by gits.dyndns.org (8.11.2/8.11.2) id f1M3uFh62808;
	Thu, 22 Feb 2001 04:56:15 +0100 (CET)
	(envelope-from root)
Message-Id: <200102220356.f1M3uFh62808@gits.dyndns.org>
Date: Thu, 22 Feb 2001 04:56:15 +0100 (CET)
From: Cyrille Lefevre <clefevre@poboxes.com>
Reply-To: clefevre@poboxes.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: add fs type feature to vnconfig(8) to allow direct mount of iso images and co.
X-Send-Pr-Version: 3.2

>Number:         25273
>Category:       bin
>Synopsis:       add fs type feature to vnconfig(8) to allow direct mount of iso images and co.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 21 20:00:07 PST 2001
>Closed-Date:    Sun Sep 11 16:32:44 GMT 2005
>Last-Modified:  Sun Sep 11 16:32:44 GMT 2005
>Originator:     Cyrille Lefevre
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
ACME
>Environment:

FreeBSD gits 4.2-STABLE FreeBSD 4.2-STABLE #7: Tue Jan 23 07:33:34 CET 2001     root@gits:/disk2/4.x-stable/src/sys/compile/CUSTOM  i386

>Description:

	currently, it is not possible to mount an iso image
	in one pass using vnconfig such as :

	vnconfig -v -e vn0 /tmp/image.iso mountro=/mnt

	effectively, the -e option mount such image using the
	hard coded fs type which is ufs.

	so, to mount an iso image, you have to do the following
	statement :

	vnconfig -c vn0 /tmp/image.iso
	mount -t cd9660 vn0 /iso

	while it could be possible to do something like :

	vnconfig -v -e vn0 /tmp/image.iso mountro=/mnt type=cd9660

	or

	vnconfig -v -e vn0 /tmp/image.iso mountro=/mnt,cd9660

	using the first syntax, the ignore feature has precedence
	over the swap feature which has precedence over the mount*
	features.

	also, these patches correct two bugs in what_opt (-s none
	was a do nothing statement !) and config (the fclose is
	done too late and prevent the fs to be mounted).

>How-To-Repeat:

	already desbribed above.

>Fix:

	I provide two patches, the first one provides the first
	proposed syntax and the second one provides the second
	proposed syntax (the one I prefer).

----------==========---------- first patch ----------==========----------

Index: vnconfig.8
===================================================================
RCS file: /home/ncvs/src/usr.sbin/vnconfig/vnconfig.8,v
retrieving revision 1.14.2.4
diff -u -r1.14.2.4 vnconfig.8
--- vnconfig.8	2000/12/27 16:23:31	1.14.2.4
+++ vnconfig.8	2001/02/22 03:52:12
@@ -188,6 +188,12 @@
 .Xr mount 2 .
 .It Dv Pf mount= Pa mount_point
 Same as ``mountrw=''.
+.It Dv Pf type= Pa fstype
+Mounts the file system as type
+.Ar fstype .
+The type
+.Ar ufs
+is the default.
 .El
 .Pp
 A configuration file contains one line per device/file pair in the form:
@@ -217,6 +223,12 @@
 Configures
 .Pa vn0c
 and enables swapping on it.
+.Pp
+.Dl vnconfig -e vn0c myisoimage mountro=/iso type=cd9660
+.Pp
+Configures
+.Pa vn0c
+and read-only mounts an ISO-9660 image file.
 .Pp
 .Dl vnconfig -d vn0c myfilesystem mount=/mnt
 .Pp
Index: vnconfig.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/vnconfig/vnconfig.c,v
retrieving revision 1.13.2.4
diff -u -r1.13.2.4 vnconfig.c
--- vnconfig.c	2001/02/02 21:16:34	1.13.2.4
+++ vnconfig.c	2001/02/22 03:45:13
@@ -75,6 +75,7 @@
 	int	flags;
 	int	size;
 	char	*oarg;
+	char	*otype;
 } vndisks[MAXVNDISK];
 
 #define VN_CONFIG	0x01
@@ -222,8 +223,10 @@
 		vndisks[0].flags = flags;
 		vndisks[0].size = size;
 		vndisks[0].autolabel = autolabel;
-		if (optind < argc)
-			getoptions(&vndisks[0], argv[optind]);
+		vndisks[0].oarg = NULL;
+		vndisks[0].otype = "ufs";
+		while (optind < argc)
+			getoptions(&vndisks[0], argv[optind++]);
 		nvndisks = 1;
 	}
 	rv = 0;
@@ -242,8 +245,8 @@
 	if (!strcmp(str,"follow")) { *p |= VN_FOLLOW; return 0; }
 	if (!strcmp(str,"debug")) { *p |= VN_DEBUG; return 0; }
 	if (!strcmp(str,"io")) { *p |= VN_IO; return 0; }
-	if (!strcmp(str,"all")) { *p |= ~0; return 0; }
-	if (!strcmp(str,"none")) { *p |= 0; return 0; }
+	if (!strcmp(str,"all")) { *p = ~0; return 0; }
+	if (!strcmp(str,"none")) { *p = 0; return 0; }
 	return 1;
 }
 
@@ -251,7 +254,7 @@
 config(vnp)
 	struct vndisk *vnp;
 {
-	char *dev, *file, *oarg;
+	char *dev, *file, *oarg, *otype;
 	int flags;
 	struct vn_ioctl vnio;
 	register int rv;
@@ -272,6 +275,7 @@
 	file = vnp->file;
 	flags = vnp->flags;
 	oarg = vnp->oarg;
+	otype = vnp->otype;
 
 	if (flags & VN_IGNORE)
 		return(0);
@@ -436,6 +440,8 @@
 			printf("%s: flags now=%08lx\n",dev,l);
 	}
 
+	fclose(f);
+
 	/*
 	 * Enable special functions on the device
 	 */
@@ -446,22 +452,21 @@
 				warn("swapon");
 			else if (verbose)
 				printf("%s: swapping enabled\n", dev);
-		}
+		} else
 		if (flags & (VN_MOUNTRO|VN_MOUNTRW)) {
 			struct ufs_args args;
 			int mflags;
 
 			args.fspec = dev;
 			mflags = (flags & VN_MOUNTRO) ? MNT_RDONLY : 0;
-			rv = mount("ufs", oarg, mflags, &args);
+			rv = mount(otype, oarg, mflags, &args);
 			if (rv)
 				warn("mount");
 			else if (verbose)
-				printf("%s: mounted on %s\n", dev, oarg);
+				printf("%s: mounted on %s (%s)\n", dev, oarg, otype);
 		}
 	}
 /* done: */
-	fclose(f);
 	fflush(stdout);
 	return(rv < 0);
 }
@@ -509,15 +514,19 @@
 
 		if (*sp == '%' && strtol(sp + 1, NULL, 0) > 0) {
 			vndisks[ix].size = getsize(sp + 1);
+			vndisks[ix].file = NULL;
 		} else {
+			vndisks[ix].size = 0;
 			vndisks[ix].file = malloc(cp - sp);
 			strcpy(vndisks[ix].file, sp);
 		}
-
+		vndisks[ix].autolabel = NULL;
 		while (!EOL(*cp) && WHITE(*cp))
 			cp++;
 		vndisks[ix].flags = flags;
-		if (!EOL(*cp)) {
+		vndisks[ix].oarg = NULL;
+		vndisks[ix].otype = "ufs";
+		while (!EOL(*cp)) {
 			sp = cp;
 			while (!EOL(*cp) && !WHITE(*cp))
 				cp++;
@@ -536,6 +545,7 @@
 {
 	int flags = 0;
 	char *oarg = NULL;
+	char *otype = NULL;
 
 	if (strcmp(fstr, "swap") == 0)
 		flags |= VN_SWAP;
@@ -548,14 +558,18 @@
 	} else if (strncmp(fstr, "mountro=", 8) == 0) {
 		flags |= VN_MOUNTRO;
 		oarg = &fstr[8];
+	} else if (strncmp(fstr, "type=", 5) == 0) {
+		otype = &fstr[5];
 	} else if (strcmp(fstr, "ignore") == 0)
 		flags |= VN_IGNORE;
 	vnp->flags |= flags;
 	if (oarg) {
 		vnp->oarg = malloc(strlen(oarg) + 1);
 		strcpy(vnp->oarg, oarg);
-	} else
-		vnp->oarg = NULL;
+	} else if (otype) {
+		vnp->otype = malloc(strlen(otype) + 1);
+		strcpy(vnp->otype, otype);
+	}
 }
 
 char *
@@ -585,7 +599,7 @@
 {
 	fprintf(stderr, "%s\n%s\n%s\n",
 		"usage: vnconfig [-cdeguv] [-s option] [-r option] [-S value] special_file",
-		"                [regular_file] [feature]",
+		"                [regular_file] [features]",
 		"       vnconfig -a [-cdeguv] [-s option] [-r option] [-f config_file]");
 	exit(1);
 }

----------==========---------- second patch ----------==========----------

Index: vnconfig.8
===================================================================
RCS file: /home/ncvs/src/usr.sbin/vnconfig/vnconfig.8,v
retrieving revision 1.14.2.4
diff -u -r1.14.2.4 vnconfig.8
--- vnconfig.8	2000/12/27 16:23:31	1.14.2.4
+++ vnconfig.8	2001/02/22 03:42:17
@@ -176,14 +176,24 @@
 Swapping is enabled on the special file.
 See
 .Xr swapon 2 .
-.It Dv Pf mountro= Pa mount_point
+.It Dv Pf mountro= Pa mount_point[,fstype]
 The special file is mounted read-only on
-.Ar mount_point .
+.Ar mount_point
+using the file system type
+.Ar fstype
+if provided. The type
+.Ar ufs
+is the default.
 See
 .Xr mount 2 .
-.It Dv Pf mountrw= Pa mount_point
+.It Dv Pf mountrw= Pa mount_point[,fstype]
 The special file is mounted read-write on
-.Ar mount_point .
+.Ar mount_point
+using the file system type
+.Ar fstype
+if provided. The type
+.Ar ufs
+is the default.
 See
 .Xr mount 2 .
 .It Dv Pf mount= Pa mount_point
@@ -217,6 +227,12 @@
 Configures
 .Pa vn0c
 and enables swapping on it.
+.Pp
+.Dl vnconfig -e vn0c myisoimage mountro=/iso,cd9660
+.Pp
+Configures
+.Pa vn0c
+and read-only mounts an ISO-9660 image file.
 .Pp
 .Dl vnconfig -d vn0c myfilesystem mount=/mnt
 .Pp
Index: vnconfig.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/vnconfig/vnconfig.c,v
retrieving revision 1.13.2.4
diff -u -r1.13.2.4 vnconfig.c
--- vnconfig.c	2001/02/02 21:16:34	1.13.2.4
+++ vnconfig.c	2001/02/22 03:44:11
@@ -75,6 +75,7 @@
 	int	flags;
 	int	size;
 	char	*oarg;
+	char	*otype;
 } vndisks[MAXVNDISK];
 
 #define VN_CONFIG	0x01
@@ -222,6 +223,8 @@
 		vndisks[0].flags = flags;
 		vndisks[0].size = size;
 		vndisks[0].autolabel = autolabel;
+		vndisks[0].oarg = NULL;
+		vndisks[0].otype = "ufs";
 		if (optind < argc)
 			getoptions(&vndisks[0], argv[optind]);
 		nvndisks = 1;
@@ -242,8 +245,8 @@
 	if (!strcmp(str,"follow")) { *p |= VN_FOLLOW; return 0; }
 	if (!strcmp(str,"debug")) { *p |= VN_DEBUG; return 0; }
 	if (!strcmp(str,"io")) { *p |= VN_IO; return 0; }
-	if (!strcmp(str,"all")) { *p |= ~0; return 0; }
-	if (!strcmp(str,"none")) { *p |= 0; return 0; }
+	if (!strcmp(str,"all")) { *p = ~0; return 0; }
+	if (!strcmp(str,"none")) { *p = 0; return 0; }
 	return 1;
 }
 
@@ -251,7 +254,7 @@
 config(vnp)
 	struct vndisk *vnp;
 {
-	char *dev, *file, *oarg;
+	char *dev, *file, *oarg, *otype;
 	int flags;
 	struct vn_ioctl vnio;
 	register int rv;
@@ -272,6 +275,7 @@
 	file = vnp->file;
 	flags = vnp->flags;
 	oarg = vnp->oarg;
+	otype = vnp->otype;
 
 	if (flags & VN_IGNORE)
 		return(0);
@@ -436,6 +440,8 @@
 			printf("%s: flags now=%08lx\n",dev,l);
 	}
 
+	fclose(f);
+
 	/*
 	 * Enable special functions on the device
 	 */
@@ -453,15 +459,14 @@
 
 			args.fspec = dev;
 			mflags = (flags & VN_MOUNTRO) ? MNT_RDONLY : 0;
-			rv = mount("ufs", oarg, mflags, &args);
+			rv = mount(otype, oarg, mflags, &args);
 			if (rv)
 				warn("mount");
 			else if (verbose)
-				printf("%s: mounted on %s\n", dev, oarg);
+				printf("%s: mounted on %s (%s)\n", dev, oarg, otype);
 		}
 	}
 /* done: */
-	fclose(f);
 	fflush(stdout);
 	return(rv < 0);
 }
@@ -509,14 +514,18 @@
 
 		if (*sp == '%' && strtol(sp + 1, NULL, 0) > 0) {
 			vndisks[ix].size = getsize(sp + 1);
+			vndisks[ix].file = NULL;
 		} else {
+			vndisks[ix].size = 0;
 			vndisks[ix].file = malloc(cp - sp);
 			strcpy(vndisks[ix].file, sp);
 		}
-
+		vndisks[ix].autolabel = NULL;
 		while (!EOL(*cp) && WHITE(*cp))
 			cp++;
 		vndisks[ix].flags = flags;
+		vndisks[ix].oarg = NULL;
+		vndisks[ix].otype = "ufs";
 		if (!EOL(*cp)) {
 			sp = cp;
 			while (!EOL(*cp) && !WHITE(*cp))
@@ -536,6 +545,7 @@
 {
 	int flags = 0;
 	char *oarg = NULL;
+	char *otype = NULL;
 
 	if (strcmp(fstr, "swap") == 0)
 		flags |= VN_SWAP;
@@ -550,12 +560,18 @@
 		oarg = &fstr[8];
 	} else if (strcmp(fstr, "ignore") == 0)
 		flags |= VN_IGNORE;
+	if (flags & (VN_MOUNTRW|VN_MOUNTRO))
+		if (strtok(oarg, ","))
+			otype = strtok(NULL, ",");
 	vnp->flags |= flags;
 	if (oarg) {
 		vnp->oarg = malloc(strlen(oarg) + 1);
 		strcpy(vnp->oarg, oarg);
-	} else
-		vnp->oarg = NULL;
+	}
+	if (otype) {
+		vnp->otype = malloc(strlen(otype) + 1);
+		strcpy(vnp->otype, otype);
+	}
 }
 
 char *
>Release-Note:
>Audit-Trail:

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: clefevre@poboxes.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/25273: add fs type feature to vnconfig(8) to allow direct mount of iso images and co. 
Date: Thu, 22 Feb 2001 07:26:23 +0100

 vnconfig(8) is being phased out.  Please consider if this can be integrated in
 mdconfig(8) in current.
 
 --
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.

From: Dima Dorfman <dima@unixfreak.org>
To: Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/25273: add fs type feature to vnconfig(8) to allow direct mount of iso images and co. 
Date: Thu, 22 Feb 2001 00:06:53 -0800

 > vnconfig(8) is being phased out.  Please consider if this can be
 > integrated in mdconfig(8) in current.
 
 mdconfig(8) can't automatically mount the filesystem it configures.  I
 offered to implement this some time ago, but noone seemed interested.
 
 					Dima Dorfman
 					dima@unixfreak.org

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: Dima Dorfman <dima@unixfreak.org>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/25273: add fs type feature to vnconfig(8) to allow direct mount of iso images and co. 
Date: Thu, 22 Feb 2001 09:17:08 +0100

 In message <20010222080653.5C9363E09@bazooka.unixfreak.org>, Dima Dorfman writes:
 >> vnconfig(8) is being phased out.  Please consider if this can be
 >> integrated in mdconfig(8) in current.
 >
 >mdconfig(8) can't automatically mount the filesystem it configures.  I
 >offered to implement this some time ago, but noone seemed interested.
 
 "send patches" doesn't count as interested in your book ?  :-)
 
 --
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.

From: Dima Dorfman <dima@unixfreak.org>
To: Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/25273: add fs type feature to vnconfig(8) to allow direct mount of iso images and co. 
Date: Thu, 22 Feb 2001 21:29:33 -0800

 > In message <20010222080653.5C9363E09@bazooka.unixfreak.org>, Dima Dorfman wri
 > tes:
 > >> vnconfig(8) is being phased out.  Please consider if this can be
 > >> integrated in mdconfig(8) in current.
 > >
 > >mdconfig(8) can't automatically mount the filesystem it configures.  I
 > >offered to implement this some time ago, but noone seemed interested.
 > 
 > "send patches" doesn't count as interested in your book ?  :-)
 
 Fair enough.  See attached.  It implements the 'feature' feature (yes,
 it's called 'feature') of vnconfig in mdconfig.  I couldn't think of a
 better name, so I also called it 'feature'.
 
 Basically, right now, this allows one to configure and mount a memory
 disk all in one shot (assuming that what you configured is a real
 filesystem, though; in other words, it only makes sense for vnode).
 Theoretically, it can be expanded to do things like automatically
 label and create a filesystem.  This also includes the functionality
 the originator asked for in this PR (although I don't think his patch
 works; see below).
 
 The only real hack in this is the way it deals with different
 filesystems having different argument structures (last argument to
 mount(2)).  This is also why I don't think the patches provided in
 this PR work; vnconfig always uses a ufs_args structure as the last
 argument to mount(2); if you're trying to mount a cd9660 filesystem,
 it will fail because iso_args is longer than ufs_args, so when the
 kernel (or something before it) tries to access one of the iso_args
 members, it will be accessing junk.  My patch solves the problem by
 defining a union of all the argument structures (okay, not all of
 them, just the ones I thought would make sense in this context).
 Since all the structures have fspec as the first member, this seems to
 work, but is quite ugly.
 
 Comments?  Suggestions?
 
 					Dima Dorfman
 					dima@unixfreak.org
 
 
 Index: mdconfig.8
 ===================================================================
 RCS file: /st/src/FreeBSD/src/sbin/mdconfig/mdconfig.8,v
 retrieving revision 1.5
 diff -u -r1.5 mdconfig.8
 --- mdconfig.8	2001/01/28 20:17:46	1.5
 +++ mdconfig.8	2001/02/23 04:37:23
 @@ -58,6 +58,7 @@
  .Op Fl s Ar size
  .Op Fl f Ar file
  .Op Fl u Ar unit
 +.Op feature ...
  .Nm
  .Fl d
  .Fl u Ar unit
 @@ -133,6 +134,25 @@
  .Xr md 4
  device to use a specific unit number.
  .El
 +.Pp
 +A
 +.Ar feature
 +argument describes an action to be taken after the device is
 +successfully configured.  The valid features follow.
 +.Bl -tag
 +.It Cm mount=rw|ro,fs_type,mount_point
 +Mount the configured memory disk on
 +.Pa mount_point .
 +Since the device must be a valid filesystem of type
 +.Va fs_type
 +at the time it is configured, this is only useful for disks of type
 +.Li vnode .
 +If
 +.Va fs_type
 +is ommited, the type
 +.Li ufs
 +is assumed.
 +.El
  .Sh EXAMPLES
  To create a 4 megabyte
  .Xr malloc 9
 @@ -165,6 +185,20 @@
  mount /dev/md10c /tmp
  chmod 1777 /tmp
  .Ed
 +.Pp
 +To mount a UFS filesystem contained in the file
 +.Pa boot.flp
 +on
 +.Pa /mnt :
 +.Pp
 +.Dl mdconfig -a -t vnode -f boot.flp mount=ro,,/mnt
 +.Pp
 +To mount a CD image contained in the file
 +.Pa 4.2-install.iso
 +on
 +.Pa /mnt :
 +.Pp
 +.Dl mdconfig -a -t vnode -f 4.2-install.iso mount=ro,cd9600,/mnt
  .Sh SEE ALSO
  .Xr md 4 ,
  .Xr disklabel 8 ,
 Index: mdconfig.c
 ===================================================================
 RCS file: /st/src/FreeBSD/src/sbin/mdconfig/mdconfig.c,v
 retrieving revision 1.6
 diff -u -r1.6 mdconfig.c
 --- mdconfig.c	2001/01/31 08:41:18	1.6
 +++ mdconfig.c	2001/02/23 04:37:23
 @@ -10,16 +10,24 @@
   *
   */
  
 +#include <sys/param.h>
 +#include <sys/mount.h>
 +#include <isofs/cd9660/cd9660_mount.h>
 +#include <msdosfs/msdosfsmount.h>
 +#include <ufs/ufs/ufsmount.h>
 +
  #include <stdio.h>
  #include <stdlib.h>
  #include <fcntl.h>
  #include <unistd.h>
  #include <string.h>
  #include <err.h>
 +#include <paths.h>
  #include <sys/ioctl.h>
 -#include <sys/param.h>
  #include <sys/mdioctl.h>
  
 +int	 f_mount(const char *);
 +
  struct md_ioctl mdio;
  
  enum {UNSET, ATTACH, DETACH} action = UNSET;
 @@ -28,7 +36,8 @@
  usage()
  {
  	fprintf(stderr, "Usage:\n");
 -	fprintf(stderr, "\tmdconfig -a -t type [-o [no]option]... [ -f file] [-s size] [-u unit]\n");
 +	fprintf(stderr, "\tmdconfig -a -t type [-o [no]option]... [ -f file] "
 +	    "[-s size] [-u unit]\n\t\t[feature ...]\n");
  	fprintf(stderr, "\tmdconfig -d -u unit\n");
  	fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n");
  	fprintf(stderr, "\t\toption = {cluster, compress, reserve, autounit}\n");
 @@ -138,6 +147,8 @@
  			usage();
  		}
  	}
 +	argc -= optind;
 +	argv += optind;
  
  	fd = open("/dev/mdctl", O_RDWR, 0);
  	if (fd < 0)
 @@ -153,6 +164,64 @@
  		err(1, "ioctl(/dev/mdctl)");
  	if (mdio.md_options & MD_AUTOUNIT)
  		printf("md%d\n", mdio.md_unit);
 +
 +	/* Process 'features'. */
 +	for (; argc > 0; argc++)
 +	{
 +		if (strncmp(argv[0], "mount=", 6) == 0)
 +			if (!f_mount(argv[0] + 6))
 +				return (1);
 +	}
  	return (0);
  }
  
 +/*
 + * Process the 'mount' feature.
 + *
 + * Pre-condition: mdio describes a valid and configured device
 + */
 +int
 +f_mount(const char *params)
 +{
 +	char *p, *wparams;
 +	char *av[3], **avp;
 +	char *mttype, *mtpoint, mtdev[MAXPATHLEN];
 +	int mtflags = 0;
 +	union {
 +	    struct ufs_args u;
 +	    struct iso_args i;
 +	    struct msdosfs_args m;
 +	} args;
 +
 +	memset(&args, '\0', sizeof(args));
 +	if ( (wparams = malloc(strlen(params) + 1)) == NULL)
 +		err(1, "malloc");
 +	strlcpy(wparams, params, strlen(params) + 1);
 +
 +	for (p = wparams, avp = av;;) {
 +		*avp = strsep(&p, ",");
 +		if (++avp >= &av[sizeof(av) / sizeof(*av)])
 +			break;
 +	}
 +
 +	if (strncmp(av[0], "rw", 2) == 0)
 +		;
 +	else if (strncmp(av[0], "ro", 2) == 0)
 +		mtflags |= MNT_RDONLY;
 +	else
 +		errx(1, "bad option to mount feature: %s", av[0]);
 +	if (*av[1] == '\0')
 +		mttype = "ufs";
 +	else
 +		mttype = av[1];
 +	if (*av[2] == '\0')
 +		errx(1, "bad mountpoint");
 +	mtpoint = av[2];
 +
 +	snprintf(mtdev, sizeof(mtdev), "%smd%dc", _PATH_DEV, mdio.md_unit);
 +	args.u.fspec = mtdev;
 +
 +	if (mount(mttype, mtpoint, mtflags, &args) == -1)
 +		err(1, "mount");
 +	return (0);
 +}
State-Changed-From-To: open->closed 
State-Changed-By: rodrigc 
State-Changed-When: Sun Sep 11 16:31:40 GMT 2005 
State-Changed-Why:  
vnconfig has been replaced by mdconfig in FreeBSD 5.x and higher. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=25273 
>Unformatted:
