Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs Add ptyfs. This is experimental.



details:   https://anonhg.NetBSD.org/src/rev/dcf556ca384d
branches:  trunk
changeset: 571105:dcf556ca384d
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 11 01:40:32 2004 +0000

description:
Add ptyfs. This is experimental.

diffstat:

 sys/miscfs/Makefile             |     4 +-
 sys/miscfs/ptyfs/Makefile       |     7 +
 sys/miscfs/ptyfs/files.ptyfs    |     7 +
 sys/miscfs/ptyfs/ptyfs.h        |   151 +++++
 sys/miscfs/ptyfs/ptyfs_subr.c   |   421 +++++++++++++++
 sys/miscfs/ptyfs/ptyfs_vfsops.c |   354 +++++++++++++
 sys/miscfs/ptyfs/ptyfs_vnops.c  |  1030 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 1972 insertions(+), 2 deletions(-)

diffs (truncated from 2007 to 300 lines):

diff -r dbfe688fd860 -r dcf556ca384d sys/miscfs/Makefile
--- a/sys/miscfs/Makefile       Thu Nov 11 01:39:25 2004 +0000
+++ b/sys/miscfs/Makefile       Thu Nov 11 01:40:32 2004 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: Makefile,v 1.5 2003/03/16 08:26:47 jdolecek Exp $
+#      $NetBSD: Makefile,v 1.6 2004/11/11 01:40:32 christos Exp $
 
 SUBDIR=        fdesc fifofs genfs kernfs nullfs overlay portal
-SUBDIR+= procfs specfs syncfs umapfs
+SUBDIR+= procfs ptyfs specfs syncfs umapfs
 
 INCSDIR= /usr/include/miscfs
 
