Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys From Ilya Zykov:



details:   https://anonhg.NetBSD.org/src/rev/d6b1a814d517
branches:  trunk
changeset: 328134:d6b1a814d517
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Mar 27 17:31:56 2014 +0000

description:
>From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
  dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp

diffstat:

 sys/fs/ptyfs/ptyfs_subr.c   |   6 +-
 sys/fs/ptyfs/ptyfs_vfsops.c |  19 ++++------
 sys/kern/tty_bsdpty.c       |  22 +++++++------
 sys/kern/tty_ptm.c          |  75 +++++++++++++++++++++++++++++++++------------
 sys/kern/tty_pty.c          |  16 ++++++---
 sys/sys/pty.h               |  25 +++++++++-----
 6 files changed, 105 insertions(+), 58 deletions(-)

diffs (truncated from 474 to 300 lines):

diff -r d8ad159327b9 -r d6b1a814d517 sys/fs/ptyfs/ptyfs_subr.c
--- a/sys/fs/ptyfs/ptyfs_subr.c Thu Mar 27 16:34:37 2014 +0000
+++ b/sys/fs/ptyfs/ptyfs_subr.c Thu Mar 27 17:31:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptyfs_subr.c,v 1.28 2014/03/26 21:28:48 christos Exp $ */
+/*     $NetBSD: ptyfs_subr.c,v 1.29 2014/03/27 17:31:56 christos Exp $ */
 
 /*
  * Copyright (c) 1993
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_subr.c,v 1.28 2014/03/26 21:28:48 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_subr.c,v 1.29 2014/03/27 17:31:56 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -139,7 +139,7 @@
                 * from the inode
                 */
                if ((error = (*ptyfs_save_ptm->makename)(
-                       ptyfs_save_ptm, l, ttyname, sizeof(ttyname),
+                       NULL, l, ttyname, sizeof(ttyname),
                        ptyfs->ptyfs_pty, ptyfs->ptyfs_type == PTYFSpts ? 't'
                        : 'p')) != 0)
                                goto out;
diff -r d8ad159327b9 -r d6b1a814d517 sys/fs/ptyfs/ptyfs_vfsops.c
--- a/sys/fs/ptyfs/ptyfs_vfsops.c       Thu Mar 27 16:34:37 2014 +0000
+++ b/sys/fs/ptyfs/ptyfs_vfsops.c       Thu Mar 27 17:31:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptyfs_vfsops.c,v 1.47 2014/03/23 15:21:15 hannken Exp $        */
+/*     $NetBSD: ptyfs_vfsops.c,v 1.48 2014/03/27 17:31:56 christos Exp $       */
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.47 2014/03/23 15:21:15 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.48 2014/03/27 17:31:56 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -72,11 +72,11 @@
 
 static struct sysctllog *ptyfs_sysctl_log;
 
