summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpedro <pedro@openbsd.org>2007-03-21 13:44:04 +0000
committerpedro <pedro@openbsd.org>2007-03-21 13:44:04 +0000
commit2112d326db245fc149cdde941c1a670298b83cd3 (patch)
treee9e78c10a41c64254823ff7c246c26696e8f934e
parentevent_init() and event_dispatch() take void. Add commented out (diff)
downloadwireguard-openbsd-2112d326db245fc149cdde941c1a670298b83cd3.tar.xz
wireguard-openbsd-2112d326db245fc149cdde941c1a670298b83cd3.zip
Add support for mounting arbitrary sessions, from Enache Adrian
OK deraadt@ mjc@ canacar@ krw@, with much input from Enache himself
-rw-r--r--lib/libc/sys/mount.23
-rw-r--r--sbin/mount_cd9660/mount_cd9660.810
-rw-r--r--sbin/mount_cd9660/mount_cd9660.c21
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c21
-rw-r--r--sys/sys/mount.h13
5 files changed, 50 insertions, 18 deletions
diff --git a/lib/libc/sys/mount.2 b/lib/libc/sys/mount.2
index 251e7875a9d..f9694be25a3 100644
--- a/lib/libc/sys/mount.2
+++ b/lib/libc/sys/mount.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mount.2,v 1.35 2006/12/15 03:04:23 krw Exp $
+.\" $OpenBSD: mount.2,v 1.36 2007/03/21 13:44:04 pedro Exp $
.\" $NetBSD: mount.2,v 1.12 1996/02/29 23:47:48 jtc Exp $
.\"
.\" Copyright (c) 1980, 1989, 1993
@@ -142,6 +142,7 @@ struct iso_args {
#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */
#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */
#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/
+#define ISOFSMNT_SESS 0x00000010 /* use iso_args.sess */
.Ed
.Pp
.Dv MOUNT_FFS
diff --git a/sbin/mount_cd9660/mount_cd9660.8 b/sbin/mount_cd9660/mount_cd9660.8
index e953a339505..acda0542e22 100644
--- a/sbin/mount_cd9660/mount_cd9660.8
+++ b/sbin/mount_cd9660/mount_cd9660.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mount_cd9660.8,v 1.19 2005/11/27 13:11:59 jmc Exp $
+.\" $OpenBSD: mount_cd9660.8,v 1.20 2007/03/21 13:44:04 pedro Exp $
.\" $NetBSD: mount_cd9660.8,v 1.3 1995/04/23 10:33:13 cgd Exp $
.\"
.\" Copyright (c) 1993, 1994
@@ -43,6 +43,7 @@
.Nm mount_cd9660
.Op Fl egjR
.Op Fl o Ar options
+.Op Fl s Ar offset
.Ar special node
.Sh DESCRIPTION
The
@@ -81,6 +82,13 @@ See the
man page for possible options and their meanings.
.It Fl R
Do not use any Rockridge extensions included in the filesystem.
+.It Fl s Ar offset
+Use the session starting at
+.Ar offset
+(counted in 2048-byte blocks from the start of the media) instead of
+the last session from the Table of Contents (TOC).
+The TOC can be inspected by using
+.Xr cdio 1 .
.El
.Sh SEE ALSO
.Xr mount 2 ,
diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c
index 9b66f8fee8c..69ed81424f3 100644
--- a/sbin/mount_cd9660/mount_cd9660.c
+++ b/sbin/mount_cd9660/mount_cd9660.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_cd9660.c,v 1.17 2005/04/08 20:09:36 jaredy Exp $ */
+/* $OpenBSD: mount_cd9660.c,v 1.18 2007/03/21 13:44:04 pedro Exp $ */
/* $NetBSD: mount_cd9660.c,v 1.3 1996/04/13 01:31:08 jtc Exp $ */
/*
@@ -45,7 +45,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_cd9660.c 8.4 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_cd9660.c,v 1.17 2005/04/08 20:09:36 jaredy Exp $";
+static char rcsid[] = "$OpenBSD: mount_cd9660.c,v 1.18 2007/03/21 13:44:04 pedro Exp $";
#endif
#endif /* not lint */
@@ -55,6 +55,7 @@ static char rcsid[] = "$OpenBSD: mount_cd9660.c,v 1.17 2005/04/08 20:09:36 jared
#include <err.h>
#include <errno.h>
+#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -74,11 +75,12 @@ int
main(int argc, char *argv[])
{
struct iso_args args;
- int ch, mntflags, opts;
+ int ch, mntflags, opts, sess = 0;
char *dev, dir[MAXPATHLEN];
+ const char *errstr;
mntflags = opts = 0;
- while ((ch = getopt(argc, argv, "egjo:R")) != -1)
+ while ((ch = getopt(argc, argv, "egjo:Rs:")) != -1)
switch (ch) {
case 'e':
opts |= ISOFSMNT_EXTATT;
@@ -95,6 +97,13 @@ main(int argc, char *argv[])
case 'R':
opts |= ISOFSMNT_NORRIP;
break;
+ case 's':
+ opts |= ISOFSMNT_SESS;
+ sess = strtonum(optarg, 0, INT32_MAX, &errstr);
+ if (errstr)
+ errx(1, "session number is %s: %s", errstr,
+ optarg);
+ break;
case '?':
default:
usage();
@@ -121,6 +130,7 @@ main(int argc, char *argv[])
else
args.export_info.ex_flags = 0;
args.flags = opts;
+ args.sess = sess;
if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0) {
if (errno == EOPNOTSUPP)
@@ -135,6 +145,7 @@ void
usage(void)
{
(void)fprintf(stderr,
- "usage: mount_cd9660 [-egjR] [-o options] special node\n");
+ "usage: mount_cd9660 [-egjR] [-o options] [-s offset] "
+ "special node\n");
exit(1);
}
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index 95a2d6f45a3..ed51eaf31cb 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vfsops.c,v 1.42 2006/08/07 15:50:42 pedro Exp $ */
+/* $OpenBSD: cd9660_vfsops.c,v 1.43 2007/03/21 13:44:04 pedro Exp $ */
/* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */
/*-
@@ -236,7 +236,7 @@ iso_mountfs(devvp, mp, p, argp)
struct iso_supplementary_descriptor *sup = NULL;
struct iso_directory_record *rootp;
int logical_block_size;
- int sess = 0;
+ int sess;
if (!ronly)
return (EROFS);
@@ -259,16 +259,25 @@ iso_mountfs(devvp, mp, p, argp)
return (error);
needclose = 1;
- /* This is the "logical sector size". The standard says this
+ /*
+ * This is the "logical sector size". The standard says this
* should be 2048 or the physical sector size on the device,
* whichever is greater. For now, we'll just use a constant.
*/
iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
- error = VOP_IOCTL(devvp, CDIOREADMSADDR, (caddr_t)&sess, 0, FSCRED, p);
- if (error)
+ if (argp->flags & ISOFSMNT_SESS) {
+ sess = argp->sess;
+ if (sess < 0)
+ sess = 0;
+ } else {
sess = 0;
-
+ error = VOP_IOCTL(devvp, CDIOREADMSADDR, (caddr_t)&sess, 0,
+ FSCRED, p);
+ if (error)
+ sess = 0;
+ }
+
joliet_level = 0;
for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) {
if ((error = bread(devvp,
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index ea848a7ddb3..20a2a013629 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount.h,v 1.77 2006/12/15 03:04:24 krw Exp $ */
+/* $OpenBSD: mount.h,v 1.78 2007/03/21 13:44:04 pedro Exp $ */
/* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */
/*
@@ -94,11 +94,14 @@ struct iso_args {
char *fspec; /* block special device to mount */
struct export_args export_info;/* network export info */
int flags; /* mounting flags, see below */
+ int sess; /* start sector of session */
};
-#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/
-#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */
-#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */
-#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/
+
+#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/
+#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */
+#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attr. */
+#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/
+#define ISOFSMNT_SESS 0x00000010 /* use iso_args.sess */
/*
* Arguments to mount NFS