Module Name:    src
Committed By:   riz
Date:           Mon Oct  1 17:35:05 UTC 2012

Modified Files:
        src/sbin/mount_ptyfs [netbsd-6]: mount_ptyfs.8 mount_ptyfs.c
        src/sys/fs/ptyfs [netbsd-6]: ptyfs.h ptyfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #566):
        sbin/mount_ptyfs/mount_ptyfs.8: revision 1.11
        sbin/mount_ptyfs/mount_ptyfs.8: revision 1.12
        sys/fs/ptyfs/ptyfs.h: revision 1.9
        sbin/mount_ptyfs/mount_ptyfs.c: revision 1.14
        sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.43
        sys/fs/ptyfs/ptyfs_vfsops.c: revision 1.44
Does not make sense to mount this as NFS, so it is not a bug.
We can now mount multiple instances, but all of them show all the ptys.
let us get mounted multiple times.
remove -c and chroot option; they are always on now
Always do the chroot filename mapping; it is pointless not to do it.


To generate a diff of this commit:
cvs rdiff -u -r1.8.8.1 -r1.8.8.2 src/sbin/mount_ptyfs/mount_ptyfs.8
cvs rdiff -u -r1.12 -r1.12.4.1 src/sbin/mount_ptyfs/mount_ptyfs.c
cvs rdiff -u -r1.8 -r1.8.18.1 src/sys/fs/ptyfs/ptyfs.h
cvs rdiff -u -r1.42 -r1.42.18.1 src/sys/fs/ptyfs/ptyfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/mount_ptyfs/mount_ptyfs.8
diff -u src/sbin/mount_ptyfs/mount_ptyfs.8:1.8.8.1 src/sbin/mount_ptyfs/mount_ptyfs.8:1.8.8.2
--- src/sbin/mount_ptyfs/mount_ptyfs.8:1.8.8.1	Thu Sep 13 22:28:15 2012
+++ src/sbin/mount_ptyfs/mount_ptyfs.8	Mon Oct  1 17:35:05 2012
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_ptyfs.8,v 1.8.8.1 2012/09/13 22:28:15 riz Exp $
+.\"	$NetBSD: mount_ptyfs.8,v 1.8.8.2 2012/10/01 17:35:05 riz Exp $
 .\"
 .\"
 .\" Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 9, 2012
+.Dd September 19, 2012
 .Dt MOUNT_PTYFS 8
 .Os
 .Sh NAME
@@ -36,7 +36,6 @@
 .Nd mount the /dev/pts file system
 .Sh SYNOPSIS
 .Nm
-.Op Fl c
 .Op Fl g Ar group|gid
 .Op Fl m Ar mode
 .Op Fl o Ar options
@@ -63,10 +62,6 @@ or they are already open via traditional
 .Pp
 The options are as follows:
 .Bl -tag -width indent
-.It Fl c
-Allows
-.Ar ptyfs
-to be mounted inside a chrooted environment.
 .It Fl g Ar group|gid
 Specify the group ownership of the slave pseudo-tty.
 .It Fl m Ar mode
@@ -80,9 +75,6 @@ flag followed by a comma separated strin
 .Pp
 .Nm
 specific options are
-.Dv chroot
-which corresponds to
-.Fl c ,
 .Dv group
 which corresponds to
 .Fl g ,
@@ -111,4 +103,5 @@ The
 utility first appeared in
 .Nx 3.0 .
 .Sh BUGS
-This filesystem may not be NFS-exported.
+When multiple instances are mounted, they all display the union of the ptys
+used in each instance, not just the ones used in the particular instance.

