1 /* 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)specdev.h 7.8 (Berkeley) 04/21/92 8 */ 9 10 /* 11 * This structure defines the information maintained about 12 * special devices. It is allocated in checkalias and freed 13 * in vgone. 14 */ 15 struct specinfo { 16 struct vnode **si_hashchain; 17 struct vnode *si_specnext; 18 long si_flags; 19 dev_t si_rdev; 20 }; 21 /* 22 * Exported shorthand 23 */ 24 #define v_rdev v_specinfo->si_rdev 25 #define v_hashchain v_specinfo->si_hashchain 26 #define v_specnext v_specinfo->si_specnext 27 #define v_specflags v_specinfo->si_flags 28 29 /* 30 * Flags for specinfo 31 */ 32 #define SI_MOUNTEDON 0x0001 /* block special device is mounted on */ 33 34 /* 35 * Special device management 36 */ 37 #define SPECHSZ 64 38 #if ((SPECHSZ&(SPECHSZ-1)) == 0) 39 #define SPECHASH(rdev) (((rdev>>5)+(rdev))&(SPECHSZ-1)) 40 #else 41 #define SPECHASH(rdev) (((unsigned)((rdev>>5)+(rdev)))%SPECHSZ) 42 #endif 43 44 struct vnode *speclisth[SPECHSZ]; 45 46 /* 47 * Prototypes for special file operations on vnodes. 48 */ 49 struct nameidata; 50 struct componentname; 51 struct ucred; 52 struct flock; 53 struct buf; 54 struct uio; 55 56 int spec_badop(), 57 spec_ebadf(); 58 59 int spec_lookup __P(( 60 struct vnode *dvp, 61 struct vnode **vpp, 62 struct componentname *cnp)); 63 #define spec_create ((int (*) __P(( \ 64 struct vnode *dvp, \ 65 struct vnode **vpp, \ 66 struct componentname *cnp, \ 67 struct vattr *vap))) spec_badop) 68 #define spec_mknod ((int (*) __P(( \ 69 struct vnode *dvp, \ 70 struct vnode **vpp, \ 71 struct componentname *cnp, \ 72 struct vattr *vap))) spec_badop) 73 int spec_open __P(( 74 struct vnode *vp, 75 int mode, 76 struct ucred *cred, 77 struct proc *p)); 78 int spec_close __P(( 79 struct vnode *vp, 80 int fflag, 81 struct ucred *cred, 82 struct proc *p)); 83 #define spec_access ((int (*) __P(( \ 84 struct vnode *vp, \ 85 int mode, \ 86 struct ucred *cred, \ 87 struct proc *p))) spec_ebadf) 88 #define spec_getattr ((int (*) __P(( \ 89 struct vnode *vp, \ 90 struct vattr *vap, \ 91 struct ucred *cred, \ 92 struct proc *p))) spec_ebadf) 93 #define spec_setattr ((int (*) __P(( \ 94 struct vnode *vp, \ 95 struct vattr *vap, \ 96 struct ucred *cred, \ 97 struct proc *p))) spec_ebadf) 98 int spec_read __P(( 99 struct vnode *vp, 100 struct uio *uio, 101 int ioflag, 102 struct ucred *cred)); 103 int spec_write __P(( 104 struct vnode *vp, 105 struct uio *uio, 106 int ioflag, 107 struct ucred *cred)); 108 int spec_ioctl __P(( 109 struct vnode *vp, 110 int command, 111 caddr_t data, 112 int fflag, 113 struct ucred *cred, 114 struct proc *p)); 115 int spec_select __P(( 116 struct vnode *vp, 117 int which, 118 int fflags, 119 struct ucred *cred, 120 struct proc *p)); 121 #define spec_mmap ((int (*) __P(( \ 122 struct vnode *vp, \ 123 int fflags, \ 124 struct ucred *cred, \ 125 struct proc *p))) spec_badop) 126 #define spec_fsync ((int (*) __P(( \ 127 struct vnode *vp, \ 128 int fflags, \ 129 struct ucred *cred, \ 130 int waitfor, \ 131 struct proc *p))) nullop) 132 #define spec_seek ((int (*) __P(( \ 133 struct vnode *vp, \ 134 off_t oldoff, \ 135 off_t newoff, \ 136 struct ucred *cred))) spec_badop) 137 #define spec_remove ((int (*) __P(( \ 138 struct vnode *dvp, \ 139 struct vnode *vp, \ 140 struct componentname *cnp))) spec_badop) 141 #define spec_link ((int (*) __P(( \ 142 register struct vnode *vp, \ 143 struct vnode *tdvp, \ 144 struct componentname *cnp))) spec_badop) 145 #define spec_rename ((int (*) __P(( \ 146 struct vnode *fdvp, \ 147 struct vnode *fvp, \ 148 struct componentname *fcnp, \ 149 struct vnode *tdvp, \ 150 struct vnode *tvp, \ 151 struct componentname *tcnp))) spec_badop) 152 #define spec_mkdir ((int (*) __P(( \ 153 struct vnode *dvp, \ 154 struct vnode **vpp, \ 155 struct componentname *cnp, \ 156 struct vattr *vap))) spec_badop) 157 #define spec_rmdir ((int (*) __P(( \ 158 struct vnode *dvp, \ 159 struct vnode *vp, \ 160 struct componentname *cnp))) spec_badop) 161 #define spec_symlink ((int (*) __P(( \ 162 struct vnode *dvp, \ 163 struct vnode **vpp, \ 164 struct componentname *cnp, \ 165 struct vattr *vap, \ 166 char *target))) spec_badop) 167 #define spec_readdir ((int (*) __P(( \ 168 struct vnode *vp, \ 169 struct uio *uio, \ 170 struct ucred *cred, \ 171 int *eofflagp))) spec_badop) 172 #define spec_readlink ((int (*) __P(( \ 173 struct vnode *vp, \ 174 struct uio *uio, \ 175 struct ucred *cred))) spec_badop) 176 #define spec_abortop ((int (*) __P(( \ 177 struct vnode *dvp, \ 178 struct componentname *cnp))) spec_badop) 179 #define spec_inactive ((int (*) __P(( \ 180 struct vnode *vp, \ 181 struct proc *p))) nullop) 182 #define spec_reclaim ((int (*) __P(( \ 183 struct vnode *vp))) nullop) 184 int spec_lock __P(( 185 struct vnode *vp)); 186 int spec_unlock __P(( 187 struct vnode *vp)); 188 int spec_bmap __P(( 189 struct vnode *vp, 190 daddr_t bn, 191 struct vnode **vpp, 192 daddr_t *bnp)); 193 int spec_strategy __P(( 194 struct buf *bp)); 195 int spec_print __P(( 196 struct vnode *vp)); 197 #define spec_islocked ((int (*) __P(( \ 198 struct vnode *vp))) nullop) 199 int spec_advlock __P(( 200 struct vnode *vp, 201 caddr_t id, 202 int op, 203 struct flock *fl, 204 int flags)); 205 #define spec_blkatoff ((int (*) __P(( \ 206 struct vnode *vp, \ 207 off_t offset, \ 208 char **res, \ 209 struct buf **bpp))) spec_badop) 210 #define spec_vget ((int (*) __P(( \ 211 struct mount *mp, \ 212 ino_t ino, \ 213 struct vnode **vpp))) spec_badop) 214 #define spec_valloc ((int (*) __P(( \ 215 struct vnode *pvp, \ 216 int mode, \ 217 struct ucred *cred, \ 218 struct vnode **vpp))) spec_badop) 219 #define spec_vfree ((void (*) __P(( \ 220 struct vnode *pvp, \ 221 ino_t ino, \ 222 int mode))) spec_badop) 223 #define spec_truncate ((int (*) __P(( \ 224 struct vnode *vp, \ 225 off_t length, \ 226 int flags, \ 227 struct ucred *cred))) nullop) 228 #define spec_update ((int (*) __P(( \ 229 struct vnode *vp, \ 230 struct timeval *ta, \ 231 struct timeval *tm, \ 232 int waitfor))) nullop) 233 #define spec_bwrite ((int (*) __P(( \ 234 struct buf *bp))) nullop) 235