#ifndef _NFSSERVER_NFS_H_
#define _NFSSERVER_NFS_H_
#ifdef _KERNEL
#include "opt_nfs.h"
#endif
#include <nfs/nfssvc.h>
#define NFS_TICKINTVL 10
#define NFS_HZ (hz / nfs_ticks)
#define NFS_TIMEO (1 * NFS_HZ)
#define NFS_MINTIMEO (1 * NFS_HZ)
#define NFS_MAXTIMEO (60 * NFS_HZ)
#define NFS_MINIDEMTIMEO (5 * NFS_HZ)
#define NFS_MAXUIDHASH 64
#ifndef NFS_GATHERDELAY
#define NFS_GATHERDELAY 10
#endif
#ifdef _KERNEL
#define DIRBLKSIZ 512
#endif
#define NFS_SRVMAXDATA(n) \
(((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
#define B_INVAFTERWRITE B_NOCACHE
#ifndef IO_METASYNC
#define IO_METASYNC 0
#endif
#define NFSRV_SNDLOCK 0x01000000
#define NFSRV_WANTSND 0x02000000
struct nfsd_addsock_args {
int sock;
caddr_t name;
int namelen;
};
struct nfsd_nfsd_args {
const char *principal;
int minthreads;
int maxthreads;
};
#ifdef NFS_NPROCS
#include <nfsserver/nfsrvstats.h>
#endif
#define NFS_NFSRVSTATS 1
#define NFS_NFSPRIVPORT 2
#ifdef _KERNEL
extern struct mtx nfsd_mtx;
#define NFSD_LOCK_ASSERT() mtx_assert(&nfsd_mtx, MA_OWNED)
#define NFSD_UNLOCK_ASSERT() mtx_assert(&nfsd_mtx, MA_NOTOWNED)
#define NFSD_LOCK_DONTCARE()
#define NFSD_LOCK() mtx_lock(&nfsd_mtx)
#define NFSD_UNLOCK() mtx_unlock(&nfsd_mtx)
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_NFSRVDESC);
MALLOC_DECLARE(M_NFSD);
#endif
struct nfssvc_sock;
struct nfsrv_descript;
struct uio;
struct vattr;
struct nameidata;
extern struct callout nfsrv_callout;
extern struct nfsrvstats nfsrvstats;
extern int nfsrv_ticks;
extern int nfsrvw_procrastinate;
extern int nfsrvw_procrastinate_v3;
extern int nfsrv_numnfsd;
extern u_int32_t nfsrv_nfs_false, nfsrv_nfs_true, nfsrv_nfs_xdrneg1,
nfsrv_nfs_prog;
extern u_int32_t nfsrv_rpc_reply, nfsrv_rpc_msgdenied, nfsrv_rpc_mismatch,
nfsrv_rpc_vers;
extern u_int32_t nfsrv_rpc_auth_unix, nfsrv_rpc_msgaccepted, nfsrv_rpc_call,
nfsrv_rpc_autherr;
extern const int nfsrvv2_procid[NFS_NPROCS];
extern const int nfsrv_nfsv3_procid[NFS_NPROCS];
extern int32_t (*nfsrv3_procs[NFS_NPROCS])(struct nfsrv_descript *nd,
struct nfssvc_sock *slp, struct mbuf **mreqp);
#ifndef NFS_WDELAYHASHSIZ
#define NFS_WDELAYHASHSIZ 16
#endif
#define NWDELAYHASH(sock, f) \
(&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
struct nfsrv_descript {
struct mbuf *nd_mrep;
struct mbuf *nd_md;
struct mbuf *nd_mreq;
struct sockaddr *nd_nam;
struct sockaddr *nd_nam2;
caddr_t nd_dpos;
u_int32_t nd_procnum;
int nd_stable;
int nd_flag;
int nd_repstat;
fhandle_t nd_fh;
struct ucred *nd_cr;
int nd_credflavor;
};
#define ND_NFSV3 0x08
#define WEBNFS_ESC_CHAR '%'
#define WEBNFS_SPECCHAR_START 0x80
#define WEBNFS_NATIVE_CHAR 0x80
#define HEXTOC(c) \
((c) >= 'a' ? ((c) - ('a' - 10)) : \
((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
#define HEXSTRTOI(p) \
((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
#ifdef NFS_DEBUG
extern int nfs_debug;
#define NFS_DEBUG_ASYNCIO 1
#define NFS_DEBUG_WG 2
#define NFS_DEBUG_RC 4
#define NFS_DPF(cat, args) \
do { \
if (nfs_debug & NFS_DEBUG_##cat) printf args; \
} while (0)
#else
#define NFS_DPF(cat, args)
#endif
#define NFSRV_FLAG_BUSY 0x01
struct mbuf *nfs_rephead(int, struct nfsrv_descript *, int, struct mbuf **,
caddr_t *);
void nfsm_srvfattr(struct nfsrv_descript *, struct vattr *,
struct nfs_fattr *);
void nfsm_srvwcc(struct nfsrv_descript *, int, struct vattr *, int,
struct vattr *, struct mbuf **, char **);
void nfsm_srvpostopattr(struct nfsrv_descript *, int, struct vattr *,
struct mbuf **, char **);
int nfs_namei(struct nameidata *, struct nfsrv_descript *, fhandle_t *,
int, struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
caddr_t *, struct vnode **, int, struct vattr *, int *, int);
void nfsm_adj(struct mbuf *, int, int);
int nfsm_mbuftouio(struct mbuf **, struct uio *, int, caddr_t *);
void nfsrv_init(int);
int nfsrv_errmap(struct nfsrv_descript *, int);
void nfsrvw_sort(gid_t *, int);
int nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_fhtovp(fhandle_t *, int, struct vnode **,
struct nfsrv_descript *, struct nfssvc_sock *, struct sockaddr *,
int *);
int nfsrv_setpublicfs(struct mount *, struct netexport *,
struct export_args *);
int nfs_ispublicfh(fhandle_t *);
int nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
#ifdef _SYS_SYSPROTO_H_
int nfssvc_nfsserver(struct thread *, struct nfssvc_args *);
#endif
#endif
#endif