Home | History | Annotate | Line # | Download | only in ptyfs
ptyfs.h revision 1.6.76.1
      1  1.6.76.1  wrstuden /*	$NetBSD: ptyfs.h,v 1.6.76.1 2008/09/18 04:36:55 wrstuden 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.2  christos };
    112       1.2  christos 
    113       1.2  christos #define VFSTOPTY(mp)	((struct ptyfsmount *)(mp)->mnt_data)
    114       1.2  christos 
    115       1.1  jdolecek #endif /* _KERNEL */
    116       1.1  jdolecek 
    117       1.2  christos struct ptyfs_args {
    118       1.2  christos 	int version;
    119       1.2  christos 	gid_t gid;
    120       1.2  christos 	mode_t mode;
    121       1.2  christos };
    122       1.2  christos 
    123       1.2  christos #define PTYFS_ARGSVERSION	1
    124       1.2  christos 
    125       1.1  jdolecek /*
    126       1.1  jdolecek  * Kernel stuff follows
    127       1.1  jdolecek  */
    128       1.1  jdolecek #ifdef _KERNEL
    129       1.1  jdolecek 
    130       1.1  jdolecek #define UIO_MX 32
    131       1.1  jdolecek 
    132       1.1  jdolecek #define PTYFS_FILENO(pty, type) \
    133       1.3    atatat     ((type == PTYFSroot) ? 2 : \
    134       1.3    atatat      ((((pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2))))
    135       1.1  jdolecek 
    136       1.1  jdolecek #define PTYFS_MAKEDEV(ptyfs) \
    137       1.1  jdolecek     pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty)
    138       1.1  jdolecek 
    139       1.4  christos #define PTYFS_ITIMES(ptyfs, acc, mod, cre) \
    140       1.4  christos    while ((ptyfs)->ptyfs_flag & (PTYFS_ACCESS|PTYFS_CHANGE|PTYFS_MODIFY)) \
    141       1.4  christos 	ptyfs_itimes(ptyfs, acc, mod, cre)
    142       1.1  jdolecek /*
    143       1.1  jdolecek  * Convert between ptyfsnode vnode
    144       1.1  jdolecek  */
    145       1.1  jdolecek #define VTOPTYFS(vp)	((struct ptyfsnode *)(vp)->v_data)
    146       1.1  jdolecek #define PTYFSTOV(ptyfs)	((ptyfs)->ptyfs_vnode)
    147       1.1  jdolecek 
    148       1.1  jdolecek int ptyfs_freevp(struct vnode *);
    149       1.1  jdolecek int ptyfs_allocvp(struct mount *, struct vnode **, ptyfstype, int,
    150       1.6  christos     struct lwp *);
    151       1.1  jdolecek void ptyfs_hashinit(void);
    152       1.1  jdolecek void ptyfs_hashreinit(void);
    153       1.1  jdolecek void ptyfs_hashdone(void);
    154       1.4  christos void ptyfs_itimes(struct ptyfsnode *, const struct timespec *,
    155       1.4  christos     const struct timespec *, const struct timespec *);
    156       1.1  jdolecek 
    157       1.1  jdolecek extern int (**ptyfs_vnodeop_p)(void *);
    158       1.1  jdolecek extern struct vfsops ptyfs_vfsops;
    159       1.1  jdolecek 
    160       1.1  jdolecek int	ptyfs_root(struct mount *, struct vnode **);
    161       1.1  jdolecek 
    162       1.1  jdolecek #endif /* _KERNEL */
    163       1.5  christos #endif /* _FS_PTYFS_PTYFS_H_ */
    164