Home | History | Annotate | Line # | Download | only in ptyfs
ptyfs.h revision 1.2
      1  1.2  christos /*	$NetBSD: ptyfs.h,v 1.2 2004/11/25 05:15:10 christos Exp $	*/
      2  1.1  jdolecek 
      3  1.1  jdolecek /*
      4  1.1  jdolecek  * Copyright (c) 1993
      5  1.1  jdolecek  *	The Regents of the University of California.  All rights reserved.
      6  1.1  jdolecek  *
      7  1.1  jdolecek  * This code is derived from software contributed to Berkeley by
      8  1.1  jdolecek  * Jan-Simon Pendry.
      9  1.1  jdolecek  *
     10  1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
     11  1.1  jdolecek  * modification, are permitted provided that the following conditions
     12  1.1  jdolecek  * are met:
     13  1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     14  1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     15  1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     18  1.1  jdolecek  * 3. Neither the name of the University nor the names of its contributors
     19  1.1  jdolecek  *    may be used to endorse or promote products derived from this software
     20  1.1  jdolecek  *    without specific prior written permission.
     21  1.1  jdolecek  *
     22  1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  1.1  jdolecek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  1.1  jdolecek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  1.1  jdolecek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  1.1  jdolecek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.1  jdolecek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.1  jdolecek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.1  jdolecek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.1  jdolecek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.1  jdolecek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.1  jdolecek  * SUCH DAMAGE.
     33  1.1  jdolecek  *
     34  1.1  jdolecek  *	@(#)procfs.h	8.9 (Berkeley) 5/14/95
     35  1.1  jdolecek  */
     36  1.1  jdolecek 
     37  1.1  jdolecek /*
     38  1.1  jdolecek  * Copyright (c) 1993 Jan-Simon Pendry
     39  1.1  jdolecek  *
     40  1.1  jdolecek  * This code is derived from software contributed to Berkeley by
     41  1.1  jdolecek  * Jan-Simon Pendry.
     42  1.1  jdolecek  *
     43  1.1  jdolecek  * Redistribution and use in source and binary forms, with or without
     44  1.1  jdolecek  * modification, are permitted provided that the following conditions
     45  1.1  jdolecek  * are met:
     46  1.1  jdolecek  * 1. Redistributions of source code must retain the above copyright
     47  1.1  jdolecek  *    notice, this list of conditions and the following disclaimer.
     48  1.1  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.1  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     50  1.1  jdolecek  *    documentation and/or other materials provided with the distribution.
     51  1.1  jdolecek  * 3. All advertising materials mentioning features or use of this software
     52  1.1  jdolecek  *    must display the following acknowledgement:
     53  1.1  jdolecek  *	This product includes software developed by the University of
     54  1.1  jdolecek  *	California, Berkeley and its contributors.
     55  1.1  jdolecek  * 4. Neither the name of the University nor the names of its contributors
     56  1.1  jdolecek  *    may be used to endorse or promote products derived from this software
     57  1.1  jdolecek  *    without specific prior written permission.
     58  1.1  jdolecek  *
     59  1.1  jdolecek  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     60  1.1  jdolecek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     61  1.1  jdolecek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     62  1.1  jdolecek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     63  1.1  jdolecek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     64  1.1  jdolecek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     65  1.1  jdolecek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     66  1.1  jdolecek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     67  1.1  jdolecek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     68  1.1  jdolecek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     69  1.1  jdolecek  * SUCH DAMAGE.
     70  1.1  jdolecek  *
     71  1.1  jdolecek  *	@(#)procfs.h	8.9 (Berkeley) 5/14/95
     72  1.1  jdolecek  */
     73  1.1  jdolecek 
     74  1.1  jdolecek #ifdef _KERNEL
     75  1.1  jdolecek /*
     76  1.1  jdolecek  * The different types of node in a ptyfs filesystem
     77  1.1  jdolecek  */
     78  1.1  jdolecek typedef enum {
     79  1.1  jdolecek 	PTYFSpts,	/* The slave side of a pty */
     80  1.1  jdolecek 	PTYFSptc,	/* The controlling side of a pty */
     81  1.1  jdolecek 	PTYFSroot,	/* the filesystem root */
     82  1.1  jdolecek } ptyfstype;
     83  1.1  jdolecek 
     84  1.1  jdolecek /*
     85  1.1  jdolecek  * control data for the proc file system.
     86  1.1  jdolecek  */
     87  1.1  jdolecek struct ptyfsnode {
     88  1.1  jdolecek 	LIST_ENTRY(ptyfsnode) ptyfs_hash;	/* hash chain */
     89  1.1  jdolecek 	struct vnode	*ptyfs_vnode;	/* vnode associated with this ptyfsnode */
     90  1.1  jdolecek 	ptyfstype	ptyfs_type;	/* type of ptyfs node */
     91  1.1  jdolecek 	int		ptyfs_pty;	/* the pty index */
     92  1.1  jdolecek 	u_long		ptyfs_fileno;	/* unique file id */
     93  1.1  jdolecek 	int		ptyfs_flag;	/* status flag for times */
     94  1.1  jdolecek #define	PTYFS_ACCESS	1
     95  1.1  jdolecek #define	PTYFS_MODIFY	2
     96  1.1  jdolecek #define	PTYFS_CHANGE	4
     97  1.1  jdolecek 	/* Attribute information */
     98  1.1  jdolecek 	uid_t		ptyfs_uid;
     99  1.1  jdolecek 	gid_t		ptyfs_gid;
    100  1.1  jdolecek 	mode_t		ptyfs_mode;
    101  1.1  jdolecek 	int		ptyfs_flags;
    102  1.1  jdolecek 	struct timespec	ptyfs_ctime, ptyfs_mtime, ptyfs_atime, ptyfs_birthtime;
    103  1.1  jdolecek };
    104  1.1  jdolecek 
    105  1.2  christos struct ptyfsmount {
    106  1.2  christos 	gid_t pmnt_gid;
    107  1.2  christos 	mode_t pmnt_mode;
    108  1.2  christos };
    109  1.2  christos 
    110  1.2  christos #define VFSTOPTY(mp)	((struct ptyfsmount *)(mp)->mnt_data)
    111  1.2  christos 
    112  1.1  jdolecek #endif /* _KERNEL */
    113  1.1  jdolecek 
    114  1.2  christos struct ptyfs_args {
    115  1.2  christos 	int version;
    116  1.2  christos 	gid_t gid;
    117  1.2  christos 	mode_t mode;
    118  1.2  christos };
    119  1.2  christos 
    120  1.2  christos #define PTYFS_ARGSVERSION	1
    121  1.2  christos 
    122  1.1  jdolecek /*
    123  1.1  jdolecek  * Kernel stuff follows
    124  1.1  jdolecek  */
    125  1.1  jdolecek #ifdef _KERNEL
    126  1.1  jdolecek 
    127  1.1  jdolecek #define UIO_MX 32
    128  1.1  jdolecek 
    129  1.1  jdolecek #define PTYFS_FILENO(pty, type) \
    130  1.1  jdolecek     ((((uint32_t)type) << 30) | (pty + 1))
    131  1.1  jdolecek 
    132  1.1  jdolecek #define PTYFS_MAKEDEV(ptyfs) \
    133  1.1  jdolecek     pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty)
    134  1.1  jdolecek 
    135  1.1  jdolecek /*
    136  1.1  jdolecek  * Convert between ptyfsnode vnode
    137  1.1  jdolecek  */
    138  1.1  jdolecek #define VTOPTYFS(vp)	((struct ptyfsnode *)(vp)->v_data)
    139  1.1  jdolecek #define PTYFSTOV(ptyfs)	((ptyfs)->ptyfs_vnode)
    140  1.1  jdolecek 
    141  1.1  jdolecek int ptyfs_freevp(struct vnode *);
    142  1.1  jdolecek int ptyfs_allocvp(struct mount *, struct vnode **, ptyfstype, int,
    143  1.1  jdolecek     struct proc *);
    144  1.1  jdolecek void ptyfs_hashinit(void);
    145  1.1  jdolecek void ptyfs_hashreinit(void);
    146  1.1  jdolecek void ptyfs_hashdone(void);
    147  1.1  jdolecek 
    148  1.1  jdolecek extern int (**ptyfs_vnodeop_p)(void *);
    149  1.1  jdolecek extern struct vfsops ptyfs_vfsops;
    150  1.1  jdolecek 
    151  1.1  jdolecek int	ptyfs_root(struct mount *, struct vnode **);
    152  1.1  jdolecek 
    153  1.1  jdolecek #ifdef SYSCTL_SETUP_PROTO
    154  1.1  jdolecek SYSCTL_SETUP_PROTO(sysctl_vfs_ptyfs_setup);
    155  1.1  jdolecek #endif /* SYSCTL_SETUP_PROTO */
    156  1.1  jdolecek #endif /* _KERNEL */
    157