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