Date: Thu, 22 Feb 2001 04:56:15 +0100 (CET) From: Cyrille Lefevre <clefevre@poboxes.com> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/25273: add fs type feature to vnconfig(8) to allow direct mount of iso images and co. Message-ID: <200102220356.f1M3uFh62808@gits.dyndns.org>
next in thread | raw e-mail | index | archive | help
>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: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Feb 21 20:00:07 PST 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102220356.f1M3uFh62808>
