📄 nfs.h
字号:
/* Flag values for r_flags */#define R_TIMING 0x01 /* timing request (in mntp) */#define R_SENT 0x02 /* request has been sent */#define R_SOFTTERM 0x04 /* soft mnt, too many retries */#define R_INTR 0x08 /* intr mnt, signal pending */#define R_SOCKERR 0x10 /* Fatal error on socket */#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */#define R_MUSTRESEND 0x40 /* Must resend request */#define R_GETONEREP 0x80 /* Probe for one reply only *//* * A list of nfssvc_sock structures is maintained with all the sockets * that require service by the nfsd. * The nfsuid structs hang off of the nfssvc_sock structs in both lru * and uid hash lists. */#ifndef NFS_UIDHASHSIZ#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */#endif#define NUIDHASH(sock, uid) \ (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])#ifndef NFS_WDELAYHASHSIZ#define NFS_WDELAYHASHSIZ 16 /* and with this */#endif#define NWDELAYHASH(sock, f) \ (&(sock)->ns_wdelayhashtbl[(*((u_long *)(f))) % NFS_WDELAYHASHSIZ])#ifndef NFS_MUIDHASHSIZ#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */#endif#define NMUIDHASH(nmp, uid) \ (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])#define NFSNOHASH(fhsum) \ (&nfsnodehashtbl[(fhsum) & nfsnodehash])/* * Network address hash list element */union nethostaddr { u_long had_inetaddr; struct mbuf *had_nam;};struct nfsuid { TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */ LIST_ENTRY(nfsuid) nu_hash; /* Hash list */ int nu_flag; /* Flags */ union nethostaddr nu_haddr; /* Host addr. for dgram sockets */ struct ucred nu_cr; /* Cred uid mapped to */ int nu_expire; /* Expiry time (sec) */ struct timeval nu_timestamp; /* Kerb. timestamp */ u_long nu_nickname; /* Nickname on server */ NFSKERBKEY_T nu_key; /* and session key */};#define nu_inetaddr nu_haddr.had_inetaddr#define nu_nam nu_haddr.had_nam/* Bits for nu_flag */#define NU_INETADDR 0x1#define NU_NAM 0x2#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)struct nfssvc_sock { TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */ TAILQ_HEAD(, nfsuid) ns_uidlruhead; struct file *ns_fp; struct socket *ns_so; struct mbuf *ns_nam; struct mbuf *ns_raw; struct mbuf *ns_rawend; struct mbuf *ns_rec; struct mbuf *ns_recend; struct mbuf *ns_frag; int ns_flag; int ns_solock; int ns_cc; int ns_reclen; int ns_numuids; u_long ns_sref; LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */ LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ]; LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];};/* Bits for "ns_flag" */#define SLP_VALID 0x01#define SLP_DOREC 0x02#define SLP_NEEDQ 0x04#define SLP_DISCONN 0x08#define SLP_GETSTREAM 0x10#define SLP_LASTFRAG 0x20#define SLP_ALLFLAGS 0xffextern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;extern int nfssvc_sockhead_flag;#define SLP_INIT 0x01#define SLP_WANTINIT 0x02/* * One of these structures is allocated for each nfsd. */struct nfsd { TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */ int nfsd_flag; /* NFSD_ flags */ struct nfssvc_sock *nfsd_slp; /* Current socket */ int nfsd_authlen; /* Authenticator len */ u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */ int nfsd_verflen; /* and the Verifier */ u_char nfsd_verfstr[RPCVERF_MAXSIZ]; struct proc *nfsd_procp; /* Proc ptr */ struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */};/* Bits for "nfsd_flag" */#define NFSD_WAITING 0x01#define NFSD_REQINPROG 0x02#define NFSD_NEEDAUTH 0x04#define NFSD_AUTHFAIL 0x08/* * This structure is used by the server for describing each request. * Some fields are used only when write request gathering is performed. */struct nfsrv_descript { u_quad_t nd_time; /* Write deadline (usec) */ off_t nd_off; /* Start byte offset */ off_t nd_eoff; /* and end byte offset */ LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */ LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */ LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */ struct mbuf *nd_mrep; /* Request mbuf list */ struct mbuf *nd_md; /* Current dissect mbuf */ struct mbuf *nd_mreq; /* Reply mbuf list */ struct mbuf *nd_nam; /* and socket addr */ struct mbuf *nd_nam2; /* return socket addr */ caddr_t nd_dpos; /* Current dissect pos */ int nd_procnum; /* RPC # */ int nd_stable; /* storage type */ int nd_flag; /* nd_flag */ int nd_len; /* Length of this write */ int nd_repstat; /* Reply status */ u_long nd_retxid; /* Reply xid */ u_long nd_duration; /* Lease duration */ struct timeval nd_starttime; /* Time RPC initiated */ fhandle_t nd_fh; /* File handle */ struct ucred nd_cr; /* Credentials */};/* Bits for "nd_flag" */#define ND_READ LEASE_READ#define ND_WRITE LEASE_WRITE#define ND_CHECK 0x04#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)#define ND_NFSV3 0x08#define ND_NQNFS 0x10#define ND_KERBNICK 0x20#define ND_KERBFULL 0x40#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;extern int nfsd_head_flag;#define NFSD_CHECKSLP 0x01/* * These macros compare nfsrv_descript structures. */#define NFSW_CONTIG(o, n) \ ((o)->nd_eoff >= (n)->nd_off && \ !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))#define NFSW_SAMECRED(o, n) \ (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \ !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \ sizeof (struct ucred)))int nfs_reply __P((struct nfsreq *));int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));int nfs_send __P((struct socket *,struct mbuf *,struct mbuf *,struct nfsreq *));int nfs_rephead __P((int,struct nfsrv_descript *,struct nfssvc_sock *,int,int,u_quad_t *,struct mbuf **,struct mbuf **,caddr_t *));int nfs_sndlock __P((int *,struct nfsreq *));void nfs_sndunlock __P((int *flagp));int nfs_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));int nfs_vinvalbuf __P((struct vnode *,int,struct ucred *,struct proc *,int));int nfs_readrpc __P((struct vnode *,struct uio *,struct ucred *));int nfs_writerpc __P((struct vnode *,struct uio *,struct ucred *,int *,int *));int nfs_readdirrpc __P((register struct vnode *,struct uio *,struct ucred *));int nfs_asyncio __P((struct buf *,struct ucred *));int nfs_doio __P((struct buf *,struct ucred *,struct proc *));int nfs_readlinkrpc __P((struct vnode *,struct uio *,struct ucred *));int nfs_sigintr __P((struct nfsmount *,struct nfsreq *r,struct proc *));int nfs_readdirplusrpc __P((struct vnode *,register struct uio *,struct ucred *));int nfsm_disct __P((struct mbuf **,caddr_t *,int,int,caddr_t *));void nfsm_srvfattr __P((struct nfsrv_descript *,struct vattr *,struct nfs_fattr *));void nfsm_srvwcc __P((struct nfsrv_descript *,int,struct vattr *,int,struct vattr *,struct mbuf **,char **));void nfsm_srvpostopattr __P((struct nfsrv_descript *,int,struct vattr *,struct mbuf **,char **));int netaddr_match __P((int,union nethostaddr *,struct mbuf *));int nfs_request __P((struct vnode *,struct mbuf *,int,struct proc *,struct ucred *,struct mbuf **,struct mbuf **,caddr_t *));int nfs_loadattrcache __P((struct vnode **,struct mbuf **,caddr_t *,struct vattr *));int nfs_namei __P((struct nameidata *,fhandle_t *,int,struct nfssvc_sock *,struct mbuf *,struct mbuf **,caddr_t *,struct vnode **,struct proc *,int));void nfsm_adj __P((struct mbuf *,int,int));int nfsm_mbuftouio __P((struct mbuf **,struct uio *,int,caddr_t *));void nfsrv_initcache __P((void));int nfs_getauth __P((struct nfsmount *,struct nfsreq *,struct ucred *,char **,int *,char *,int *,NFSKERBKEY_T));int nfs_getnickauth __P((struct nfsmount *,struct ucred *,char **,int *,char *,int));int nfs_savenickauth __P((struct nfsmount *,struct ucred *,int,NFSKERBKEY_T,struct mbuf **,char **,struct mbuf *));int nfs_adv __P((struct mbuf **,caddr_t *,int,int));void nfs_nhinit __P((void));void nfs_timer __P((void*));u_long nfs_hash __P((nfsfh_t *,int));void nfsrv_slpderef __P((struct nfssvc_sock *slp));int nfsrv_dorec __P((struct nfssvc_sock *,struct nfsd *,struct nfsrv_descript **));void nfsrv_cleancache __P((void));int nfsrv_getcache __P((struct nfsrv_descript *,struct nfssvc_sock *,struct mbuf **));int nfs_init __P((void));void nfsrv_updatecache __P((struct nfsrv_descript *,int,struct mbuf *));int nfs_connect __P((struct nfsmount *,struct nfsreq *));void nfs_disconnect __P((struct nfsmount *nmp));int nfs_getattrcache __P((struct vnode *,struct vattr *));int nfsm_strtmbuf __P((struct mbuf **,char **,char *,long));int nfs_bioread __P((struct vnode *,struct uio *,int,struct ucred *, int getpages));int nfsm_uiotombuf __P((struct uio *,struct mbuf **,int,caddr_t *));void nfsrv_init __P((int));void nfs_clearcommit __P((struct mount *));int nfsrv_errmap __P((struct nfsrv_descript *, int));void nfsrv_rcv __P((struct socket *so, caddr_t arg, int waitflag));void nfsrvw_sort __P((gid_t [],int));void nfsrv_setcred __P((struct ucred *,struct ucred *));int nfs_writebp __P((struct buf *,int));int nfsrv_object_create __P(( struct vnode * ));void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *, struct proc *, struct mbuf **));int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, struct proc *p));int nfsrv3_access __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_fhtovp __P((fhandle_t *,int,struct vnode **, struct ucred *,struct nfssvc_sock *,struct mbuf *, int *,int));int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_pathconf __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_readdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_readlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_setattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_statfs __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_symlink __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct proc *procp, struct mbuf **mrq));#ifdef NFS_DEBUGextern int nfs_debug;#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */#define NFS_DEBUG_WG 2 /* server write gathering */#define NFS_DEBUG_RC 4 /* server request caching */#define NFS_DPF(cat, args) \ do { \ if (nfs_debug & NFS_DEBUG_##cat) printf args; \ } while (0)#else#define NFS_DPF(cat, args)#endif#endif /* KERNEL */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -