Home | History | Annotate | Line # | Download | only in ptyfs
ptyfs.h revision 1.8
      1  1.8  christos /*	$NetBSD: ptyfs.h,v 1.8 2009/03/15 16:43:55 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.5  christos #ifndef _FS_PTYFS_PTYFS_H_
     75  1.5  christos #define _FS_PTYFS_PTYFS_H_
     76  1.5  christos 
     77  1.1  jdolecek #ifdef _KERNEL
     78  1.1  jdolecek /*
     79  1.1  jdolecek  * The different types of node in a ptyfs filesystem
     80  1.1  jdolecek  */
     81  1.1  jdolecek typedef enum {
     82  1.1  jdolecek 	PTYFSpts,	/* The slave side of a pty */
     83  1.1  jdolecek 	PTYFSptc,	/* The controlling side of a pty */
     84  1.1  jdolecek 	PTYFSroot,	/* the filesystem root */
     85  1.1  jdolecek } ptyfstype;
     86  1.1  jdolecek 
     87  1.1  jdolecek /*
     88  1.1  jdolecek  * control data for the proc file system.
     89  1.1  jdolecek  */
     90  1.1  jdolecek struct ptyfsnode {
     91  1.1  jdolecek 	LIST_ENTRY(ptyfsnode) ptyfs_hash;	/* hash chain */
     92  1.1  jdolecek 	struct vnode	*ptyfs_vnode;	/* vnode associated with this ptyfsnode */
     93  1.1  jdolecek 	ptyfstype	ptyfs_type;	/* type of ptyfs node */
     94  1.1  jdolecek 	int		ptyfs_pty;	/* the pty index */
     95  1.1  jdolecek 	u_long		ptyfs_fileno;	/* unique file id */
     96  1.1  jdolecek 	int		ptyfs_flag;	/* status flag for times */
     97  1.1  jdolecek #define	PTYFS_ACCESS	1
     98  1.1  jdolecek #define	PTYFS_MODIFY	2
     99  1.1  jdolecek #define	PTYFS_CHANGE	4
    100  1.1  jdolecek 	/* Attribute information */
    101  1.1  jdolecek 	uid_t		ptyfs_uid;
    102  1.1  jdolecek 	gid_t		ptyfs_gid;
    103  1.1  jdolecek 	mode_t		ptyfs_mode;
    104  1.1  jdolecek 	int		ptyfs_flags;
    105  1.1  jdolecek 	struct timespec	ptyfs_ctime, ptyfs_mtime, ptyfs_atime, ptyfs_birthtime;
    106  1.1  jdolecek };
    107  1.1  jdolecek 
    108  1.2  christos struct ptyfsmount {
    109  1.2  christos 	gid_t pmnt_gid;
    110  1.2  christos 	mode_t pmnt_mode;
    111  1.8  christos 	int pmnt_flags;
    112  1.2  christos };
    113  1.2  christos 
    114  1.2  christos #define VFSTOPTY(mp)	((struct ptyfsmount *)(mp)->mnt_data)
    115  1.2  christos 
    116  1.1  jdolecek #endif /* _KERNEL */
    117  1.1  jdolecek 
    118  1.2  christos struct ptyfs_args {
    119  1.2  christos 	int version;
    120  1.2  christos 	gid_t gid;
    121  1.2  christos 	mode_t mode;
    122  1.8  christos 	int flags;
    123  1.2  christos };
    124  1.2  christos 
    125  1.8  christos #define PTYFS_ARGSVERSION	2
    126  1.8  christos 
    127  1.8  christos #define PTYFSMNT_CHROOT		0x01
    128  1.8  christos 
    129  1.8  christos #define PTYFSMNT_BITS "\177\20" \
    130  1.8  christos     "b\00chroot\0"
    131  1.2  christos 
    132  1.1  jdolecek /*
    133  1.1  jdolecek  * Kernel stuff follows
    134  1.1  jdolecek  */
    135  1.1  jdolecek #ifdef _KERNEL
    136  1.1  jdolecek 
    137  1.1  jdolecek #define UIO_MX 32
    138  1.1  jdolecek 
    139  1.1  jdolecek #define PTYFS_FILENO(pty, type) \
    140  1.3    atatat     ((type == PTYFSroot) ? 2 : \
    141  1.3    atatat      ((((pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2))))
    142  1.1  jdolecek 
    143  1.1  jdolecek #define PTYFS_MAKEDEV(ptyfs) \
    144  1.1  jdolecek     pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty)
    145  1.1  jdolecek 
    146  1.4  christos #define PTYFS_ITIMES(ptyfs, acc, mod, cre) \
    147  1.4  christos    while ((ptyfs)->ptyfs_flag & (PTYFS_ACCESS|PTYFS_CHANGE|PTYFS_MODIFY)) \
    148  1.4  christos 	ptyfs_itimes(ptyfs, acc, mod, cre)
    149  1.1  jdolecek /*
    150  1.1  jdolecek  * Convert between ptyfsnode vnode
    151  1.1  jdolecek  */
    152  1.1  jdolecek #define VTOPTYFS(vp)	((struct ptyfsnode *)(vp)->v_data)
    153  1.1  jdolecek #define PTYFSTOV(ptyfs)	((ptyfs)->ptyfs_vnode)
    154  1.1  jdolecek 
    155  1.1  jdolecek int ptyfs_freevp(struct vnode *);
    156  1.1  jdolecek int ptyfs_allocvp(struct mount *, struct vnode **, ptyfstype, int,
    157  1.6  christos     struct lwp *);
    158  1.1  jdolecek void ptyfs_hashinit(void);
    159  1.1  jdolecek void ptyfs_hashreinit(void);
    160  1.1  jdolecek void ptyfs_hashdone(void);
    161  1.4  christos void ptyfs_itimes(struct ptyfsnode *, const struct timespec *,
    162  1.4  christos     const struct timespec *, const struct timespec *);
    163  1.1  jdolecek 
    164  1.1  jdolecek extern int (**ptyfs_vnodeop_p)(void *);
    165  1.1  jdolecek extern struct vfsops ptyfs_vfsops;
    166  1.1  jdolecek 
    167  1.1  jdolecek int	ptyfs_root(struct mount *, struct vnode **);
    168  1.1  jdolecek 
    169  1.1  jdolecek #endif /* _KERNEL */
    170  1.5  christos #endif /* _FS_PTYFS_PTYFS_H_ */
    171