/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Estimate rto for an nfs rpc sent via. an unreliable datagram.
* Use the mean and mean deviation of rtt for the appropriate type of rpc
* for the frequent rpcs and a default for the others.
* The justification for doing "other" this way is that these rpcs
* happen so infrequently that timer est. would probably be stale.
* Also, since many of these rpcs are
* non-idempotent, a conservative timeout is desired.
* getattr, lookup - A+2D
* read, write - A+4D
* other - nm_timeo
*/
#define NFS_RTO(n, t) \
((t) == 0 ? (n)->nm_timeo : \
((t) < 3 ? \
(((((n)->nm_srtt[t-1] + 3) >> 2) + (n)->nm_sdrtt[t-1] + 1) >> 1) : \
((((n)->nm_srtt[t-1] + 7) >> 3) + (n)->nm_sdrtt[t-1] + 1)))
#define NFS_SRTT(r) (r)->r_nmp->nm_srtt[nfs_proct[(r)->r_procnum] - 1]
#define NFS_SDRTT(r) (r)->r_nmp->nm_sdrtt[nfs_proct[(r)->r_procnum] - 1]
extern int nfsrtton;
extern struct nfsrtt nfsrtt;
extern const int nfs_proct[];
/* nfs_syscalls.c */
struct sys_getfh_args;
struct sys_nfssvc_args;
int sys_getfh(struct lwp *, const struct sys_getfh_args *, register_t *);
int sys_nfssvc(struct lwp *, const struct sys_nfssvc_args *, register_t *);
int nfssvc_addsock(struct file *, struct mbuf *);
void nfsrv_zapsock(struct nfssvc_sock *);
void nfsrv_slpderef(struct nfssvc_sock *);
void nfsrv_init(int);
void nfsrv_fini(void);
void nfs_iodinit(void);
void nfs_iodfini(void);
int nfs_iodbusy(struct nfsmount *);
int nfs_set_niothreads(int);
int nfs_getauth(struct nfsmount *, struct nfsreq *, kauth_cred_t, char **,
int *, char *, int *, NFSKERBKEY_T);
int nfs_getnickauth(struct nfsmount *, kauth_cred_t, char **, int *, char *,
int);
int nfs_savenickauth(struct nfsmount *, kauth_cred_t, int, NFSKERBKEY_T,
struct mbuf **, char **, struct mbuf *);
/*
* Backend copyin/out functions for nfssvc(2), so that netbsd32 can
* easily access NFS. Each operation either must perform a copyin or
* copyout of the right data for the emulation. exp_in() takes a count
* of the number of export_args to copyin, and order arguments for
* func(dst, src).
*/
struct nfssvc_copy_ops {
int (*addsock_in)(struct nfsd_args *, const void *);
int (*setexports_in)(struct mountd_exports_list *, const void *);
int (*nsd_in)(struct nfsd_srvargs *, const void *);
int (*nsd_out)(void *, const struct nfsd_srvargs *);
int (*exp_in)(struct export_args *, const void *, size_t);
};
int do_nfssvc(struct nfssvc_copy_ops *, struct lwp *, int, void *, register_t *);
/* nfs_export.c */
extern struct nfs_public nfs_pub;
int mountd_set_exports_list(const struct mountd_exports_list *, struct lwp *,
struct mount *, int);
int netexport_check(const fsid_t *, struct mbuf *, struct mount **, int *,
kauth_cred_t *);
void netexport_rdlock(void);
void netexport_rdunlock(void);
void netexport_init(void);
void netexport_fini(void);
bool netexport_hasexports(void);