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.5 (Berkeley) 11/05/91 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 ucred; 51 struct flock; 52 struct buf; 53 struct uio; 54 55 int spec_badop(), 56 spec_ebadf(); 57 58 int spec_lookup __P(( 59 struct vnode *vp, 60 struct nameidata *ndp, 61 struct proc *p)); 62 #define spec_create ((int (*) __P(( \ 63 struct nameidata *ndp, \ 64 struct vattr *vap, \ 65 struct proc *p))) spec_badop) 66 #define spec_mknod ((int (*) __P(( \ 67 struct nameidata *ndp, \ 68 struct vattr *vap, \ 69 struct ucred *cred, \ 70 struct proc *p))) spec_badop) 71 int spec_open __P(( 72 struct vnode *vp, 73 int mode, 74 struct ucred *cred, 75 struct proc *p)); 76 int spec_close __P(( 77 struct vnode *vp, 78 int fflag, 79 struct ucred *cred, 80 struct proc *p)); 81 #define spec_access ((int (*) __P(( \ 82 struct vnode *vp, \ 83 int mode, \ 84 struct ucred *cred, \ 85 struct proc *p))) spec_ebadf) 86 #define spec_getattr ((int (*) __P(( \ 87 struct vnode *vp, \ 88 struct vattr *vap, \ 89 struct ucred *cred, \ 90 struct proc *p))) spec_ebadf) 91 #define spec_setattr ((int (*) __P(( \ 92 struct vnode *vp, \ 93 struct vattr *vap, \ 94 struct ucred *cred, \ 95 struct proc *p))) spec_ebadf) 96 int spec_read __P(( 97 struct vnode *vp, 98 struct uio *uio, 99 int ioflag, 100 struct ucred *cred)); 101 int spec_write __P(( 102 struct vnode *vp, 103 struct uio *uio, 104 int ioflag, 105 struct ucred *cred)); 106 int spec_ioctl __P(( 107 struct vnode *vp, 108 int command, 109 caddr_t data, 110 int fflag, 111 struct ucred *cred, 112 struct proc *p)); 113 int spec_select __P(( 114 struct vnode *vp, 115 int which, 116 int fflags, 117 struct ucred *cred, 118 struct proc *p)); 119 #define spec_mmap ((int (*) __P(( \ 120 struct vnode *vp, \ 121 int fflags, \ 122 struct ucred *cred, \ 123 struct proc *p))) spec_badop) 124 #define spec_fsync ((int (*) __P(( \ 125 struct vnode *vp, \ 126 int fflags, \ 127 struct ucred *cred, \ 128 int waitfor, \ 129 struct proc *p))) nullop) 130 #define spec_seek ((int (*) __P(( \ 131 struct vnode *vp, \ 132 off_t oldoff, \ 133 off_t newoff, \ 134 struct ucred *cred))) spec_badop) 135 #define spec_remove ((int (*) __P(( \ 136 struct nameidata *ndp, \ 137 struct proc *p))) spec_badop) 138 #define spec_link ((int (*) __P(( \ 139 struct vnode *vp, \ 140 struct nameidata *ndp, \ 141 struct proc *p))) spec_badop) 142 #define spec_rename ((int (*) __P(( \ 143 struct nameidata *fndp, \ 144 struct nameidata *tdnp, \ 145 struct proc *p))) spec_badop) 146 #define spec_mkdir ((int (*) __P(( \ 147 struct nameidata *ndp, \ 148 struct vattr *vap, \ 149 struct proc *p))) spec_badop) 150 #define spec_rmdir ((int (*) __P(( \ 151 struct nameidata *ndp, \ 152 struct proc *p))) spec_badop) 153 #define spec_symlink ((int (*) __P(( \ 154 struct nameidata *ndp, \ 155 struct vattr *vap, \ 156 char *target, \ 157 struct proc *p))) spec_badop) 158 #define spec_readdir ((int (*) __P(( \ 159 struct vnode *vp, \ 160 struct uio *uio, \ 161 struct ucred *cred, \ 162 int *eofflagp))) spec_badop) 163 #define spec_readlink ((int (*) __P(( \ 164 struct vnode *vp, \ 165 struct uio *uio, \ 166 struct ucred *cred))) spec_badop) 167 #define spec_abortop ((int (*) __P(( \ 168 struct nameidata *ndp))) spec_badop) 169 #define spec_inactive ((int (*) __P(( \ 170 struct vnode *vp, \ 171 struct proc *p))) nullop) 172 #define spec_reclaim ((int (*) __P(( \ 173 struct vnode *vp))) nullop) 174 int spec_lock __P(( 175 struct vnode *vp)); 176 int spec_unlock __P(( 177 struct vnode *vp)); 178 int spec_bmap __P(( 179 struct vnode *vp, 180 daddr_t bn, 181 struct vnode **vpp, 182 daddr_t *bnp)); 183 int spec_strategy __P(( 184 struct buf *bp)); 185 int spec_print __P(( 186 struct vnode *vp)); 187 #define spec_islocked ((int (*) __P(( \ 188 struct vnode *vp))) nullop) 189 int spec_advlock __P(( 190 struct vnode *vp, 191 caddr_t id, 192 int op, 193 struct flock *fl, 194 int flags)); 195 #define spec_blkatoff ((int (*) __P(( \ 196 struct vnode *vp, \ 197 off_t offset, \ 198 char **res, \ 199 struct buf **bpp))) spec_badop) 200 #define spec_vget ((int (*) __P(( \ 201 struct mount *mp, \ 202 ino_t ino, \ 203 struct vnode **vpp))) spec_badop) 204 #define spec_valloc ((int (*) __P(( \ 205 struct vnode *pvp, \ 206 int mode, \ 207 struct ucred *cred, \ 208 struct vnode **vpp))) spec_badop) 209 #define spec_vfree ((void (*) __P(( \ 210 struct vnode *pvp, \ 211 ino_t ino, \ 212 int mode))) spec_badop) 213 #define spec_truncate ((int (*) __P(( \ 214 struct vnode *vp, \ 215 u_long length, \ 216 int flags))) nullop) 217 #define spec_update ((int (*) __P(( \ 218 struct vnode *vp, \ 219 struct timeval *ta, \ 220 struct timeval *tm, \ 221 int waitfor))) nullop) 222 #define spec_bwrite ((int (*) __P(( \ 223 struct buf *bp))) nullop) 224