1 1.16 christos /* $NetBSD: ptyfs.h,v 1.16 2020/11/27 14:43:57 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.14 hannken struct ptyfskey { 91 1.14 hannken ptyfstype ptk_type; /* type of ptyfs node */ 92 1.14 hannken int ptk_pty; /* the pty index */ 93 1.14 hannken }; 94 1.1 jdolecek struct ptyfsnode { 95 1.14 hannken SLIST_ENTRY(ptyfsnode) ptyfs_hash; /* hash chain */ 96 1.14 hannken struct ptyfskey ptyfs_key; 97 1.14 hannken #define ptyfs_type ptyfs_key.ptk_type 98 1.14 hannken #define ptyfs_pty ptyfs_key.ptk_pty 99 1.1 jdolecek u_long ptyfs_fileno; /* unique file id */ 100 1.10 christos int ptyfs_status; /* status flag for times */ 101 1.1 jdolecek #define PTYFS_ACCESS 1 102 1.1 jdolecek #define PTYFS_MODIFY 2 103 1.1 jdolecek #define PTYFS_CHANGE 4 104 1.1 jdolecek /* Attribute information */ 105 1.1 jdolecek uid_t ptyfs_uid; 106 1.1 jdolecek gid_t ptyfs_gid; 107 1.1 jdolecek mode_t ptyfs_mode; 108 1.1 jdolecek int ptyfs_flags; 109 1.1 jdolecek struct timespec ptyfs_ctime, ptyfs_mtime, ptyfs_atime, ptyfs_birthtime; 110 1.1 jdolecek }; 111 1.1 jdolecek 112 1.2 christos struct ptyfsmount { 113 1.13 hannken kmutex_t pmnt_lock; 114 1.12 christos TAILQ_ENTRY(ptyfsmount) pmnt_le; 115 1.12 christos struct mount *pmnt_mp; 116 1.2 christos gid_t pmnt_gid; 117 1.2 christos mode_t pmnt_mode; 118 1.8 christos int pmnt_flags; 119 1.13 hannken int pmnt_bitmap_size; 120 1.13 hannken uint8_t *pmnt_bitmap; 121 1.2 christos }; 122 1.2 christos 123 1.2 christos #define VFSTOPTY(mp) ((struct ptyfsmount *)(mp)->mnt_data) 124 1.2 christos 125 1.1 jdolecek #endif /* _KERNEL */ 126 1.1 jdolecek 127 1.2 christos struct ptyfs_args { 128 1.2 christos int version; 129 1.2 christos gid_t gid; 130 1.2 christos mode_t mode; 131 1.8 christos int flags; 132 1.2 christos }; 133 1.2 christos 134 1.8 christos #define PTYFS_ARGSVERSION 2 135 1.8 christos 136 1.1 jdolecek /* 137 1.1 jdolecek * Kernel stuff follows 138 1.1 jdolecek */ 139 1.1 jdolecek #ifdef _KERNEL 140 1.1 jdolecek 141 1.1 jdolecek #define UIO_MX 32 142 1.1 jdolecek 143 1.16 christos #define PTYFS_FILENO(type, pty) \ 144 1.3 atatat ((type == PTYFSroot) ? 2 : \ 145 1.3 atatat ((((pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2)))) 146 1.1 jdolecek 147 1.1 jdolecek #define PTYFS_MAKEDEV(ptyfs) \ 148 1.1 jdolecek pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty) 149 1.1 jdolecek 150 1.4 christos #define PTYFS_ITIMES(ptyfs, acc, mod, cre) \ 151 1.10 christos while ((ptyfs)->ptyfs_status & (PTYFS_ACCESS|PTYFS_CHANGE|PTYFS_MODIFY)) \ 152 1.4 christos ptyfs_itimes(ptyfs, acc, mod, cre) 153 1.1 jdolecek /* 154 1.1 jdolecek * Convert between ptyfsnode vnode 155 1.1 jdolecek */ 156 1.1 jdolecek #define VTOPTYFS(vp) ((struct ptyfsnode *)(vp)->v_data) 157 1.1 jdolecek 158 1.13 hannken void ptyfs_set_active(struct mount *, int); 159 1.13 hannken void ptyfs_clr_active(struct mount *, int); 160 1.13 hannken int ptyfs_next_active(struct mount *, int); 161 1.13 hannken int ptyfs_allocvp(struct mount *, struct vnode **, ptyfstype, int); 162 1.1 jdolecek void ptyfs_hashinit(void); 163 1.1 jdolecek void ptyfs_hashdone(void); 164 1.14 hannken struct ptyfsnode *ptyfs_get_node(ptyfstype, int); 165 1.4 christos void ptyfs_itimes(struct ptyfsnode *, const struct timespec *, 166 1.4 christos const struct timespec *, const struct timespec *); 167 1.1 jdolecek 168 1.1 jdolecek extern int (**ptyfs_vnodeop_p)(void *); 169 1.1 jdolecek extern struct vfsops ptyfs_vfsops; 170 1.1 jdolecek 171 1.15 ad int ptyfs_root(struct mount *, int, struct vnode **); 172 1.1 jdolecek 173 1.1 jdolecek #endif /* _KERNEL */ 174 1.5 christos #endif /* _FS_PTYFS_PTYFS_H_ */ 175