140654Smckusick /* 240654Smckusick * Copyright (c) 1990 The Regents of the University of California. 340654Smckusick * All rights reserved. 440654Smckusick * 544523Sbostic * %sccs.include.redist.c% 640654Smckusick * 7*51555Smckusick * @(#)specdev.h 7.5 (Berkeley) 11/05/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]; 4548009Smckusick 4648009Smckusick /* 4748009Smckusick * Prototypes for special file operations on vnodes. 4848009Smckusick */ 4948363Smckusick struct nameidata; 5048363Smckusick struct ucred; 5148363Smckusick struct flock; 5248363Smckusick struct buf; 5348363Smckusick struct uio; 5448363Smckusick 5548009Smckusick int spec_badop(), 5648009Smckusick spec_ebadf(); 5748009Smckusick 5848009Smckusick int spec_lookup __P(( 5948009Smckusick struct vnode *vp, 6048009Smckusick struct nameidata *ndp, 6148009Smckusick struct proc *p)); 6248009Smckusick #define spec_create ((int (*) __P(( \ 6348009Smckusick struct nameidata *ndp, \ 6448009Smckusick struct vattr *vap, \ 6548009Smckusick struct proc *p))) spec_badop) 6648009Smckusick #define spec_mknod ((int (*) __P(( \ 6748009Smckusick struct nameidata *ndp, \ 6848009Smckusick struct vattr *vap, \ 6948009Smckusick struct ucred *cred, \ 7048009Smckusick struct proc *p))) spec_badop) 7148009Smckusick int spec_open __P(( 7248009Smckusick struct vnode *vp, 7348009Smckusick int mode, 7448009Smckusick struct ucred *cred, 7548009Smckusick struct proc *p)); 7648009Smckusick int spec_close __P(( 7748009Smckusick struct vnode *vp, 7848009Smckusick int fflag, 7948009Smckusick struct ucred *cred, 8048009Smckusick struct proc *p)); 8148009Smckusick #define spec_access ((int (*) __P(( \ 8248009Smckusick struct vnode *vp, \ 8348009Smckusick int mode, \ 8448009Smckusick struct ucred *cred, \ 8548009Smckusick struct proc *p))) spec_ebadf) 8648009Smckusick #define spec_getattr ((int (*) __P(( \ 8748009Smckusick struct vnode *vp, \ 8848009Smckusick struct vattr *vap, \ 8948009Smckusick struct ucred *cred, \ 9048009Smckusick struct proc *p))) spec_ebadf) 9148009Smckusick #define spec_setattr ((int (*) __P(( \ 9248009Smckusick struct vnode *vp, \ 9348009Smckusick struct vattr *vap, \ 9448009Smckusick struct ucred *cred, \ 9548009Smckusick struct proc *p))) spec_ebadf) 9648009Smckusick int spec_read __P(( 9748009Smckusick struct vnode *vp, 9848009Smckusick struct uio *uio, 9948009Smckusick int ioflag, 10048009Smckusick struct ucred *cred)); 10148009Smckusick int spec_write __P(( 10248009Smckusick struct vnode *vp, 10348009Smckusick struct uio *uio, 10448009Smckusick int ioflag, 10548009Smckusick struct ucred *cred)); 10648009Smckusick int spec_ioctl __P(( 10748009Smckusick struct vnode *vp, 10848009Smckusick int command, 10948009Smckusick caddr_t data, 11048009Smckusick int fflag, 11148009Smckusick struct ucred *cred, 11248009Smckusick struct proc *p)); 11348009Smckusick int spec_select __P(( 11448009Smckusick struct vnode *vp, 11548009Smckusick int which, 11648009Smckusick int fflags, 11748009Smckusick struct ucred *cred, 11848009Smckusick struct proc *p)); 11948009Smckusick #define spec_mmap ((int (*) __P(( \ 12048009Smckusick struct vnode *vp, \ 12148009Smckusick int fflags, \ 12248009Smckusick struct ucred *cred, \ 12348009Smckusick struct proc *p))) spec_badop) 12448009Smckusick #define spec_fsync ((int (*) __P(( \ 12548009Smckusick struct vnode *vp, \ 12648009Smckusick int fflags, \ 12748009Smckusick struct ucred *cred, \ 12848009Smckusick int waitfor, \ 12948009Smckusick struct proc *p))) nullop) 13048009Smckusick #define spec_seek ((int (*) __P(( \ 13148009Smckusick struct vnode *vp, \ 13248009Smckusick off_t oldoff, \ 13348009Smckusick off_t newoff, \ 13448009Smckusick struct ucred *cred))) spec_badop) 13548009Smckusick #define spec_remove ((int (*) __P(( \ 13648009Smckusick struct nameidata *ndp, \ 13748009Smckusick struct proc *p))) spec_badop) 13848009Smckusick #define spec_link ((int (*) __P(( \ 13948009Smckusick struct vnode *vp, \ 14048009Smckusick struct nameidata *ndp, \ 14148009Smckusick struct proc *p))) spec_badop) 14248009Smckusick #define spec_rename ((int (*) __P(( \ 14348009Smckusick struct nameidata *fndp, \ 14448009Smckusick struct nameidata *tdnp, \ 14548009Smckusick struct proc *p))) spec_badop) 14648009Smckusick #define spec_mkdir ((int (*) __P(( \ 14748009Smckusick struct nameidata *ndp, \ 14848009Smckusick struct vattr *vap, \ 14948009Smckusick struct proc *p))) spec_badop) 15048009Smckusick #define spec_rmdir ((int (*) __P(( \ 15148009Smckusick struct nameidata *ndp, \ 15248009Smckusick struct proc *p))) spec_badop) 15348009Smckusick #define spec_symlink ((int (*) __P(( \ 15448009Smckusick struct nameidata *ndp, \ 15548009Smckusick struct vattr *vap, \ 15648009Smckusick char *target, \ 15748009Smckusick struct proc *p))) spec_badop) 15848009Smckusick #define spec_readdir ((int (*) __P(( \ 15948009Smckusick struct vnode *vp, \ 16048009Smckusick struct uio *uio, \ 16148009Smckusick struct ucred *cred, \ 16248009Smckusick int *eofflagp))) spec_badop) 16348009Smckusick #define spec_readlink ((int (*) __P(( \ 16448009Smckusick struct vnode *vp, \ 16548009Smckusick struct uio *uio, \ 16648009Smckusick struct ucred *cred))) spec_badop) 16748009Smckusick #define spec_abortop ((int (*) __P(( \ 16848009Smckusick struct nameidata *ndp))) spec_badop) 16948009Smckusick #define spec_inactive ((int (*) __P(( \ 17048009Smckusick struct vnode *vp, \ 17148009Smckusick struct proc *p))) nullop) 17248009Smckusick #define spec_reclaim ((int (*) __P(( \ 17348009Smckusick struct vnode *vp))) nullop) 17448009Smckusick int spec_lock __P(( 17548009Smckusick struct vnode *vp)); 17648009Smckusick int spec_unlock __P(( 17748009Smckusick struct vnode *vp)); 17848009Smckusick int spec_bmap __P(( 17948009Smckusick struct vnode *vp, 18048009Smckusick daddr_t bn, 18148009Smckusick struct vnode **vpp, 18248009Smckusick daddr_t *bnp)); 18348009Smckusick int spec_strategy __P(( 18448009Smckusick struct buf *bp)); 18548009Smckusick int spec_print __P(( 18648009Smckusick struct vnode *vp)); 18748009Smckusick #define spec_islocked ((int (*) __P(( \ 18848009Smckusick struct vnode *vp))) nullop) 18948009Smckusick int spec_advlock __P(( 19048009Smckusick struct vnode *vp, 19148009Smckusick caddr_t id, 19248009Smckusick int op, 19348009Smckusick struct flock *fl, 19448009Smckusick int flags)); 195*51555Smckusick #define spec_blkatoff ((int (*) __P(( \ 196*51555Smckusick struct vnode *vp, \ 197*51555Smckusick off_t offset, \ 198*51555Smckusick char **res, \ 199*51555Smckusick struct buf **bpp))) spec_badop) 200*51555Smckusick #define spec_vget ((int (*) __P(( \ 201*51555Smckusick struct mount *mp, \ 202*51555Smckusick ino_t ino, \ 203*51555Smckusick struct vnode **vpp))) spec_badop) 204*51555Smckusick #define spec_valloc ((int (*) __P(( \ 205*51555Smckusick struct vnode *pvp, \ 206*51555Smckusick int mode, \ 207*51555Smckusick struct ucred *cred, \ 208*51555Smckusick struct vnode **vpp))) spec_badop) 209*51555Smckusick #define spec_vfree ((void (*) __P(( \ 210*51555Smckusick struct vnode *pvp, \ 211*51555Smckusick ino_t ino, \ 212*51555Smckusick int mode))) spec_badop) 213*51555Smckusick #define spec_truncate ((int (*) __P(( \ 214*51555Smckusick struct vnode *vp, \ 215*51555Smckusick u_long length, \ 216*51555Smckusick int flags))) nullop) 217*51555Smckusick #define spec_update ((int (*) __P(( \ 218*51555Smckusick struct vnode *vp, \ 219*51555Smckusick struct timeval *ta, \ 220*51555Smckusick struct timeval *tm, \ 221*51555Smckusick int waitfor))) nullop) 222*51555Smckusick #define spec_bwrite ((int (*) __P(( \ 223*51555Smckusick struct buf *bp))) nullop) 224