Index: src/sbin/mount_ptyfs/mount_ptyfs.c
diff -u src/sbin/mount_ptyfs/mount_ptyfs.c:1.12 src/sbin/mount_ptyfs/mount_ptyfs.c:1.12.4.1
--- src/sbin/mount_ptyfs/mount_ptyfs.c:1.12	Mon Aug 29 14:35:02 2011
+++ src/sbin/mount_ptyfs/mount_ptyfs.c	Mon Oct  1 17:35:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount_ptyfs.c,v 1.12 2011/08/29 14:35:02 joerg Exp $	*/
+/*	$NetBSD: mount_ptyfs.c,v 1.12.4.1 2012/10/01 17:35:05 riz Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994
@@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)mount_ptyfs.c	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: mount_ptyfs.c,v 1.12 2011/08/29 14:35:02 joerg Exp $");
+__RCSID("$NetBSD: mount_ptyfs.c,v 1.12.4.1 2012/10/01 17:35:05 riz Exp $");
 #endif
 #endif /* not lint */
 
@@ -100,14 +100,12 @@ __RCSID("$NetBSD: mount_ptyfs.c,v 1.12 2
 
 #define ALTF_GROUP	0x1
 #define ALTF_MODE	0x2
-#define ALTF_CHROOT	0x4
 
 static const struct mntopt mopts[] = {
 	MOPT_STDOPTS,
 	MOPT_GETARGS,
 	{ "group", 0, ALTF_GROUP, 1 },
 	{ "mode", 0, ALTF_MODE, 1 },
-	{ "chroot", 0, ALTF_CHROOT, 1 },
 	MOPT_NULL,
 };
 
@@ -165,7 +163,7 @@ mount_ptyfs(int argc, char *argv[])
 	args.mode = S_IRUSR|S_IWUSR|S_IWGRP;
 	args.flags = 0;
 
-	while ((ch = getopt(argc, argv, "cg:m:o:")) != -1)
+	while ((ch = getopt(argc, argv, "g:m:o:")) != -1)
 		switch (ch) {
 		case 'o':
 			altflags = 0;
@@ -176,13 +174,8 @@ mount_ptyfs(int argc, char *argv[])
 				args.gid = getgrp(getmntoptstr(mp, "group"));
 			if (altflags & ALTF_MODE)
 				args.mode = (mode_t)getmntoptnum(mp, "mode");
-			if (altflags & ALTF_CHROOT)
-				args.flags |= PTYFSMNT_CHROOT;
 			freemntopts(mp);
 			break;
-		case 'c':
-			args.flags |= PTYFSMNT_CHROOT;
-			break;
 		case 'g':
 			args.gid = getgrp(optarg);
 			break;
@@ -210,11 +203,8 @@ mount_ptyfs(int argc, char *argv[])
 	if (mount(MOUNT_PTYFS, canon_dir, mntflags, &args, sizeof args) == -1)
 		err(1, "ptyfs on %s", canon_dir);
 	if (mntflags & MNT_GETARGS) {
-		char buf[1024];
-		(void)snprintb(buf, sizeof(buf), PTYFSMNT_BITS, args.flags);
-		printf("version=%d, flags=%s\n", args.version, buf);
-		printf("version=%d, gid=%lu, mode=0%o flags=%s\n", args.version,
-		    (unsigned long)args.gid, args.mode, buf);
+		printf("version=%d, gid=%lu, mode=0%o\n", args.version,
+		    (unsigned long)args.gid, args.mode);
 	}
 	return 0;
 }
@@ -223,7 +213,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	    "Usage: %s [-c] [-g <group|gid>] [-m <mode>] [-o options] "
+	    "Usage: %s [-g <group|gid>] [-m <mode>] [-o options] "
 	    "ptyfs mountpoint\n", getprogname());
 	exit(1);
 }

