140654Smckusick /* 240654Smckusick * Copyright (c) 1990 The Regents of the University of California. 340654Smckusick * All rights reserved. 440654Smckusick * 544523Sbostic * %sccs.include.redist.c% 640654Smckusick * 7*48009Smckusick * @(#)specdev.h 7.3 (Berkeley) 04/15/91 840654Smckusick */ 940654Smckusick 1040654Smckusick /* 1140654Smckusick * This structure defines the information maintained about 1240654Smckusick * special devices. It is allocated in checkalias and freed 1340654Smckusick * in vgone. 1440654Smckusick */ 1540654Smckusick struct specinfo { 1640654Smckusick struct vnode **si_hashchain; 1740654Smckusick struct vnode *si_specnext; 1840654Smckusick long si_flags; 1940654Smckusick dev_t si_rdev; 2040654Smckusick }; 2140654Smckusick /* 2240654Smckusick * Exported shorthand 2340654Smckusick */ 2440654Smckusick #define v_rdev v_specinfo->si_rdev 2540654Smckusick #define v_hashchain v_specinfo->si_hashchain 2640654Smckusick #define v_specnext v_specinfo->si_specnext 2740654Smckusick #define v_specflags v_specinfo->si_flags 2840654Smckusick 2940654Smckusick /* 3040654Smckusick * Flags for specinfo 3140654Smckusick */ 3240654Smckusick #define SI_MOUNTEDON 0x0001 /* block special device is mounted on */ 3340654Smckusick 3440654Smckusick /* 3540654Smckusick * Special device management 3640654Smckusick */ 3740654Smckusick #define SPECHSZ 64 3840654Smckusick #if ((SPECHSZ&(SPECHSZ-1)) == 0) 3940654Smckusick #define SPECHASH(rdev) (((rdev>>5)+(rdev))&(SPECHSZ-1)) 4040654Smckusick #else 4140654Smckusick #define SPECHASH(rdev) (((unsigned)((rdev>>5)+(rdev)))%SPECHSZ) 4240654Smckusick #endif 4340654Smckusick 4440654Smckusick struct vnode *speclisth[SPECHSZ]; 45*48009Smckusick 46*48009Smckusick /* 47*48009Smckusick * Prototypes for special file operations on vnodes. 48*48009Smckusick */ 49*48009Smckusick int spec_badop(), 50*48009Smckusick spec_ebadf(); 51*48009Smckusick 52*48009Smckusick int spec_lookup __P(( 53*48009Smckusick struct vnode *vp, 54*48009Smckusick struct nameidata *ndp, 55*48009Smckusick struct proc *p)); 56*48009Smckusick #define spec_create ((int (*) __P(( \ 57*48009Smckusick struct nameidata *ndp, \ 58*48009Smckusick struct vattr *vap, \ 59*48009Smckusick struct proc *p))) spec_badop) 60*48009Smckusick #define spec_mknod ((int (*) __P(( \ 61*48009Smckusick struct nameidata *ndp, \ 62*48009Smckusick struct vattr *vap, \ 63*48009Smckusick struct ucred *cred, \ 64*48009Smckusick struct proc *p))) spec_badop) 65*48009Smckusick int spec_open __P(( 66*48009Smckusick struct vnode *vp, 67*48009Smckusick int mode, 68*48009Smckusick struct ucred *cred, 69*48009Smckusick struct proc *p)); 70*48009Smckusick int spec_close __P(( 71*48009Smckusick struct vnode *vp, 72*48009Smckusick int fflag, 73*48009Smckusick struct ucred *cred, 74*48009Smckusick struct proc *p)); 75*48009Smckusick #define spec_access ((int (*) __P(( \ 76*48009Smckusick struct vnode *vp, \ 77*48009Smckusick int mode, \ 78*48009Smckusick struct ucred *cred, \ 79*48009Smckusick struct proc *p))) spec_ebadf) 80*48009Smckusick #define spec_getattr ((int (*) __P(( \ 81*48009Smckusick struct vnode *vp, \ 82*48009Smckusick struct vattr *vap, \ 83*48009Smckusick struct ucred *cred, \ 84*48009Smckusick struct proc *p))) spec_ebadf) 85*48009Smckusick #define spec_setattr ((int (*) __P(( \ 86*48009Smckusick struct vnode *vp, \ 87*48009Smckusick struct vattr *vap, \ 88*48009Smckusick struct ucred *cred, \ 89*48009Smckusick struct proc *p))) spec_ebadf) 90*48009Smckusick int spec_read __P(( 91*48009Smckusick struct vnode *vp, 92*48009Smckusick struct uio *uio, 93*48009Smckusick int ioflag, 94*48009Smckusick struct ucred *cred)); 95*48009Smckusick int spec_write __P(( 96*48009Smckusick struct vnode *vp, 97*48009Smckusick struct uio *uio, 98*48009Smckusick int ioflag, 99*48009Smckusick struct ucred *cred)); 100*48009Smckusick int spec_ioctl __P(( 101*48009Smckusick struct vnode *vp, 102*48009Smckusick int command, 103*48009Smckusick caddr_t data, 104*48009Smckusick int fflag, 105*48009Smckusick struct ucred *cred, 106*48009Smckusick struct proc *p)); 107*48009Smckusick int spec_select __P(( 108*48009Smckusick struct vnode *vp, 109*48009Smckusick int which, 110*48009Smckusick int fflags, 111*48009Smckusick struct ucred *cred, 112*48009Smckusick struct proc *p)); 113*48009Smckusick #define spec_mmap ((int (*) __P(( \ 114*48009Smckusick struct vnode *vp, \ 115*48009Smckusick int fflags, \ 116*48009Smckusick struct ucred *cred, \ 117*48009Smckusick struct proc *p))) spec_badop) 118*48009Smckusick #define spec_fsync ((int (*) __P(( \ 119*48009Smckusick struct vnode *vp, \ 120*48009Smckusick int fflags, \ 121*48009Smckusick struct ucred *cred, \ 122*48009Smckusick int waitfor, \ 123*48009Smckusick struct proc *p))) nullop) 124*48009Smckusick #define spec_seek ((int (*) __P(( \ 125*48009Smckusick struct vnode *vp, \ 126*48009Smckusick off_t oldoff, \ 127*48009Smckusick off_t newoff, \ 128*48009Smckusick struct ucred *cred))) spec_badop) 129*48009Smckusick #define spec_remove ((int (*) __P(( \ 130*48009Smckusick struct nameidata *ndp, \ 131*48009Smckusick struct proc *p))) spec_badop) 132*48009Smckusick #define spec_link ((int (*) __P(( \ 133*48009Smckusick struct vnode *vp, \ 134*48009Smckusick struct nameidata *ndp, \ 135*48009Smckusick struct proc *p))) spec_badop) 136*48009Smckusick #define spec_rename ((int (*) __P(( \ 137*48009Smckusick struct nameidata *fndp, \ 138*48009Smckusick struct nameidata *tdnp, \ 139*48009Smckusick struct proc *p))) spec_badop) 140*48009Smckusick #define spec_mkdir ((int (*) __P(( \ 141*48009Smckusick struct nameidata *ndp, \ 142*48009Smckusick struct vattr *vap, \ 143*48009Smckusick struct proc *p))) spec_badop) 144*48009Smckusick #define spec_rmdir ((int (*) __P(( \ 145*48009Smckusick struct nameidata *ndp, \ 146*48009Smckusick struct proc *p))) spec_badop) 147*48009Smckusick #define spec_symlink ((int (*) __P(( \ 148*48009Smckusick struct nameidata *ndp, \ 149*48009Smckusick struct vattr *vap, \ 150*48009Smckusick char *target, \ 151*48009Smckusick struct proc *p))) spec_badop) 152*48009Smckusick #define spec_readdir ((int (*) __P(( \ 153*48009Smckusick struct vnode *vp, \ 154*48009Smckusick struct uio *uio, \ 155*48009Smckusick struct ucred *cred, \ 156*48009Smckusick int *eofflagp))) spec_badop) 157*48009Smckusick #define spec_readlink ((int (*) __P(( \ 158*48009Smckusick struct vnode *vp, \ 159*48009Smckusick struct uio *uio, \ 160*48009Smckusick struct ucred *cred))) spec_badop) 161*48009Smckusick #define spec_abortop ((int (*) __P(( \ 162*48009Smckusick struct nameidata *ndp))) spec_badop) 163*48009Smckusick #define spec_inactive ((int (*) __P(( \ 164*48009Smckusick struct vnode *vp, \ 165*48009Smckusick struct proc *p))) nullop) 166*48009Smckusick #define spec_reclaim ((int (*) __P(( \ 167*48009Smckusick struct vnode *vp))) nullop) 168*48009Smckusick int spec_lock __P(( 169*48009Smckusick struct vnode *vp)); 170*48009Smckusick int spec_unlock __P(( 171*48009Smckusick struct vnode *vp)); 172*48009Smckusick int spec_bmap __P(( 173*48009Smckusick struct vnode *vp, 174*48009Smckusick daddr_t bn, 175*48009Smckusick struct vnode **vpp, 176*48009Smckusick daddr_t *bnp)); 177*48009Smckusick int spec_strategy __P(( 178*48009Smckusick struct buf *bp)); 179*48009Smckusick int spec_print __P(( 180*48009Smckusick struct vnode *vp)); 181*48009Smckusick #define spec_islocked ((int (*) __P(( \ 182*48009Smckusick struct vnode *vp))) nullop) 183*48009Smckusick int spec_advlock __P(( 184*48009Smckusick struct vnode *vp, 185*48009Smckusick caddr_t id, 186*48009Smckusick int op, 187*48009Smckusick struct flock *fl, 188*48009Smckusick int flags)); 189