diff -r dbfe688fd860 -r dcf556ca384d sys/miscfs/ptyfs/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/ptyfs/Makefile Thu Nov 11 01:40:32 2004 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: Makefile,v 1.1 2004/11/11 01:40:32 christos Exp $
+
+INCSDIR= /usr/include/miscfs/ptyfs
+
+INCS=  ptyfs.h
+
+.include <bsd.kinc.mk>
diff -r dbfe688fd860 -r dcf556ca384d sys/miscfs/ptyfs/files.ptyfs
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/ptyfs/files.ptyfs      Thu Nov 11 01:40:32 2004 +0000
@@ -0,0 +1,7 @@
+#      $NetBSD: files.ptyfs,v 1.1 2004/11/11 01:40:32 christos Exp $
+
+deffs  fs_ptyfs.h                      PTYFS           # XXX
+
+file   miscfs/ptyfs/ptyfs_subr.c       ptyfs
+file   miscfs/ptyfs/ptyfs_vfsops.c     ptyfs
+file   miscfs/ptyfs/ptyfs_vnops.c      ptyfs
diff -r dbfe688fd860 -r dcf556ca384d sys/miscfs/ptyfs/ptyfs.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/ptyfs/ptyfs.h  Thu Nov 11 01:40:32 2004 +0000
@@ -0,0 +1,151 @@
+/*     $NetBSD: ptyfs.h,v 1.1 2004/11/11 01:40:32 christos Exp $       */
+
+/*
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ptyfs.h     8.9 (Berkeley) 5/14/95
+ */
+
+/*
+ * Copyright (c) 1993 Jan-Simon Pendry
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ptyfs.h     8.9 (Berkeley) 5/14/95
+ */
+
+#ifdef _KERNEL
+/*
+ * The different types of node in a ptyfs filesystem
+ */
+typedef enum {
+       PTYFSpts,       /* The slave side of a pty */
+       PTYFSptc,       /* The controlling side of a pty */
+       PTYFSroot,      /* the filesystem root */
+} ptyfstype;
+
+/*
+ * control data for the proc file system.
+ */
+struct ptyfsnode {
+       LIST_ENTRY(ptyfsnode) ptyfs_hash;       /* hash chain */
+       struct vnode    *ptyfs_vnode;   /* vnode associated with this ptyfsnode */
+       ptyfstype       ptyfs_type;     /* type of ptyfs node */
+       int             ptyfs_pty;      /* the pty index */
+       u_long          ptyfs_fileno;   /* unique file id */
+       int             ptyfs_flag;     /* status flag for times */
+#define        PTYFS_ACCESS    1
+#define        PTYFS_MODIFY    2
+#define        PTYFS_CHANGE    4
+       /* Attribute information */
+       uid_t           ptyfs_uid;
+       gid_t           ptyfs_gid;
+       mode_t          ptyfs_mode;
+       int             ptyfs_flags;
+       struct timespec ptyfs_ctime, ptyfs_mtime, ptyfs_atime, ptyfs_birthtime;
+};
+
+#endif /* _KERNEL */
+
+/*
+ * Kernel stuff follows
+ */
+#ifdef _KERNEL
+#define CNEQ(cnp, s, len) \
+        ((cnp)->cn_namelen == (len) && \
+         (memcmp((s), (cnp)->cn_nameptr, (len)) == 0))
+
+#define UIO_MX 32
+
+#define PTYFS_FILENO(pty, type) \
+    ((((uint32_t)type) << 30) | (pty + 1))
+
+#define PTYFS_MAKEDEV(ptyfs) \
+    pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty)
+
+/*
+ * Convert between ptyfsnode vnode
+ */
+#define VTOPTYFS(vp)   ((struct ptyfsnode *)(vp)->v_data)
+#define PTYFSTOV(ptyfs)        ((ptyfs)->ptyfs_vnode)
+
+int ptyfs_freevp(struct vnode *);
+int ptyfs_allocvp(struct mount *, struct vnode **, ptyfstype, int,
+    struct proc *);
+void ptyfs_hashinit(void);
+void ptyfs_hashreinit(void);
+void ptyfs_hashdone(void);
+int ptyfs_getfp(struct ptyfsnode *, struct proc **, struct file **);
+
+/* functions to check whether or not files should be displayed */
+int ptyfs_validfile(struct proc *, struct mount *);
+int ptyfs_validfpregs(struct proc *, struct mount *);
+int ptyfs_validregs(struct proc *, struct mount *);
+int ptyfs_validmap(struct proc *, struct mount *);
+
+extern int (**ptyfs_vnodeop_p)(void *);
+extern struct vfsops ptyfs_vfsops;
+
+int    ptyfs_root(struct mount *, struct vnode **);
+
+#ifdef SYSCTL_SETUP_PROTO
+SYSCTL_SETUP_PROTO(sysctl_vfs_ptyfs_setup);
+#endif /* SYSCTL_SETUP_PROTO */
+#endif /* _KERNEL */
diff -r dbfe688fd860 -r dcf556ca384d sys/miscfs/ptyfs/ptyfs_subr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/ptyfs/ptyfs_subr.c     Thu Nov 11 01:40:32 2004 +0000
@@ -0,0 +1,421 @@
+/*     $NetBSD: ptyfs_subr.c,v 1.1 2004/11/11 01:40:32 christos Exp $  */
+
+/*
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ptyfs_subr.c        8.6 (Berkeley) 5/14/95
+ */
+
+/*
+ * Copyright (c) 1994 Christopher G. Demetriou.  All rights reserved.
+ * Copyright (c) 1993 Jan-Simon Pendry
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)procfs_subr.c       8.6 (Berkeley) 5/14/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_subr.c,v 1.1 2004/11/11 01:40:32 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/vnode.h>
+#include <sys/malloc.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/namei.h>
+#include <sys/filedesc.h>
+#include <sys/select.h>
+#include <sys/tty.h>
+#include <sys/pty.h>
+
+#include <miscfs/ptyfs/ptyfs.h>
+#include <miscfs/specfs/specdev.h>
+
+static struct lock ptyfs_hashlock;
+
+static LIST_HEAD(ptyfs_hashhead, ptyfsnode) *ptyfs_used_tbl, *ptyfs_free_tbl;
+static u_long ptyfs_used_mask, ptyfs_free_mask; /* size of hash table - 1 */
+static struct simplelock ptyfs_used_slock, ptyfs_free_slock;
+
+static void ptyfs_getinfo(struct ptyfsnode *, struct proc *);
+
+static void ptyfs_hashins(struct ptyfsnode *);
+static void ptyfs_hashrem(struct ptyfsnode *);
+
+static struct vnode *ptyfs_used_get(ptyfstype, int, struct mount *);



Home | Main Index | Thread Index | Old Index