Index: src/sys/fs/ptyfs/ptyfs.h
diff -u src/sys/fs/ptyfs/ptyfs.h:1.8 src/sys/fs/ptyfs/ptyfs.h:1.8.18.1
--- src/sys/fs/ptyfs/ptyfs.h:1.8	Sun Mar 15 16:43:55 2009
+++ src/sys/fs/ptyfs/ptyfs.h	Mon Oct  1 17:35:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs.h,v 1.8 2009/03/15 16:43:55 christos Exp $	*/
+/*	$NetBSD: ptyfs.h,v 1.8.18.1 2012/10/01 17:35:05 riz Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -124,11 +124,6 @@ struct ptyfs_args {
 
 #define PTYFS_ARGSVERSION	2
 
-#define PTYFSMNT_CHROOT		0x01
-
-#define PTYFSMNT_BITS "\177\20" \
-    "b\00chroot\0"
-
 /*
  * Kernel stuff follows
  */

Index: src/sys/fs/ptyfs/ptyfs_vfsops.c
diff -u src/sys/fs/ptyfs/ptyfs_vfsops.c:1.42 src/sys/fs/ptyfs/ptyfs_vfsops.c:1.42.18.1
--- src/sys/fs/ptyfs/ptyfs_vfsops.c:1.42	Fri Jan  8 11:35:09 2010
+++ src/sys/fs/ptyfs/ptyfs_vfsops.c	Mon Oct  1 17:35:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs_vfsops.c,v 1.42 2010/01/08 11:35:09 pooka Exp $	*/
+/*	$NetBSD: ptyfs_vfsops.c,v 1.42.18.1 2012/10/01 17:35:05 riz Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.42 2010/01/08 11:35:09 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.42.18.1 2012/10/01 17:35:05 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -101,11 +101,9 @@ ptyfs__getpath(struct lwp *l, const stru
 	size_t len;
 	char *bp;
 	int error;
-	struct ptyfsmount *pmnt = mp->mnt_data;
 
 	rv = mp->mnt_stat.f_mntonname;
-	if (cwdi->cwdi_rdir == NULL ||
-	    (pmnt->pmnt_flags & PTYFSMNT_CHROOT) == 0)
+	if (cwdi->cwdi_rdir == NULL)
 		return rv;
 
 	buf = malloc(MAXBUF, M_TEMP, M_WAITOK);
@@ -243,9 +241,11 @@ ptyfs_mount(struct mount *mp, const char
 		return 0;
 	}
 
+#if 0
 	/* Don't allow more than one mount */
 	if (ptyfs_count)
 		return EBUSY;
+#endif
 
 	if (mp->mnt_flag & MNT_UPDATE)
 		return EOPNOTSUPP;
@@ -272,9 +272,10 @@ ptyfs_mount(struct mount *mp, const char
 	}
 
 	/* Point pty access to us */
-
-	ptm_ptyfspty.arg = mp;
-	ptyfs_save_ptm = pty_sethandler(&ptm_ptyfspty);
+	if (ptyfs_count == 0) {
+		ptm_ptyfspty.arg = mp;
+		ptyfs_save_ptm = pty_sethandler(&ptm_ptyfspty);
+	}
 	ptyfs_count++;
 	return 0;
 }
@@ -297,19 +298,21 @@ ptyfs_unmount(struct mount *mp, int mntf
 		flags |= FORCECLOSE;
 
 	if ((error = vflush(mp, 0, flags)) != 0)
-		return (error);
+		return error;
 
-	/* Restore where pty access was pointing */
-	(void)pty_sethandler(ptyfs_save_ptm);
-	ptyfs_save_ptm = NULL;
-	ptm_ptyfspty.arg = NULL;
+	ptyfs_count--;
+	if (ptyfs_count == 0) {
+		/* Restore where pty access was pointing */
+		(void)pty_sethandler(ptyfs_save_ptm);
+		ptyfs_save_ptm = NULL;
+		ptm_ptyfspty.arg = NULL;
+	}
 
 	/*
 	 * Finally, throw away the ptyfsmount structure
 	 */
 	free(mp->mnt_data, M_PTYFSMNT);
 	mp->mnt_data = NULL;
-	ptyfs_count--;
 
 	return 0;
 }

Reply via email to