-static int ptyfs__allocvp(struct ptm_pty *, struct lwp *, struct vnode **,
+static int ptyfs__allocvp(struct mount *, struct lwp *, struct vnode **,
     dev_t, char);
-static int ptyfs__makename(struct ptm_pty *, struct lwp *, char *, size_t,
+static int ptyfs__makename(struct mount *, struct lwp *, char *, size_t,
     dev_t, char);
-static void ptyfs__getvattr(struct ptm_pty *, struct lwp *, struct vattr *);
+static void ptyfs__getvattr(struct mount *, struct lwp *, struct vattr *);
 
 /*
  * ptm glue: When we mount, we make ptm point to us.
@@ -125,10 +125,9 @@
 }
 
 static int
-ptyfs__makename(struct ptm_pty *pt, struct lwp *l, char *tbuf, size_t bufsiz,
+ptyfs__makename(struct mount *mp, struct lwp *l, char *tbuf, size_t bufsiz,
     dev_t dev, char ms)
 {
-       struct mount *mp = pt->arg;
        size_t len;
        const char *np;
 
@@ -154,10 +153,9 @@
 
 static int
 /*ARGSUSED*/
-ptyfs__allocvp(struct ptm_pty *pt, struct lwp *l, struct vnode **vpp,
+ptyfs__allocvp(struct mount *mp, struct lwp *l, struct vnode **vpp,
     dev_t dev, char ms)
 {
-       struct mount *mp = pt->arg;
        ptyfstype type;
 
        switch (ms) {
@@ -176,9 +174,8 @@
 
 
 static void
-ptyfs__getvattr(struct ptm_pty *pt, struct lwp *l, struct vattr *vattr)
+ptyfs__getvattr(struct mount *mp, struct lwp *l, struct vattr *vattr)
 {
-       struct mount *mp = pt->arg;
        struct ptyfsmount *pmnt = VFSTOPTY(mp);
        vattr_null(vattr);
        /* get real uid */
diff -r d8ad159327b9 -r d6b1a814d517 sys/kern/tty_bsdpty.c
--- a/sys/kern/tty_bsdpty.c     Thu Mar 27 16:34:37 2014 +0000
+++ b/sys/kern/tty_bsdpty.c     Thu Mar 27 17:31:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_bsdpty.c,v 1.18 2014/03/26 21:29:54 christos Exp $ */
+/*     $NetBSD: tty_bsdpty.c,v 1.19 2014/03/27 17:31:56 christos Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,10 +27,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_bsdpty.c,v 1.18 2014/03/26 21:29:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_bsdpty.c,v 1.19 2014/03/27 17:31:56 christos Exp $");
 
 #include "opt_ptm.h"
 
+#ifndef NO_DEV_PTM
 #ifdef COMPAT_BSDPTY
 /* bsd tty implementation for pty multiplexor driver /dev/ptm{,x} */
 
@@ -68,11 +69,11 @@
 #define TTY_OLD_SUFFIX  "0123456789abcdef"
 #define TTY_NEW_SUFFIX  "ghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
-static int pty_makename(struct ptm_pty *, struct lwp *, char *, size_t, dev_t,
+static int pty_makename(struct mount *, struct lwp *, char *, size_t, dev_t,
     char);
-static int pty_allocvp(struct ptm_pty *, struct lwp *, struct vnode **,
+static int pty_allocvp(struct mount *, struct lwp *, struct vnode **,
     dev_t, char);
-static void pty_getvattr(struct ptm_pty *, struct lwp *, struct vattr *);
+static void pty_getvattr(struct mount *, struct lwp *, struct vattr *);
 
 struct ptm_pty ptm_bsdpty = {
        pty_allocvp,
@@ -83,7 +84,7 @@
 
 static int
 /*ARGSUSED*/
-pty_makename(struct ptm_pty *ptm, struct lwp *l, char *bf,
+pty_makename(struct mount *mp, struct lwp *l, char *bf,
     size_t bufsiz, dev_t dev, char c)
 {
        size_t nt;
@@ -113,7 +114,7 @@
 
 static int
 /*ARGSUSED*/
-pty_allocvp(struct ptm_pty *ptm, struct lwp *l, struct vnode **vp, dev_t dev,
+pty_allocvp(struct mount *mp, struct lwp *l, struct vnode **vp, dev_t dev,
     char ms)
 {
        int error;
@@ -121,7 +122,7 @@
        struct nameidata nd;
        char name[TTY_NAMESIZE];
 
-       error = pty_makename(ptm, l, name, sizeof(name), dev, ms);
+       error = pty_makename(NULL, l, name, sizeof(name), dev, ms);
        if (error)
                return error;
 
@@ -143,7 +144,7 @@
 
 static void
 /*ARGSUSED*/
-pty_getvattr(struct ptm_pty *ptm, struct lwp *l, struct vattr *vattr)
+pty_getvattr(struct mount *mp, struct lwp *l, struct vattr *vattr)
 {
        vattr_null(vattr);
        /* get real uid */
@@ -151,4 +152,5 @@
        vattr->va_gid = TTY_GID;
        vattr->va_mode = TTY_PERM;
 }
-#endif
+#endif /* COMPAT_BSDPTY */
+#endif /* NO_DEV_PTM */
diff -r d8ad159327b9 -r d6b1a814d517 sys/kern/tty_ptm.c
--- a/sys/kern/tty_ptm.c        Thu Mar 27 16:34:37 2014 +0000
+++ b/sys/kern/tty_ptm.c        Thu Mar 27 17:31:56 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_ptm.c,v 1.30 2014/03/19 18:11:17 christos Exp $    */
+/*     $NetBSD: tty_ptm.c,v 1.31 2014/03/27 17:31:56 christos Exp $    */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.30 2014/03/19 18:11:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_ptm.c,v 1.31 2014/03/27 17:31:56 christos Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ptm.h"
@@ -84,11 +84,39 @@
 int pts_major, ptc_major;
 
 static dev_t pty_getfree(void);
-static int pty_alloc_master(struct lwp *, int *, dev_t *);
-static int pty_alloc_slave(struct lwp *, int *, dev_t);
+static int pty_alloc_master(struct lwp *, int *, dev_t *, struct mount *);
+static int pty_alloc_slave(struct lwp *, int *, dev_t, struct mount *);
 
 void ptmattach(int);
 
+int
+ptyfs_getmp(struct lwp *l, struct mount **mpp) {
+       struct cwdinfo *cwdi = l->l_proc->p_cwdi;
+       struct mount *mp;
+
+       if (ptm == NULL)
+               return EOPNOTSUPP;
+
+       if (ptm->arg == NULL) { /* BSDPTY */
+               *mpp = NULL;
+               return 0;
+       }
+
+       mp = ptm->arg;  /* PTYFS */
+
+       if (cwdi->cwdi_rdir == NULL)
+               goto ok;
+
+       if (vn_isunder(mp->mnt_vnodecovered, cwdi->cwdi_rdir, l))
+               goto ok;
+
+       *mpp = NULL;
+       return EOPNOTSUPP;
+ok:
+       *mpp = mp;
+       return 0;
+}
+
 dev_t
 pty_makedev(char ms, int minor)
 {
@@ -140,7 +168,7 @@
 }
 
 static int
-pty_alloc_master(struct lwp *l, int *fd, dev_t *dev)
+pty_alloc_master(struct lwp *l, int *fd, dev_t *dev, struct mount *mp)
 {
        int error;
        struct file *fp;
@@ -164,7 +192,7 @@
                error = EOPNOTSUPP;
                goto bad;
        }
-       if ((error = (*ptm->allocvp)(ptm, l, &vp, *dev, 'p')) != 0) {
+       if ((error = (*ptm->allocvp)(mp, l, &vp, *dev, 'p')) != 0) {
                DPRINTF(("pty_allocvp %d\n", error));
                goto bad;
        }
@@ -197,7 +225,7 @@
 }
 
 int
-pty_grant_slave(struct lwp *l, dev_t dev)
+pty_grant_slave(struct lwp *l, dev_t dev, struct mount *mp)
 {
        int error;
        struct vnode *vp;
@@ -213,12 +241,12 @@
         */
        if (ptm == NULL)
                return EOPNOTSUPP;
-       if ((error = (*ptm->allocvp)(ptm, l, &vp, dev, 't')) != 0)
+       if ((error = (*ptm->allocvp)(mp, l, &vp, dev, 't')) != 0)
                return error;
 
        if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
                struct vattr vattr;
-               (*ptm->getvattr)(ptm, l, &vattr);
+               (*ptm->getvattr)(mp, l, &vattr);
                /* Do the VOP_SETATTR() as root. */
                error = VOP_SETATTR(vp, &vattr, lwp0.l_cred);
                if (error) {
@@ -239,7 +267,7 @@
 }
 
 static int
-pty_alloc_slave(struct lwp *l, int *fd, dev_t dev)
+pty_alloc_slave(struct lwp *l, int *fd, dev_t dev, struct mount *mp)
 {
        int error;
        struct file *fp;
@@ -256,7 +284,7 @@
                goto bad;
        }
 
-       if ((error = (*ptm->allocvp)(ptm, l, &vp, dev, 't')) != 0)
+       if ((error = (*ptm->allocvp)(mp, l, &vp, dev, 't')) != 0)
                goto bad;
        if ((error = pty_vn_open(vp, l)) != 0)
                goto bad;
@@ -282,7 +310,7 @@
 }
 
 int
-pty_fill_ptmget(struct lwp *l, dev_t dev, int cfd, int sfd, void *data)



Home | Main Index | Thread Index | Old Index