NFS update; fix STM32 enabling of CAN2 clock
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4494 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
fca16fa374
commit
b761211fff
@ -42,7 +42,7 @@ CSRCS +=
|
|||||||
# Files required for NFS RPC
|
# Files required for NFS RPC
|
||||||
|
|
||||||
ASRCS +=
|
ASRCS +=
|
||||||
CSRCS += rpc_subr.c
|
CSRCS += rpc_clnt.c
|
||||||
|
|
||||||
# Argument for dependency checking
|
# Argument for dependency checking
|
||||||
|
|
||||||
|
360
fs/nfs/nfs.h
Normal file
360
fs/nfs/nfs.h
Normal file
@ -0,0 +1,360 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1989, 1993, 1995
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Rick Macklem at The University of Guelph.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||||
|
*
|
||||||
|
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _NFS_NFS_H_
|
||||||
|
#define _NFS_NFS_H_
|
||||||
|
|
||||||
|
#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
|
||||||
|
#define NFS_HZ (CLOCKS_PER_SEC / nfs_ticks) /* Ticks/sec */
|
||||||
|
#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
|
||||||
|
#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
|
||||||
|
#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
|
||||||
|
#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops */
|
||||||
|
#define NFS_TIMEOUTMUL 2 /* Timeout/Delay multiplier */
|
||||||
|
#define NFS_MAXREXMIT 100 /* Stop counting after this many */
|
||||||
|
#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
|
||||||
|
#define NFS_MAXGRPS 16 /* Max. size of groups list */
|
||||||
|
#define NFS_MINATTRTIMO 5 /* Attribute cache timeout in sec */
|
||||||
|
#define NFS_MAXATTRTIMO 60
|
||||||
|
#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
|
||||||
|
#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
|
||||||
|
#define NFS_READDIRSIZE 8192 /* Def. readdir size */
|
||||||
|
#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
|
||||||
|
#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
|
||||||
|
#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runable */
|
||||||
|
|
||||||
|
/* Ideally, NFS_DIRBLKSIZ should be bigger, but I've seen servers with
|
||||||
|
* broken NFS/ethernet drivers that won't work with anything bigger (Linux..)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFS_DIRBLKSIZ 1024 /* Must be a multiple of DIRBLKSIZ */
|
||||||
|
#define NFS_READDIRBLKSIZ 512 /* Size of read dir blocks. XXX */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Oddballs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFS_CMPFH(n, f, s) \
|
||||||
|
((n)->n_fhsize == (s) && !bcmp((void *)(n)->n_fhp, (void *)(f), (s)))
|
||||||
|
#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
|
||||||
|
#define NFS_SRVMAXDATA(n) \
|
||||||
|
(((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
|
||||||
|
NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sys/malloc.h needs M_NFSDIROFF, M_NFSRVDESC and M_NFSBIGFH added.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef M_NFSRVDESC
|
||||||
|
# define M_NFSRVDESC M_TEMP
|
||||||
|
#endif
|
||||||
|
#ifndef M_NFSDIROFF
|
||||||
|
# define M_NFSDIROFF M_TEMP
|
||||||
|
#endif
|
||||||
|
#ifndef M_NFSBIGFH
|
||||||
|
# define M_NFSBIGFH M_TEMP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The B_INVAFTERWRITE flag should be set to whatever is required by the
|
||||||
|
* buffer cache code to say "Invalidate the block after it is written back".
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define B_INVAFTERWRITE B_INVAL
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structures for the nfssvc(2) syscall.
|
||||||
|
* Not that anyone besides nfsd(8) should ever use it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsd_args
|
||||||
|
{
|
||||||
|
int sock; /* Socket to serve */
|
||||||
|
void *name; /* Client addr for connection based sockets */
|
||||||
|
int namelen; /* Length of name */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nfsd_srvargs
|
||||||
|
{
|
||||||
|
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
|
||||||
|
uid_t nsd_uid; /* Effective uid mapped to cred */
|
||||||
|
uint32_t nsd_haddr; /* IP address of client */
|
||||||
|
int nsd_authlen; /* Length of auth string (ret) */
|
||||||
|
unsigned char *nsd_authstr; /* Auth string (ret) */
|
||||||
|
int nsd_verflen; /* and the verifier */
|
||||||
|
unsigned char *nsd_verfstr;
|
||||||
|
struct timeval nsd_timestamp; /* timestamp from verifier */
|
||||||
|
uint32_t nsd_ttl; /* credential ttl (sec) */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stats structure
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsstats
|
||||||
|
{
|
||||||
|
uint64_t attrcache_hits;
|
||||||
|
uint64_t attrcache_misses;
|
||||||
|
uint64_t lookupcache_hits;
|
||||||
|
uint64_t lookupcache_misses;
|
||||||
|
uint64_t direofcache_hits;
|
||||||
|
uint64_t direofcache_misses;
|
||||||
|
uint64_t biocache_reads;
|
||||||
|
uint64_t read_bios;
|
||||||
|
uint64_t read_physios;
|
||||||
|
uint64_t biocache_writes;
|
||||||
|
uint64_t write_bios;
|
||||||
|
uint64_t write_physios;
|
||||||
|
uint64_t biocache_readlinks;
|
||||||
|
uint64_t readlink_bios;
|
||||||
|
uint64_t biocache_readdirs;
|
||||||
|
uint64_t readdir_bios;
|
||||||
|
uint64_t rpccnt[NFS_NPROCS];
|
||||||
|
uint64_t rpcretries;
|
||||||
|
uint64_t srvrpccnt[NFS_NPROCS];
|
||||||
|
uint64_t srvrpc_errs;
|
||||||
|
uint64_t srv_errs;
|
||||||
|
uint64_t rpcrequests;
|
||||||
|
uint64_t rpctimeouts;
|
||||||
|
uint64_t rpcunexpected;
|
||||||
|
uint64_t rpcinvalid;
|
||||||
|
uint64_t srvcache_inproghits;
|
||||||
|
uint64_t srvcache_idemdonehits;
|
||||||
|
uint64_t srvcache_nonidemdonehits;
|
||||||
|
uint64_t srvcache_misses;
|
||||||
|
uint64_t forcedsync;
|
||||||
|
uint64_t srvnqnfs_leases;
|
||||||
|
uint64_t srvnqnfs_maxleases;
|
||||||
|
uint64_t srvnqnfs_getleases;
|
||||||
|
uint64_t srvvop_writes;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flags for nfssvc() system call.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFSSVC_BIOD 0x002
|
||||||
|
#define NFSSVC_NFSD 0x004
|
||||||
|
#define NFSSVC_ADDSOCK 0x008
|
||||||
|
#define NFSSVC_AUTHIN 0x010
|
||||||
|
#define NFSSVC_GOTAUTH 0x040
|
||||||
|
#define NFSSVC_AUTHINFAIL 0x080
|
||||||
|
#define NFSSVC_MNTD 0x100
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fs.nfs sysctl(3) identifiers
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
|
||||||
|
#define NFS_NIOTHREADS 2 /* number of i/o threads */
|
||||||
|
#define NFS_MAXID 3
|
||||||
|
|
||||||
|
#define FS_NFS_NAMES { \
|
||||||
|
{ 0, 0 }, \
|
||||||
|
{ "nfsstats", CTLTYPE_STRUCT }, \
|
||||||
|
{ "iothreads", CTLTYPE_INT } \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
|
||||||
|
* What should be in this set is open to debate, but I believe that since
|
||||||
|
* I/O system calls on ufs are never interrupted by signals the set should
|
||||||
|
* be minimal. My reasoning is that many current programs that use signals
|
||||||
|
* such as SIGALRM will not expect file I/O system calls to be interrupted
|
||||||
|
* by them and break.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
extern int nfs_niothreads;
|
||||||
|
|
||||||
|
struct uio;
|
||||||
|
struct buf;
|
||||||
|
struct vattr;
|
||||||
|
struct nameidata; /* XXX */
|
||||||
|
|
||||||
|
#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
|
||||||
|
sigmask(SIGHUP)|sigmask(SIGQUIT))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Socket errors ignored for connectionless sockets??
|
||||||
|
* For now, ignore them all
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFSIGNORE_SOERROR(s, e) \
|
||||||
|
((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
|
||||||
|
((s) & PR_CONNREQUIRED) == 0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Nfs outstanding request list element
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsreq
|
||||||
|
{
|
||||||
|
dq_entry_t r_chain;
|
||||||
|
void *r_dpos;
|
||||||
|
struct nfsmount *r_nmp;
|
||||||
|
uint32_t r_xid;
|
||||||
|
int r_flags; /* flags on request, see below */
|
||||||
|
int r_rexmit; /* current retrans count */
|
||||||
|
int r_timer; /* tick counter on reply */
|
||||||
|
int r_procnum; /* NFS procedure number */
|
||||||
|
int r_rtt; /* RTT for rpc */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On fast networks, the estimator will try to reduce the
|
||||||
|
* timeout lower than the latency of the server's disks,
|
||||||
|
* which results in too many timeouts, so cap the lower
|
||||||
|
* bound.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFS_MINRTO (NFS_HZ >> 2)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the RTO from increasing to unreasonably large values
|
||||||
|
* when a server is not responding.
|
||||||
|
*/
|
||||||
|
#define NFS_MAXRTO (20 * NFS_HZ)
|
||||||
|
|
||||||
|
enum nfs_rto_timers
|
||||||
|
{
|
||||||
|
NFS_DEFAULT_TIMER,
|
||||||
|
NFS_GETATTR_TIMER,
|
||||||
|
NFS_LOOKUP_TIMER,
|
||||||
|
NFS_READ_TIMER,
|
||||||
|
NFS_WRITE_TIMER,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NFS_MAX_TIMER (NFS_WRITE_TIMER)
|
||||||
|
#define NFS_INITRTT (NFS_HZ << 3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Network address hash list element
|
||||||
|
*/
|
||||||
|
|
||||||
|
union nethostaddr
|
||||||
|
{
|
||||||
|
u_int32_t had_inetaddr;
|
||||||
|
struct mbuf *had_nam;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nfssvc_sock
|
||||||
|
{
|
||||||
|
TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
|
||||||
|
struct file *ns_fp; /* fp from the... */
|
||||||
|
struct socket *ns_so; /* ...socket this struct wraps */
|
||||||
|
struct mbuf *ns_nam; /* MT_SONAME of client */
|
||||||
|
struct mbuf *ns_raw; /* head of unpeeked mbufs */
|
||||||
|
struct mbuf *ns_rawend; /* tail of unpeeked mbufs */
|
||||||
|
struct mbuf *ns_rec; /* queued RPC records */
|
||||||
|
struct mbuf *ns_recend; /* last queued RPC record */
|
||||||
|
struct mbuf *ns_frag; /* end of record fragment */
|
||||||
|
int ns_flag; /* socket status flags */
|
||||||
|
int ns_solock; /* lock for connected socket */
|
||||||
|
int ns_cc; /* actual chars queued */
|
||||||
|
int ns_reclen; /* length of first queued record */
|
||||||
|
u_int32_t ns_sref; /* # of refs to this struct */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Bits for "ns_flag" */
|
||||||
|
|
||||||
|
#define SLP_VALID 0x01/* connection is usable */
|
||||||
|
#define SLP_DOREC 0x02/* receive operation required */
|
||||||
|
#define SLP_NEEDQ 0x04/* connection has data to queue from socket */
|
||||||
|
#define SLP_DISCONN 0x08/* connection is closed */
|
||||||
|
#define SLP_GETSTREAM 0x10/* extracting RPC from TCP connection */
|
||||||
|
#define SLP_LASTFRAG 0x20/* last fragment received on TCP connection */
|
||||||
|
#define SLP_ALLFLAGS 0xff/* convenience */
|
||||||
|
|
||||||
|
extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
|
||||||
|
extern int nfssvc_sockhead_flag;
|
||||||
|
|
||||||
|
#define SLP_INIT 0x01/* NFS data undergoing initialization */
|
||||||
|
#define SLP_WANTINIT 0x02/* thread waiting on NFS initialization */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 */
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsrv_descript
|
||||||
|
{
|
||||||
|
unsigned int nd_procnum; /* RPC # */
|
||||||
|
int nd_flag; /* nd_flag */
|
||||||
|
int nd_repstat; /* Reply status */
|
||||||
|
u_int32_t nd_retxid; /* Reply xid */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Bits for "nd_flag" */
|
||||||
|
|
||||||
|
#define ND_NFSV3 0x08
|
||||||
|
|
||||||
|
extern struct pool nfsreqpl;
|
||||||
|
extern struct pool nfs_node_pool;
|
||||||
|
extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
|
||||||
|
extern int nfsd_head_flag;
|
||||||
|
|
||||||
|
#define NFSD_CHECKSLP 0x01
|
||||||
|
|
||||||
|
#endif /* _KERNEL */
|
||||||
|
#endif /* _NFS_NFS_H */
|
454
fs/nfs/nfs_proto.h
Normal file
454
fs/nfs/nfs_proto.h
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1989, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Rick Macklem at The University of Guelph.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _NFS_NFSPROTO_H_
|
||||||
|
#define _NFS_NFSPROTO_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constants as defined in the Sun NFS Version 2 and 3 specs.
|
||||||
|
* "NFS: Network File System Protocol Specification" RFC1094
|
||||||
|
* and in the "NFS: Network File System Version 3 Protocol
|
||||||
|
* Specification"
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFS_PORT 2049
|
||||||
|
#define NFS_PROG 100003
|
||||||
|
#define NFS_VER2 2
|
||||||
|
#define NFS_VER3 3
|
||||||
|
#define NFS_VER4 4
|
||||||
|
#define NFS_V2MAXDATA 8192
|
||||||
|
#define NFS_MAXDGRAMDATA 32768
|
||||||
|
#define NFS_MAXDATA MAXBSIZE
|
||||||
|
#define NFS_MAXPATHLEN 1024
|
||||||
|
#define NFS_MAXNAMLEN 255
|
||||||
|
#define NFS_MAXPKTHDR 404
|
||||||
|
#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
|
||||||
|
#define NFS_MINPACKET 20
|
||||||
|
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
|
||||||
|
|
||||||
|
/* Stat numbers for rpc returns (version 2 and 3) */
|
||||||
|
|
||||||
|
#define NFS_OK 0
|
||||||
|
#define NFSERR_PERM 1
|
||||||
|
#define NFSERR_NOENT 2
|
||||||
|
#define NFSERR_IO 5
|
||||||
|
#define NFSERR_NXIO 6
|
||||||
|
#define NFSERR_ACCES 13
|
||||||
|
#define NFSERR_EXIST 17
|
||||||
|
#define NFSERR_XDEV 18 /* Version 3 only */
|
||||||
|
#define NFSERR_NODEV 19
|
||||||
|
#define NFSERR_NOTDIR 20
|
||||||
|
#define NFSERR_ISDIR 21
|
||||||
|
#define NFSERR_INVAL 22 /* Version 3 only */
|
||||||
|
#define NFSERR_FBIG 27
|
||||||
|
#define NFSERR_NOSPC 28
|
||||||
|
#define NFSERR_ROFS 30
|
||||||
|
#define NFSERR_MLINK 31 /* Version 3 only */
|
||||||
|
#define NFSERR_NAMETOL 63
|
||||||
|
#define NFSERR_NOTEMPTY 66
|
||||||
|
#define NFSERR_DQUOT 69
|
||||||
|
#define NFSERR_STALE 70
|
||||||
|
#define NFSERR_REMOTE 71 /* Version 3 only */
|
||||||
|
#define NFSERR_WFLUSH 99 /* Version 2 only */
|
||||||
|
#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
|
||||||
|
#define NFSERR_NOT_SYNC 10002
|
||||||
|
#define NFSERR_BAD_COOKIE 10003
|
||||||
|
#define NFSERR_NOTSUPP 10004
|
||||||
|
#define NFSERR_TOOSMALL 10005
|
||||||
|
#define NFSERR_SERVERFAULT 10006
|
||||||
|
#define NFSERR_BADTYPE 10007
|
||||||
|
#define NFSERR_JUKEBOX 10008
|
||||||
|
#define NFSERR_TRYLATER NFSERR_JUKEBOX
|
||||||
|
#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
|
||||||
|
|
||||||
|
#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
|
||||||
|
#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error
|
||||||
|
*/
|
||||||
|
#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
|
||||||
|
|
||||||
|
/* Sizes in bytes of various nfs rpc components */
|
||||||
|
|
||||||
|
#define NFSX_UNSIGNED 4
|
||||||
|
|
||||||
|
/* specific to NFS Version 2 */
|
||||||
|
|
||||||
|
#define NFSX_V2FH 32
|
||||||
|
#define NFSX_V2FATTR 68
|
||||||
|
#define NFSX_V2SATTR 32
|
||||||
|
#define NFSX_V2COOKIE 4
|
||||||
|
#define NFSX_V2STATFS 20
|
||||||
|
|
||||||
|
/* specific to NFS Version 3 */
|
||||||
|
|
||||||
|
#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
|
||||||
|
#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
|
||||||
|
#define NFSX_V3FATTR 84
|
||||||
|
#define NFSX_V3SATTR 60 /* max. all fields filled in */
|
||||||
|
#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
|
||||||
|
#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
|
||||||
|
#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
|
||||||
|
#define NFSX_V3COOKIEVERF 8
|
||||||
|
#define NFSX_V3WRITEVERF 8
|
||||||
|
#define NFSX_V3CREATEVERF 8
|
||||||
|
#define NFSX_V3STATFS 52
|
||||||
|
#define NFSX_V3FSINFO 48
|
||||||
|
#define NFSX_V3PATHCONF 24
|
||||||
|
|
||||||
|
/* variants for both versions */
|
||||||
|
#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
|
||||||
|
NFSX_V2FH)
|
||||||
|
#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
|
||||||
|
#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
|
||||||
|
#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
|
||||||
|
#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
|
||||||
|
#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
|
||||||
|
NFSX_V2FATTR)
|
||||||
|
#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
|
||||||
|
#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
|
||||||
|
#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
|
||||||
|
#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
|
||||||
|
#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
|
||||||
|
#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
|
||||||
|
(2 * NFSX_UNSIGNED))
|
||||||
|
#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
|
||||||
|
|
||||||
|
/* nfs rpc procedure numbers (before version mapping) */
|
||||||
|
|
||||||
|
#define NFSPROC_NULL 0
|
||||||
|
#define NFSPROC_GETATTR 1
|
||||||
|
#define NFSPROC_SETATTR 2
|
||||||
|
#define NFSPROC_LOOKUP 3
|
||||||
|
#define NFSPROC_ACCESS 4
|
||||||
|
#define NFSPROC_READLINK 5
|
||||||
|
#define NFSPROC_READ 6
|
||||||
|
#define NFSPROC_WRITE 7
|
||||||
|
#define NFSPROC_CREATE 8
|
||||||
|
#define NFSPROC_MKDIR 9
|
||||||
|
#define NFSPROC_SYMLINK 10
|
||||||
|
#define NFSPROC_MKNOD 11
|
||||||
|
#define NFSPROC_REMOVE 12
|
||||||
|
#define NFSPROC_RMDIR 13
|
||||||
|
#define NFSPROC_RENAME 14
|
||||||
|
#define NFSPROC_LINK 15
|
||||||
|
#define NFSPROC_READDIR 16
|
||||||
|
#define NFSPROC_READDIRPLUS 17
|
||||||
|
#define NFSPROC_FSSTAT 18
|
||||||
|
#define NFSPROC_FSINFO 19
|
||||||
|
#define NFSPROC_PATHCONF 20
|
||||||
|
#define NFSPROC_COMMIT 21
|
||||||
|
#define NFSPROC_NOOP 22
|
||||||
|
#define NFS_NPROCS 23
|
||||||
|
|
||||||
|
/* Actual Version 2 procedure numbers */
|
||||||
|
|
||||||
|
#define NFSV2PROC_NULL 0
|
||||||
|
#define NFSV2PROC_GETATTR 1
|
||||||
|
#define NFSV2PROC_SETATTR 2
|
||||||
|
#define NFSV2PROC_NOOP 3
|
||||||
|
#define NFSV2PROC_ROOT NFSV2PROC_NOOP/* Obsolete */
|
||||||
|
#define NFSV2PROC_LOOKUP 4
|
||||||
|
#define NFSV2PROC_READLINK 5
|
||||||
|
#define NFSV2PROC_READ 6
|
||||||
|
#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP/* Obsolete */
|
||||||
|
#define NFSV2PROC_WRITE 8
|
||||||
|
#define NFSV2PROC_CREATE 9
|
||||||
|
#define NFSV2PROC_REMOVE 10
|
||||||
|
#define NFSV2PROC_RENAME 11
|
||||||
|
#define NFSV2PROC_LINK 12
|
||||||
|
#define NFSV2PROC_SYMLINK 13
|
||||||
|
#define NFSV2PROC_MKDIR 14
|
||||||
|
#define NFSV2PROC_RMDIR 15
|
||||||
|
#define NFSV2PROC_READDIR 16
|
||||||
|
#define NFSV2PROC_STATFS 17
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constants used by the Version 3 protocol for various RPCs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NFSV3SATTRTIME_DONTCHANGE 0
|
||||||
|
#define NFSV3SATTRTIME_TOSERVER 1
|
||||||
|
#define NFSV3SATTRTIME_TOCLIENT 2
|
||||||
|
|
||||||
|
#define NFSV3ACCESS_READ 0x01
|
||||||
|
#define NFSV3ACCESS_LOOKUP 0x02
|
||||||
|
#define NFSV3ACCESS_MODIFY 0x04
|
||||||
|
#define NFSV3ACCESS_EXTEND 0x08
|
||||||
|
#define NFSV3ACCESS_DELETE 0x10
|
||||||
|
#define NFSV3ACCESS_EXECUTE 0x20
|
||||||
|
|
||||||
|
#define NFSV3WRITE_UNSTABLE 0
|
||||||
|
#define NFSV3WRITE_DATASYNC 1
|
||||||
|
#define NFSV3WRITE_FILESYNC 2
|
||||||
|
|
||||||
|
#define NFSV3CREATE_UNCHECKED 0
|
||||||
|
#define NFSV3CREATE_GUARDED 1
|
||||||
|
#define NFSV3CREATE_EXCLUSIVE 2
|
||||||
|
|
||||||
|
#define NFSV3FSINFO_LINK 0x01
|
||||||
|
#define NFSV3FSINFO_SYMLINK 0x02
|
||||||
|
#define NFSV3FSINFO_HOMOGENEOUS 0x08
|
||||||
|
#define NFSV3FSINFO_CANSETTIME 0x10
|
||||||
|
|
||||||
|
/* Conversion macros */
|
||||||
|
#define vtonfsv2_mode(t,m) \
|
||||||
|
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
|
||||||
|
MAKEIMODE((t), (m)))
|
||||||
|
#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
|
||||||
|
#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777)
|
||||||
|
#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
|
||||||
|
#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
|
||||||
|
#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
|
||||||
|
#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
|
||||||
|
|
||||||
|
/* File types */
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NFNON = 0,
|
||||||
|
NFREG = 1,
|
||||||
|
NFDIR = 2,
|
||||||
|
NFBLK = 3,
|
||||||
|
NFCHR = 4,
|
||||||
|
NFLNK = 5,
|
||||||
|
NFSOCK = 6,
|
||||||
|
NFFIFO = 7
|
||||||
|
} nfstype;
|
||||||
|
|
||||||
|
/* Structs for common parts of the rpc's */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File Handle (32 bytes for version 2), variable up to 64 for version 3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NFS_MAXFHSIZE
|
||||||
|
# define NFS_MAXFHSIZE 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
union nfsfh
|
||||||
|
{
|
||||||
|
fhandle_t fh_generic;
|
||||||
|
unsigned char fh_bytes[NFS_MAXFHSIZE];
|
||||||
|
};
|
||||||
|
typedef union nfsfh nfsfh_t;
|
||||||
|
|
||||||
|
struct nfsv2_time
|
||||||
|
{
|
||||||
|
uint32_t nfsv2_sec;
|
||||||
|
uint32_t nfsv2_usec;
|
||||||
|
};
|
||||||
|
typedef struct nfsv2_time nfstime2;
|
||||||
|
|
||||||
|
struct nfsv3_time
|
||||||
|
{
|
||||||
|
uint32_t nfsv3_sec;
|
||||||
|
uint32_t nfsv3_nsec;
|
||||||
|
};
|
||||||
|
typedef struct nfsv3_time nfstime3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Quads are defined as arrays of 2 longs to ensure dense packing for the
|
||||||
|
* protocol and to facilitate xdr conversion.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfs_uquad
|
||||||
|
{
|
||||||
|
uint32_t nfsuquad[2];
|
||||||
|
};
|
||||||
|
typedef struct nfs_uquad nfsuint64;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NFS Version 3 special file number.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsv3_spec
|
||||||
|
{
|
||||||
|
uint32_t specdata1;
|
||||||
|
uint32_t specdata2;
|
||||||
|
};
|
||||||
|
typedef struct nfsv3_spec nfsv3spec;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File attributes and setable attributes. These structures cover both
|
||||||
|
* NFS version 2 and the version 3 protocol. Note that the union is only
|
||||||
|
* used so that one pointer can refer to both variants. These structures
|
||||||
|
* go out on the wire and must be densely packed, so no quad data types
|
||||||
|
* are used. (all fields are longs or u_longs or structures of same)
|
||||||
|
* NB: You can't do sizeof(struct nfs_fattr), you must use the
|
||||||
|
* NFSX_FATTR(v3) macro.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfs_fattr
|
||||||
|
{
|
||||||
|
uint32_t fa_type;
|
||||||
|
uint32_t fa_mode;
|
||||||
|
uint32_t fa_nlink;
|
||||||
|
uint32_t fa_uid;
|
||||||
|
uint32_t fa_gid;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t nfsv2fa_size;
|
||||||
|
uint32_t nfsv2fa_blocksize;
|
||||||
|
uint32_t nfsv2fa_rdev;
|
||||||
|
uint32_t nfsv2fa_blocks;
|
||||||
|
uint32_t nfsv2fa_fsid;
|
||||||
|
uint32_t nfsv2fa_fileid;
|
||||||
|
nfstime2 nfsv2fa_atime;
|
||||||
|
nfstime2 nfsv2fa_mtime;
|
||||||
|
nfstime2 nfsv2fa_ctime;
|
||||||
|
} fa_nfsv2;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
nfsuint64 nfsv3fa_size;
|
||||||
|
nfsuint64 nfsv3fa_used;
|
||||||
|
nfsv3spec nfsv3fa_rdev;
|
||||||
|
nfsuint64 nfsv3fa_fsid;
|
||||||
|
nfsuint64 nfsv3fa_fileid;
|
||||||
|
nfstime3 nfsv3fa_atime;
|
||||||
|
nfstime3 nfsv3fa_mtime;
|
||||||
|
nfstime3 nfsv3fa_ctime;
|
||||||
|
} fa_nfsv3;
|
||||||
|
} fa_un;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* and some ugly defines for accessing union components */
|
||||||
|
|
||||||
|
#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
|
||||||
|
#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize
|
||||||
|
#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev
|
||||||
|
#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks
|
||||||
|
#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid
|
||||||
|
#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid
|
||||||
|
#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime
|
||||||
|
#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime
|
||||||
|
#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime
|
||||||
|
#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size
|
||||||
|
#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used
|
||||||
|
#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev
|
||||||
|
#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid
|
||||||
|
#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid
|
||||||
|
#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime
|
||||||
|
#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime
|
||||||
|
#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
|
||||||
|
|
||||||
|
struct nfsv2_sattr
|
||||||
|
{
|
||||||
|
uint32_t sa_mode;
|
||||||
|
uint32_t sa_uid;
|
||||||
|
uint32_t sa_gid;
|
||||||
|
uint32_t sa_size;
|
||||||
|
nfstime2 sa_atime;
|
||||||
|
nfstime2 sa_mtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NFS Version 3 sattr structure for the new node creation case.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsv3_sattr
|
||||||
|
{
|
||||||
|
uint32_t sa_modetrue;
|
||||||
|
uint32_t sa_mode;
|
||||||
|
uint32_t sa_uidfalse;
|
||||||
|
uint32_t sa_gidfalse;
|
||||||
|
uint32_t sa_sizefalse;
|
||||||
|
uint32_t sa_atimetype;
|
||||||
|
nfstime3 sa_atime;
|
||||||
|
uint32_t sa_mtimetype;
|
||||||
|
nfstime3 sa_mtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nfs_statfs
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t nfsv2sf_tsize;
|
||||||
|
uint32_t nfsv2sf_bsize;
|
||||||
|
uint32_t nfsv2sf_blocks;
|
||||||
|
uint32_t nfsv2sf_bfree;
|
||||||
|
uint32_t nfsv2sf_bavail;
|
||||||
|
} sf_nfsv2;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
nfsuint64 nfsv3sf_tbytes;
|
||||||
|
nfsuint64 nfsv3sf_fbytes;
|
||||||
|
nfsuint64 nfsv3sf_abytes;
|
||||||
|
nfsuint64 nfsv3sf_tfiles;
|
||||||
|
nfsuint64 nfsv3sf_ffiles;
|
||||||
|
nfsuint64 nfsv3sf_afiles;
|
||||||
|
uint32_t nfsv3sf_invarsec;
|
||||||
|
} sf_nfsv3;
|
||||||
|
} sf_un;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
|
||||||
|
#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
|
||||||
|
#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks
|
||||||
|
#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree
|
||||||
|
#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail
|
||||||
|
#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes
|
||||||
|
#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes
|
||||||
|
#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes
|
||||||
|
#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles
|
||||||
|
#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles
|
||||||
|
#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles
|
||||||
|
#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
|
||||||
|
|
||||||
|
struct nfsv3_fsinfo
|
||||||
|
{
|
||||||
|
uint32_t fs_rtmax;
|
||||||
|
uint32_t fs_rtpref;
|
||||||
|
uint32_t fs_rtmult;
|
||||||
|
uint32_t fs_wtmax;
|
||||||
|
uint32_t fs_wtpref;
|
||||||
|
uint32_t fs_wtmult;
|
||||||
|
uint32_t fs_dtpref;
|
||||||
|
nfsuint64 fs_maxfilesize;
|
||||||
|
nfstime3 fs_timedelta;
|
||||||
|
uint32_t fs_properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nfsv3_pathconf
|
||||||
|
{
|
||||||
|
uint32_t pc_linkmax;
|
||||||
|
uint32_t pc_namemax;
|
||||||
|
uint32_t pc_notrunc;
|
||||||
|
uint32_t pc_chownrestricted;
|
||||||
|
uint32_t pc_caseinsensitive;
|
||||||
|
uint32_t pc_casepreserving;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
230
fs/nfs/nfs_socket.c
Normal file
230
fs/nfs/nfs_socket.c
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* copyright (c) 2004
|
||||||
|
* the regents of the university of michigan
|
||||||
|
* all rights reserved
|
||||||
|
*
|
||||||
|
* permission is granted to use, copy, create derivative works and redistribute
|
||||||
|
* this software and such derivative works for any purpose, so long as the name
|
||||||
|
* of the university of michigan is not used in any advertising or publicity
|
||||||
|
* pertaining to the use or distribution of this software without specific,
|
||||||
|
* written prior authorization. if the above copyright notice or any other
|
||||||
|
* identification of the university of michigan is included in any copy of any
|
||||||
|
* portion of this software, then the disclaimer below must also be included.
|
||||||
|
*
|
||||||
|
* this software is provided as is, without representation from the university
|
||||||
|
* of michigan as to its fitness for any purpose, and without warranty by the
|
||||||
|
* university of michigan of any kind, either express or implied, including
|
||||||
|
* without limitation the implied warranties of merchantability and fitness for
|
||||||
|
* a particular purpose. the regents of the university of michigan shall not be
|
||||||
|
* liable for any damages, including special, indirect, incidental, or
|
||||||
|
* consequential damages, with respect to any claim arising out of or in
|
||||||
|
* connection with the use of the software, even if it has been or is hereafter
|
||||||
|
* advised of the possibility of such damages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* wrappers around rpcclnt */
|
||||||
|
|
||||||
|
/* XXX add tryagain code in nfs_request_xx */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Socket operations for use by nfs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/mbuf.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include "rpc_clnt.h"
|
||||||
|
#include "rpc_v2.h"
|
||||||
|
#include "nfs_proto.h
|
||||||
|
#include "nfs.h"
|
||||||
|
#include "xdr_subs.h"
|
||||||
|
#include "nfsmount.h"
|
||||||
|
//#include <nfsx/nfs_common.h>
|
||||||
|
#include "nfs_socket.h"
|
||||||
|
|
||||||
|
/* Flag translations */
|
||||||
|
#define nfsmnt_to_rpcclnt(nf, rf, name) do { \
|
||||||
|
if (nf & NFSMNT_##name)) { \
|
||||||
|
rf |= RPCCLNT_##name \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
static struct rpc_program nfs2_program =
|
||||||
|
{
|
||||||
|
NFS_PROG, NFS_VER2, "NFSv2"
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct rpc_program nfs3_program =
|
||||||
|
{
|
||||||
|
NFS_PROG, NFS_VER3, "NFSv3"
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct rpc_program nfs4_program =
|
||||||
|
{
|
||||||
|
NFS_PROG, NFS_VER4, "NFSv4"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* XXXMARIUS: name collision */
|
||||||
|
int nfsx_connect(struct nfsmount *nmp)
|
||||||
|
{
|
||||||
|
struct rpcclnt *rpc;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
if (nmp == NULL)
|
||||||
|
return EFAULT;
|
||||||
|
|
||||||
|
rpc = &nmp->nm_rpcclnt;
|
||||||
|
|
||||||
|
rpc->rc_prog = &nfs3_program;
|
||||||
|
|
||||||
|
printf("nfsxconnect!\n");
|
||||||
|
|
||||||
|
/* translate nfsmnt flags -> rpcclnt flags */
|
||||||
|
rpc->rc_flag = 0;
|
||||||
|
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, SOFT);
|
||||||
|
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, INT);
|
||||||
|
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, NOCONN);
|
||||||
|
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, DUMBTIMR);
|
||||||
|
|
||||||
|
rpc->rc_flag |= RPCCLNT_REDIRECT; /* Make this a mount option. */
|
||||||
|
|
||||||
|
rpc->rc_authtype = RPCAUTH_NULL; /* for now */
|
||||||
|
rpc->rc_servername = nmp->nm_mountp->mnt_stat.f_mntfromname;
|
||||||
|
rpc->rc_name = (struct sockaddr *)nmp->nm_nam;
|
||||||
|
|
||||||
|
rpc->rc_sotype = nmp->nm_sotype;
|
||||||
|
rpc->rc_soproto = nmp->nm_soproto;
|
||||||
|
rpc->rc_rsize = (nmp->nm_rsize > nmp->nm_readdirsize) ?
|
||||||
|
nmp->nm_rsize : nmp->nm_readdirsize;
|
||||||
|
rpc->rc_wsize = nmp->nm_wsize;
|
||||||
|
rpc->rc_deadthresh = nmp->nm_deadthresh;
|
||||||
|
rpc->rc_timeo = nmp->nm_timeo;
|
||||||
|
rpc->rc_retry = nmp->nm_retry;
|
||||||
|
|
||||||
|
/* XXX v2,3 need to use this */
|
||||||
|
rpc->rc_proctlen = 0;
|
||||||
|
rpc->rc_proct = NULL;
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return rpcclnt_connect(rpc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NFS disconnect. Clean up and unlink. */
|
||||||
|
|
||||||
|
/* XXXMARIUS: name collision */
|
||||||
|
|
||||||
|
void nfsx_disconnect(struct nfsmount *nmp)
|
||||||
|
{
|
||||||
|
rpcclnt_disconnect(&nmp->nm_rpcclnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_NFS_TCPIP
|
||||||
|
void nfsx_safedisconnect(struct nfsmount *nmp)
|
||||||
|
{
|
||||||
|
rpcclnt_safedisconnect(&nmp->nm_rpcclnt);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
nfsx_request_xx(struct nfsmount *nm, struct vnode *vp, struct mbuf *mrest,
|
||||||
|
int procnum, cthread_t * td, struct ucred *cred,
|
||||||
|
struct mbuf **mrp, struct mbuf **mdp, caddr_t * dposp)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
u_int32_t *tl;
|
||||||
|
struct nfsmount *nmp;
|
||||||
|
struct rpcclnt *clnt;
|
||||||
|
struct mbuf *md, *mrep;
|
||||||
|
caddr_t dpos;
|
||||||
|
struct rpc_reply reply;
|
||||||
|
#if 0
|
||||||
|
int t1;
|
||||||
|
#endif /* 0 */
|
||||||
|
|
||||||
|
if (vp != NULL)
|
||||||
|
nmp = VFSTONFS(vp->v_mount);
|
||||||
|
else
|
||||||
|
nmp = nm;
|
||||||
|
|
||||||
|
clnt = &nmp->nm_rpcclnt;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
tryagain:
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset(&reply, 0, sizeof(reply));
|
||||||
|
|
||||||
|
if ((error = rpcclnt_request(clnt, mrest, procnum, td, cred, &reply)) != 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
mrep = reply.mrep;
|
||||||
|
md = reply.result_md;
|
||||||
|
dpos = reply.result_dpos;
|
||||||
|
|
||||||
|
tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED);
|
||||||
|
if (*tl != 0)
|
||||||
|
{
|
||||||
|
error = fxdr_unsigned(int, *tl);
|
||||||
|
#if 0
|
||||||
|
if ((nmp->nm_flag & NFSMNT_NFSV3) && error == NFSERR_TRYLATER)
|
||||||
|
{
|
||||||
|
m_freem(mrep);
|
||||||
|
error = 0;
|
||||||
|
waituntil = time_second + trylater_delay;
|
||||||
|
while (time_second < waituntil)
|
||||||
|
(void)tsleep(&lbolt, PSOCK, "nqnfstry", 0);
|
||||||
|
trylater_delay *= nfs_backoff[trylater_cnt];
|
||||||
|
if (trylater_cnt < NFS_NBACKOFF - 1)
|
||||||
|
trylater_cnt++;
|
||||||
|
goto tryagain;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** If the File Handle was stale, invalidate the
|
||||||
|
** lookup cache, just in case.
|
||||||
|
**/
|
||||||
|
if (error == ESTALE)
|
||||||
|
if (vp != NULL)
|
||||||
|
cache_purge(vp);
|
||||||
|
else
|
||||||
|
printf("%s: ESTALE on mount from server %s\n",
|
||||||
|
nmp->nm_rpcclnt.rc_prog->prog_name,
|
||||||
|
nmp->nm_rpcclnt.rc_servername);
|
||||||
|
else
|
||||||
|
printf("%s: unknown error %d from server %s\n",
|
||||||
|
nmp->nm_rpcclnt.rc_prog->prog_name, error,
|
||||||
|
nmp->nm_rpcclnt.rc_servername);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_freem(mrest);
|
||||||
|
|
||||||
|
*mrp = mrep;
|
||||||
|
*mdp = md;
|
||||||
|
*dposp = dpos;
|
||||||
|
return (0);
|
||||||
|
nfsmout:
|
||||||
|
out:
|
||||||
|
/* XXX: don't free mrest if an error occured, to allow caller to retry */
|
||||||
|
m_freem(mrest);
|
||||||
|
m_freem(reply.mrep);
|
||||||
|
*mrp = NULL;
|
||||||
|
*mdp = NULL;
|
||||||
|
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* terminate any outstanding RPCs. */
|
||||||
|
|
||||||
|
int nfsx_nmcancelreqs(struct nfsmount *nmp)
|
||||||
|
{
|
||||||
|
return rpcclnt_cancelreqs(&nmp->nm_rpcclnt);
|
||||||
|
}
|
69
fs/nfs/nfs_socket.h
Normal file
69
fs/nfs/nfs_socket.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* copyright (c) 2004
|
||||||
|
* the regents of the university of michigan
|
||||||
|
* all rights reserved
|
||||||
|
*
|
||||||
|
* permission is granted to use, copy, create derivative works and redistribute
|
||||||
|
* this software and such derivative works for any purpose, so long as the name
|
||||||
|
* of the university of michigan is not used in any advertising or publicity
|
||||||
|
* pertaining to the use or distribution of this software without specific,
|
||||||
|
* written prior authorization. if the above copyright notice or any other
|
||||||
|
* identification of the university of michigan is included in any copy of any
|
||||||
|
* portion of this software, then the disclaimer below must also be included.
|
||||||
|
*
|
||||||
|
* this software is provided as is, without representation from the university
|
||||||
|
* of michigan as to its fitness for any purpose, and without warranty by the
|
||||||
|
* university of michigan of any kind, either express or implied, including
|
||||||
|
* without limitation the implied warranties of merchantability and fitness for
|
||||||
|
* a particular purpose. the regents of the university of michigan shall not be
|
||||||
|
* liable for any damages, including special, indirect, incidental, or
|
||||||
|
* consequential damages, with respect to any claim arising out of or in
|
||||||
|
* connection with the use of the software, even if it has been or is hereafter
|
||||||
|
* advised of the possibility of such damages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __NFSX_H_
|
||||||
|
#define __NFSX_H_
|
||||||
|
|
||||||
|
/* nfs_socket interface */
|
||||||
|
|
||||||
|
/* XXXMARIUS: name collision */
|
||||||
|
|
||||||
|
int nfsx_connect(struct nfsmount *);
|
||||||
|
void nfsx_disconnect(struct nfsmount *);
|
||||||
|
int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
||||||
|
void nfsx_safedisconnect(struct nfsmount *);
|
||||||
|
int nfsx_request_xx(struct nfsmount *, struct vnode *, struct mbuf *, int,
|
||||||
|
cthread_t *, struct ucred *, struct mbuf **, struct mbuf **,
|
||||||
|
caddr_t *);
|
||||||
|
int nfsx_nmcancelreqs(struct nfsmount *);
|
||||||
|
|
||||||
|
#define nfs_connect nfs_connect_nfsx
|
||||||
|
#define nfs_disconnect nfs_disconnect_nfsx
|
||||||
|
#define nfs_sigintr nfs_sigintr_nfsx
|
||||||
|
|
||||||
|
/* XXX dros: defined in nfs.h */
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void nfs_safedisconnect(struct nfsmount *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define nfsx_request(vp, m, p, td, cr, m2, m3, c) \
|
||||||
|
nfsx_request_xx(NULL, vp, m, p, td, cr, m2, m3, c)
|
||||||
|
|
||||||
|
#define nfsx_request_mnt(nmp, m, p, td, cr, m2, m3, c) \
|
||||||
|
nfsx_request_xx(nmp, NULL, m, p, td, cr, m2, m3, c)
|
||||||
|
|
||||||
|
/* don't use this.. use nfsx_request() of nfsx_request_mnt() */
|
||||||
|
|
||||||
|
int nfs_request_xx(struct nfsmount *, struct vnode *, struct mbuf *, int,
|
||||||
|
cthread_t *, struct ucred *, struct mbuf **, struct mbuf **,
|
||||||
|
caddr_t *);
|
||||||
|
|
||||||
|
/* XXX dros: defined in nfs.h */
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
int nfs_nmcancelreqs(struct nfsmount *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __NFSX_H_ */
|
106
fs/nfs/nfsmount.h
Normal file
106
fs/nfs/nfsmount.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1989, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Rick Macklem at The University of Guelph.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _NFSCLIENT_NFSMOUNT_H_
|
||||||
|
#define _NFSCLIENT_NFSMOUNT_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mount structure.
|
||||||
|
* One allocated on every NFS mount.
|
||||||
|
* Holds NFS specific information for mount.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct nfsmount
|
||||||
|
{
|
||||||
|
int nm_flag; /* Flags for soft/hard... */
|
||||||
|
int nm_state; /* Internal state flags */
|
||||||
|
struct mount *nm_mountp; /* Vfs structure for this filesystem */
|
||||||
|
int nm_numgrps; /* Max. size of groupslist */
|
||||||
|
nfsfh_t nm_fh; /* File handle of root dir */
|
||||||
|
int nm_fhsize; /* Size of root file handle */
|
||||||
|
struct rpcclnt nm_rpcclnt; /* rpc state */
|
||||||
|
struct socket *nm_so; /* Rpc socket */
|
||||||
|
int nm_sotype; /* Type of socket */
|
||||||
|
int nm_soproto; /* and protocol */
|
||||||
|
int nm_soflags; /* pr_flags for socket protocol */
|
||||||
|
struct sockaddr *nm_nam; /* Addr of server */
|
||||||
|
int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */
|
||||||
|
int nm_retry; /* Max retries */
|
||||||
|
int nm_srtt[4]; /* Timers for rpcs */
|
||||||
|
int nm_sdrtt[4];
|
||||||
|
int nm_sent; /* Request send count */
|
||||||
|
int nm_cwnd; /* Request send window */
|
||||||
|
int nm_timeouts; /* Request timeouts */
|
||||||
|
int nm_deadthresh; /* Threshold of timeouts-->dead server */
|
||||||
|
int nm_rsize; /* Max size of read rpc */
|
||||||
|
int nm_wsize; /* Max size of write rpc */
|
||||||
|
int nm_readdirsize; /* Size of a readdir rpc */
|
||||||
|
int nm_readahead; /* Num. of blocks to readahead */
|
||||||
|
int nm_acdirmin; /* Directory attr cache min lifetime */
|
||||||
|
int nm_acdirmax; /* Directory attr cache max lifetime */
|
||||||
|
int nm_acregmin; /* Reg file attr cache min lifetime */
|
||||||
|
int nm_acregmax; /* Reg file attr cache max lifetime */
|
||||||
|
u_char nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
|
||||||
|
TAILQ_HEAD(, buf) nm_bufq; /* async io buffer queue */
|
||||||
|
short nm_bufqlen; /* number of buffers in queue */
|
||||||
|
short nm_bufqwant; /* process wants to add to the queue */
|
||||||
|
int nm_bufqiods; /* number of iods processing queue */
|
||||||
|
u_int64_t nm_maxfilesize; /* maximum file size */
|
||||||
|
|
||||||
|
struct nfsx_nfsops *nm_nfsops; /* Version specific ops. */
|
||||||
|
|
||||||
|
/* NFSv4 */
|
||||||
|
|
||||||
|
uint64_t nm_clientid;
|
||||||
|
fsid_t nm_fsid;
|
||||||
|
u_int nm_lease_time;
|
||||||
|
time_t nm_last_renewal;
|
||||||
|
|
||||||
|
struct vnode *nm_dvp;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NFSOP(nmp, op) (*nmp->nm_nfsops->nn_##op)
|
||||||
|
#define NFSHASOP(nmp, op) (nmp->nm_nfsops->nn_##op != NULL)
|
||||||
|
#define NFSDAT(nmp, nam) (nmp->nm_nfsops->nn_##nam)
|
||||||
|
|
||||||
|
#if defined(_KERNEL)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert mount ptr to nfsmount ptr.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# define VFSTONFS(mp) ((struct nfsmount *)((mp)->mnt_data))
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
239
fs/nfs/rpc.h
239
fs/nfs/rpc.h
@ -1,24 +1,48 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
* fs/nfs/rpc.h
|
* copyright (c) 2003
|
||||||
|
* the regents of the university of michigan
|
||||||
|
* all rights reserved
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* permission is granted to use, copy, create derivative works and redistribute
|
||||||
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
|
* this software and such derivative works for any purpose, so long as the name
|
||||||
* Author: Jose Pablo Rojas Vargas <jrojas@nx-engineering.com>
|
* of the university of michigan is not used in any advertising or publicity
|
||||||
|
* pertaining to the use or distribution of this software without specific,
|
||||||
|
* written prior authorization. if the above copyright notice or any other
|
||||||
|
* identification of the university of michigan is included in any copy of any
|
||||||
|
* portion of this software, then the disclaimer below must also be included.
|
||||||
*
|
*
|
||||||
* Leveraged from OpenBSD:
|
* this software is provided as is, without representation from the university
|
||||||
*
|
* of michigan as to its fitness for any purpose, and without warranty by the
|
||||||
* Copyright (c) 1982, 1986, 1988, 1993
|
* university of michigan of any kind, either express or implied, including
|
||||||
|
* without limitation the implied warranties of merchantability and fitness for
|
||||||
|
* a particular purpose. the regents of the university of michigan shall not be
|
||||||
|
* liable for any damages, including special, indirect, incidental, or
|
||||||
|
* consequential damages, with respect to any claim arising out of or in
|
||||||
|
* connection with the use of the software, even if it has been or is hereafter
|
||||||
|
* advised of the possibility of such damages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1989, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
*
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Rick Macklem at The University of Guelph.
|
||||||
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@ -33,50 +57,175 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*/
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __FS_NFS_RPC_H
|
#ifndef _RPCCLNT_H_
|
||||||
#define __FS_NFS_RPC_H
|
#define _RPCCLNT_H_
|
||||||
|
|
||||||
/****************************************************************************
|
#include <sys/types.h>
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/* for rpcclnt's rc_flags */
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* RPC definitions for the portmapper. */
|
#define RPCCLNT_SOFT 0x001 /* soft mount (hard is details) */
|
||||||
|
#define RPCCLNT_INT 0x002 /* allow interrupts on hard mounts */
|
||||||
|
#define RPCCLNT_NOCONN 0x004 /* dont connect the socket (udp) */
|
||||||
|
#define RPCCLNT_DUMBTIMR 0x010
|
||||||
|
|
||||||
#define PMAPPORT 111
|
/* XXX should be replaced with real locks */
|
||||||
#define PMAPPROG 100000
|
|
||||||
#define PMAPVERS 2
|
|
||||||
#define PMAPPROC_NULL 0
|
|
||||||
#define PMAPPROC_SET 1
|
|
||||||
#define PMAPPROC_UNSET 2
|
|
||||||
#define PMAPPROC_GETPORT 3
|
|
||||||
#define PMAPPROC_DUMP 4
|
|
||||||
#define PMAPPROC_CALLIT 5
|
|
||||||
|
|
||||||
/* RPC definitions for bootparamd. */
|
#define RPCCLNT_SNDLOCK 0x100
|
||||||
|
#define RPCCLNT_WANTSND 0x200
|
||||||
|
#define RPCCLNT_RCVLOCK 0x400
|
||||||
|
#define RPCCLNT_WANTRCV 0x800
|
||||||
|
|
||||||
#define BOOTPARAM_PROG 100026
|
struct rpc_program
|
||||||
#define BOOTPARAM_VERS 1
|
{
|
||||||
#define BOOTPARAM_WHOAMI 1
|
uint32_t prog_id;
|
||||||
#define BOOTPARAM_GETFILE 2
|
uint32_t prog_version;
|
||||||
|
char * prog_name;
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
struct rpctask
|
||||||
* Public Function Prototypes
|
{
|
||||||
****************************************************************************/
|
dq_entry_t r_chain;
|
||||||
|
|
||||||
int krpc_call(struct sockaddr_in *, unsigned int, unsigned int, unsigned int,
|
struct rpcclnt *r_rpcclnt;
|
||||||
struct sockaddr **, int);
|
|
||||||
int krpc_portmap(struct sockaddr_in *, unsigned int, unsigned int, uint16_t *);
|
|
||||||
|
|
||||||
void xdr_string_encode(char *, int);
|
uint32_t r_xid;
|
||||||
void xdr_string_decode(char *, int *);
|
int r_flags; /* flags on request, see below */
|
||||||
void xdr_inaddr_encode(struct in_addr *);
|
int r_retry; /* max retransmission count */
|
||||||
void xdr_inaddr_decode(struct in_addr *);
|
int r_rexmit; /* current retrans count */
|
||||||
|
int r_timer; /* tick counter on reply */
|
||||||
|
int r_procnum; /* NFS procedure number */
|
||||||
|
int r_rtt; /* RTT for rpc */
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __FS_NFS_RPC_H */
|
/* Generic RPC headers */
|
||||||
|
|
||||||
|
struct rpc_auth_info
|
||||||
|
{
|
||||||
|
uint32_t authtype; /* auth type */
|
||||||
|
uint32_t authlen; /* auth length */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct auth_unix
|
||||||
|
{
|
||||||
|
int32_t ua_time;
|
||||||
|
int32_t ua_hostname; /* null */
|
||||||
|
int32_t ua_uid;
|
||||||
|
int32_t ua_gid;
|
||||||
|
int32_t ua_gidlist; /* null */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rpc_call
|
||||||
|
{
|
||||||
|
uint32_t rp_xid; /* request transaction id */
|
||||||
|
int32_t rp_direction; /* call direction (0) */
|
||||||
|
uint32_t rp_rpcvers; /* rpc version (2) */
|
||||||
|
uint32_t rp_prog; /* program */
|
||||||
|
uint32_t rp_vers; /* version */
|
||||||
|
uint32_t rp_proc; /* procedure */
|
||||||
|
struct rpc_auth_info rpc_auth;
|
||||||
|
struct auth_unix rpc_unix;
|
||||||
|
struct rpc_auth_info rpc_verf;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rpc_reply
|
||||||
|
{
|
||||||
|
uint32_t rp_xid; /* request transaction id */
|
||||||
|
int32_t rp_direction; /* call direction (1) */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t type;
|
||||||
|
uint32_t status;
|
||||||
|
|
||||||
|
/* used only when reply == RPC_MSGDENIED and status == RPC_AUTHERR */
|
||||||
|
|
||||||
|
uint32_t autherr;
|
||||||
|
|
||||||
|
/* rpc mismatch info if reply == RPC_MSGDENIED and status == RPC_MISMATCH */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t low;
|
||||||
|
uint32_t high;
|
||||||
|
} mismatch_info;
|
||||||
|
} stat;
|
||||||
|
|
||||||
|
struct rpc_auth_info rpc_verfi;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RPC Client connection context.
|
||||||
|
* One allocated on every NFS mount.
|
||||||
|
* Holds RPC specific information for mount.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* XXX: please note that all pointer type variables are just set (not copied),
|
||||||
|
* so it is up to the user to free these values */
|
||||||
|
|
||||||
|
struct rpcclnt
|
||||||
|
{
|
||||||
|
int rc_flag; /* For RPCCLNT_* flags */
|
||||||
|
|
||||||
|
int rc_wsize; /* Max size of the request data */
|
||||||
|
int rc_rsize; /* Max size of the response data */
|
||||||
|
|
||||||
|
struct sockaddr *rc_name;
|
||||||
|
struct socket *rc_so; /* Rpc socket */
|
||||||
|
|
||||||
|
int rc_sotype; /* Type of socket */
|
||||||
|
int rc_soproto; /* and protocol */
|
||||||
|
int rc_soflags; /* pr_flags for socket protocol */
|
||||||
|
|
||||||
|
int rc_timeo; /* Init timer for NFSMNT_DUMBTIMR */
|
||||||
|
int rc_retry; /* Max retries */
|
||||||
|
int rc_srtt[4]; /* Timers for rpcs */
|
||||||
|
int rc_sdrtt[4];
|
||||||
|
int rc_sent; /* Request send count */
|
||||||
|
int rc_cwnd; /* Request send window */
|
||||||
|
int rc_timeouts; /* Request timeouts */
|
||||||
|
|
||||||
|
int rc_deadthresh; /* Threshold of timeouts-->dead server*/
|
||||||
|
|
||||||
|
/* authentication: */
|
||||||
|
/* currently can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX */
|
||||||
|
/* should be kept in XDR form */
|
||||||
|
|
||||||
|
int rc_authtype; /* Authenticator type */
|
||||||
|
#ifdef CONFIG_NFS_UNIX_AUTH
|
||||||
|
/* RPCAUTH_UNIX*/
|
||||||
|
|
||||||
|
struct rpc_auth_info rc_oldauth; /* authentication */
|
||||||
|
#endif
|
||||||
|
void *rc_auth;
|
||||||
|
|
||||||
|
struct rpc_program * rc_prog;
|
||||||
|
|
||||||
|
char *rc_servername;
|
||||||
|
|
||||||
|
int rc_proctlen; /* if == 0 then rc_proct == NULL */
|
||||||
|
int * rc_proct;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
void rpcclnt_create(struct rpcclnt ** rpc);
|
||||||
|
void rpcclnt_destroy(struct rpcclnt * rpc);
|
||||||
|
|
||||||
|
#define rpcclnt_get(X) rpcclnt_create(&(X))
|
||||||
|
#define rpcclnt_put(X) rpcclnt_destroy(X)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
void rpcclnt_init(void);
|
||||||
|
//void rpcclnt_uninit(void);
|
||||||
|
|
||||||
|
int rpcclnt_setup(struct rpcclnt *, struct rpc_program *, struct sockaddr *, int, int, struct rpc_auth_info *, int, int, int);
|
||||||
|
int rpcclnt_connect(struct rpcclnt *);
|
||||||
|
int rpcclnt_reconnect(struct rpctask *);
|
||||||
|
void rpcclnt_disconnect(struct rpcclnt *);
|
||||||
|
void rpcclnt_safedisconnect(struct rpcclnt *);
|
||||||
|
int rpcclnt_request(struct rpcclnt *, int, struct rpc_reply *);
|
||||||
|
int rpcclnt_cancelreqs(struct rpcclnt *);
|
||||||
|
|
||||||
|
#endif /* _RPCCLNT_H_ */
|
||||||
|
1306
fs/nfs/rpc_clnt.c
Normal file
1306
fs/nfs/rpc_clnt.c
Normal file
File diff suppressed because it is too large
Load Diff
129
fs/nfs/rpc_clnt_private.h
Normal file
129
fs/nfs/rpc_clnt_private.h
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* copyright (c) 2003
|
||||||
|
* the regents of the university of michigan
|
||||||
|
* all rights reserved
|
||||||
|
*
|
||||||
|
* permission is granted to use, copy, create derivative works and redistribute
|
||||||
|
* this software and such derivative works for any purpose, so long as the name
|
||||||
|
* of the university of michigan is not used in any advertising or publicity
|
||||||
|
* pertaining to the use or distribution of this software without specific,
|
||||||
|
* written prior authorization. if the above copyright notice or any other
|
||||||
|
* identification of the university of michigan is included in any copy of any
|
||||||
|
* portion of this software, then the disclaimer below must also be included.
|
||||||
|
*
|
||||||
|
* this software is provided as is, without representation from the university
|
||||||
|
* of michigan as to its fitness for any purpose, and without warranty by the
|
||||||
|
* university of michigan of any kind, either express or implied, including
|
||||||
|
* without limitation the implied warranties of merchantability and fitness for
|
||||||
|
* a particular purpose. the regents of the university of michigan shall not be
|
||||||
|
* liable for any damages, including special, indirect, incidental, or
|
||||||
|
* consequential damages, with respect to any claim arising out of or in
|
||||||
|
* connection with the use of the software, even if it has been or is hereafter
|
||||||
|
* advised of the possibility of such damages.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1989, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Rick Macklem at The University of Guelph.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RPCCLNT_PRIVATE_H_
|
||||||
|
#define _RPCCLNT_PRIVATE_H_
|
||||||
|
|
||||||
|
#define RPCCLNT_DEBUG 1
|
||||||
|
|
||||||
|
#define RPC_TICKINTVL 5
|
||||||
|
|
||||||
|
/* from nfs/nfsproto.h */
|
||||||
|
|
||||||
|
#define RPC_MAXDATA 32768
|
||||||
|
#define RPC_MAXPKTHDR 404
|
||||||
|
#define RPC_MAXPACKET (RPC_MAXPKTHDR + RPC_MAXDATA)
|
||||||
|
|
||||||
|
#define RPCX_UNSIGNED 4
|
||||||
|
|
||||||
|
#define RPC_SUCCESS 0
|
||||||
|
|
||||||
|
/* Flag values for r_flags */
|
||||||
|
|
||||||
|
#define TASK_TIMING 0x01 /* timing request (in mntp) */
|
||||||
|
#define TASK_SENT 0x02 /* request has been sent */
|
||||||
|
#define TASK_SOFTTERM 0x04 /* soft mnt, too many retries */
|
||||||
|
|
||||||
|
|
||||||
|
#define TASK_INTR 0x08 /* intr mnt, signal pending */
|
||||||
|
#define TASK_SOCKERR 0x10 /* Fatal error on socket */
|
||||||
|
|
||||||
|
|
||||||
|
#define TASK_TPRINTFMSG 0x20 /* Did a tprintf msg. */
|
||||||
|
|
||||||
|
#define TASK_MUSTRESEND 0x40 /* Must resend request */
|
||||||
|
#define TASK_GETONEREP 0x80 /* Probe for one reply only */
|
||||||
|
|
||||||
|
|
||||||
|
#define RPC_HZ (CLOCKS_PER_SEC / rpcclnt_ticks) /* Ticks/sec */
|
||||||
|
#define RPC_TIMEO (1 * RPC_HZ) /* Default timeout = 1 second */
|
||||||
|
|
||||||
|
#define RPC_MAXREXMIT 100 /* Stop counting after this many */
|
||||||
|
|
||||||
|
|
||||||
|
#define RPCIGNORE_SOERROR(s, e) \
|
||||||
|
((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK)
|
||||||
|
|
||||||
|
#define RPCINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
|
||||||
|
sigmask(SIGHUP)|sigmask(SIGQUIT))
|
||||||
|
|
||||||
|
#define RPCMADV(m, s) (m)->m_data += (s)
|
||||||
|
|
||||||
|
#define RPCAUTH_ROOTCREDS NULL
|
||||||
|
|
||||||
|
#define RPCCLNTINT_SIGMASK(set) \
|
||||||
|
(SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
|
||||||
|
SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
|
||||||
|
SIGISMEMBER(set, SIGQUIT))
|
||||||
|
|
||||||
|
/* global rpcstats
|
||||||
|
* XXX should be per rpcclnt */
|
||||||
|
|
||||||
|
struct rpcstats
|
||||||
|
{
|
||||||
|
int rpcretries;
|
||||||
|
int rpcrequests;
|
||||||
|
int rpctimeouts;
|
||||||
|
int rpcunexpected;
|
||||||
|
int rpcinvalid;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _RPCCLNT_PRIVATE_H_ */
|
@ -1,69 +0,0 @@
|
|||||||
|
|
||||||
/* $OpenBSD: idgen.h,v 1.2 2008/06/25 00:55:53 djm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* fs/nfs/rpc_idgen.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
|
||||||
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
|
|
||||||
* Author: Jose Pablo Rojas Vargas <jrojas@nx-engineering.com>
|
|
||||||
*
|
|
||||||
* Leveraged from OpenBSD:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2008 Damien Miller <djm@mindrot.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __FS_NFS_RPC_IDGEN_H
|
|
||||||
#define __FS_NFS_RPC_IDGEN_H
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#define IDGEN32_ROUNDS 31
|
|
||||||
#define IDGEN32_KEYLEN 32
|
|
||||||
#define IDGEN32_REKEY_LIMIT 0x60000000
|
|
||||||
#define IDGEN32_REKEY_TIME 600
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
struct idgen32_ctx
|
|
||||||
{
|
|
||||||
uint32_t id_counter;
|
|
||||||
uint32_t id_offset;
|
|
||||||
uint32_t id_hibit;
|
|
||||||
uint8_t id_key[IDGEN32_KEYLEN];
|
|
||||||
time_t id_rekey_time;
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void idgen32_init(struct idgen32_ctx *);
|
|
||||||
uint32_t idgen32(struct idgen32_ctx *);
|
|
||||||
|
|
||||||
#endif /* __FS_NFS_RPC_IDGEN_H */
|
|
||||||
|
|
@ -1,449 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* fs/nfs/rpc_mbuf.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
|
||||||
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
|
|
||||||
* Author: Jose Pablo Rojas Vargas <jrojas@nx-engineering.com>
|
|
||||||
*
|
|
||||||
* Leveraged from OpenBSD:
|
|
||||||
*
|
|
||||||
* Copyright (c) 1982, 1986, 1988, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __FS_NFS_RPC_MBUF_H
|
|
||||||
#define __FS_NFS_RPC_MBUF_H
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <sys/queue.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
/* Mbufs are of a single size, MSIZE (sys/param.h), which
|
|
||||||
* includes overhead. An mbuf may add a single "mbuf cluster" of size
|
|
||||||
* MCLBYTES (also in sys/param.h), which has no additional overhead
|
|
||||||
* and is used instead of the internal data area; this is done when
|
|
||||||
* at least MINCLSIZE of data must be stored.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MSIZE 128
|
|
||||||
#define MCLSHIFT 11 /* Convert bytes to m_buf clusters */
|
|
||||||
/* 2K cluster can hold Ether frame */
|
|
||||||
#define MCLBYTES (1 << MCLSHIFT) /* Size of a m_buf cluster */
|
|
||||||
#define MLEN (MSIZE - sizeof(struct m_hdr)) /* Normal data len */
|
|
||||||
#define MHLEN (MLEN - sizeof(struct pkthdr)) /* Data len w/pkthdr */
|
|
||||||
|
|
||||||
/* smallest amount to put in cluster */
|
|
||||||
|
|
||||||
#define MINCLSIZE (MHLEN + MLEN + 1)
|
|
||||||
#define M_MAXCOMPRESS (MHLEN / 2) /* Max amount to copy for compression */
|
|
||||||
|
|
||||||
/* Macros for type conversion
|
|
||||||
* mtod(m,t) - convert mbuf pointer to data pointer of correct type
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define mtod(m,t) ((t)((m)->m_data))
|
|
||||||
|
|
||||||
/* mbuf flags */
|
|
||||||
|
|
||||||
#define M_EXT 0x0001 /* has associated external storage */
|
|
||||||
#define M_PKTHDR 0x0002 /* start of record */
|
|
||||||
#define M_EOR 0x0004 /* end of record */
|
|
||||||
#define M_CLUSTER 0x0008 /* external storage is a cluster */
|
|
||||||
#define M_PROTO1 0x0010 /* protocol-specific */
|
|
||||||
|
|
||||||
/* mbuf pkthdr flags, also in m_flags */
|
|
||||||
|
|
||||||
#define M_VLANTAG 0x0020 /* ether_vtag is valid */
|
|
||||||
#define M_LOOP 0x0040 /* for Mbuf statistics */
|
|
||||||
#define M_FILDROP 0x0080 /* dropped by bpf filter */
|
|
||||||
#define M_BCAST 0x0100 /* send/received as link-level broadcast */
|
|
||||||
#define M_MCAST 0x0200 /* send/received as link-level multicast */
|
|
||||||
#define M_CONF 0x0400 /* payload was encrypted (ESP-transport) */
|
|
||||||
#define M_AUTH 0x0800 /* payload was authenticated (AH or ESP auth) */
|
|
||||||
#define M_TUNNEL 0x1000 /* IP-in-IP added by tunnel mode IPsec */
|
|
||||||
#define M_AUTH_AH 0x2000 /* header was authenticated (AH) */
|
|
||||||
#define M_COMP 0x4000 /* header was decompressed */
|
|
||||||
#define M_LINK0 0x8000 /* link layer specific flag */
|
|
||||||
|
|
||||||
/* Flags copied when copying m_pkthdr */
|
|
||||||
|
|
||||||
#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_PROTO1|M_BCAST|M_MCAST|M_CONF|M_COMP|\
|
|
||||||
M_AUTH|M_LOOP|M_TUNNEL|M_LINK0|M_VLANTAG|M_FILDROP)
|
|
||||||
|
|
||||||
/* Checksumming flags */
|
|
||||||
|
|
||||||
#define M_IPV4_CSUM_OUT 0x0001 /* IPv4 checksum needed */
|
|
||||||
#define M_TCP_CSUM_OUT 0x0002 /* TCP checksum needed */
|
|
||||||
#define M_UDP_CSUM_OUT 0x0004 /* UDP checksum needed */
|
|
||||||
#define M_IPV4_CSUM_IN_OK 0x0008 /* IPv4 checksum verified */
|
|
||||||
#define M_IPV4_CSUM_IN_BAD 0x0010 /* IPv4 checksum bad */
|
|
||||||
#define M_TCP_CSUM_IN_OK 0x0020 /* TCP/IPv4 checksum verified */
|
|
||||||
#define M_TCP_CSUM_IN_BAD 0x0040 /* TCP/IPv4 checksum bad */
|
|
||||||
#define M_UDP_CSUM_IN_OK 0x0080 /* UDP/IPv4 checksum verified */
|
|
||||||
#define M_UDP_CSUM_IN_BAD 0x0100 /* UDP/IPv4 checksum bad */
|
|
||||||
#define M_ICMP_CSUM_OUT 0x0200 /* ICMP checksum needed */
|
|
||||||
#define M_ICMP_CSUM_IN_OK 0x0400 /* ICMP checksum verified */
|
|
||||||
#define M_ICMP_CSUM_IN_BAD 0x0800 /* ICMP checksum bad */
|
|
||||||
|
|
||||||
/* mbuf types */
|
|
||||||
|
|
||||||
#define MT_FREE 0 /* should be on free list */
|
|
||||||
#define MT_DATA 1 /* dynamic (data) allocation */
|
|
||||||
#define MT_HEADER 2 /* packet header */
|
|
||||||
#define MT_SONAME 3 /* socket name */
|
|
||||||
#define MT_SOOPTS 4 /* socket options */
|
|
||||||
#define MT_FTABLE 5 /* fragment reassembly header */
|
|
||||||
#define MT_CONTROL 6 /* extra-data protocol message */
|
|
||||||
#define MT_OOBDATA 7 /* expedited data */
|
|
||||||
|
|
||||||
/* Flags to m_get/MGET */
|
|
||||||
|
|
||||||
#define M_DONTWAIT 0x0000
|
|
||||||
#define M_WAIT 0x0001
|
|
||||||
|
|
||||||
/* mbuf allocation/deallocation macros:
|
|
||||||
*
|
|
||||||
* MGET(struct mbuf *m, int how, int type)
|
|
||||||
* allocates an mbuf and initializes it to contain internal data.
|
|
||||||
*
|
|
||||||
* MGETHDR(struct mbuf *m, int how, int type)
|
|
||||||
* allocates an mbuf and initializes it to contain a packet header
|
|
||||||
* and internal data.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MGET(m, how, type) m = m_get((how), (type))
|
|
||||||
#define MGETHDR(m, how, type) m = m_gethdr((how), (type))
|
|
||||||
|
|
||||||
/* Macros for tracking external storage associated with an mbuf.
|
|
||||||
*
|
|
||||||
* Note: add and delete reference must be called at splnet().
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
|
||||||
# define MCLREFDEBUGN(m, file, line) do { \
|
|
||||||
(m)->m_ext.ext_nfile = (file); \
|
|
||||||
(m)->m_ext.ext_nline = (line); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
# define MCLREFDEBUGO(m, file, line) do { \
|
|
||||||
(m)->m_ext.ext_ofile = (file); \
|
|
||||||
(m)->m_ext.ext_oline = (line); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
#else
|
|
||||||
# define MCLREFDEBUGN(m, file, line)
|
|
||||||
# define MCLREFDEBUGO(m, file, line)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MCLISREFERENCED(m) ((m)->m_ext.ext_nextref != (m))
|
|
||||||
|
|
||||||
#define MCLADDREFERENCE(o, n) do { \
|
|
||||||
int ms = splnet(); \
|
|
||||||
(n)->m_flags |= ((o)->m_flags & (M_EXT|M_CLUSTER)); \
|
|
||||||
(n)->m_ext.ext_nextref = (o)->m_ext.ext_nextref; \
|
|
||||||
(n)->m_ext.ext_prevref = (o); \
|
|
||||||
(o)->m_ext.ext_nextref = (n); \
|
|
||||||
(n)->m_ext.ext_nextref->m_ext.ext_prevref = (n); \
|
|
||||||
splx(ms); \
|
|
||||||
MCLREFDEBUGN((n), __FILE__, __LINE__); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
|
|
||||||
#define MCLINITREFERENCE(m) do { \
|
|
||||||
(m)->m_ext.ext_prevref = (m); \
|
|
||||||
(m)->m_ext.ext_nextref = (m); \
|
|
||||||
MCLREFDEBUGO((m), __FILE__, __LINE__); \
|
|
||||||
MCLREFDEBUGN((m), NULL, 0); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
|
|
||||||
/* Macros for mbuf external storage.
|
|
||||||
*
|
|
||||||
* MEXTADD adds pre-allocated external storage to
|
|
||||||
* a normal mbuf; the flag M_EXT is set.
|
|
||||||
*
|
|
||||||
* MCLGET allocates and adds an mbuf cluster to a normal mbuf;
|
|
||||||
* the flag M_EXT is set upon success.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MEXTADD(m, buf, size, type, free, arg) do { \
|
|
||||||
(m)->m_data = (m)->m_ext.ext_buf = (char*)(buf); \
|
|
||||||
(m)->m_flags |= M_EXT; \
|
|
||||||
(m)->m_flags &= ~M_CLUSTER; \
|
|
||||||
(m)->m_ext.ext_size = (size); \
|
|
||||||
(m)->m_ext.ext_free = (free); \
|
|
||||||
(m)->m_ext.ext_arg = (arg); \
|
|
||||||
(m)->m_ext.ext_type = (type); \
|
|
||||||
MCLINITREFERENCE(m); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
|
|
||||||
#define MCLGET(m, how) (void) m_clget((m), (how), NULL, MCLBYTES)
|
|
||||||
#define MCLGETI(m, how, ifp, l) m_clget((m), (how), (ifp), (l))
|
|
||||||
|
|
||||||
/* MFREE(struct mbuf *m, struct mbuf *n)
|
|
||||||
* Free a single mbuf and associated external storage.
|
|
||||||
* Place the successor, if any, in n.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MFREE(m, n) n = m_free((m))
|
|
||||||
|
|
||||||
/* Move just m_pkthdr from from to to,
|
|
||||||
* remove M_PKTHDR and clean flags/tags for from.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_MOVE_HDR(to, from) do { \
|
|
||||||
(to)->m_pkthdr = (from)->m_pkthdr; \
|
|
||||||
(from)->m_flags &= ~M_PKTHDR; \
|
|
||||||
SLIST_INIT(&(from)->m_pkthdr.tags); \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
|
|
||||||
/* MOVE mbuf pkthdr from from to to.
|
|
||||||
* from must have M_PKTHDR set, and to must be empty.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_MOVE_PKTHDR(to, from) do { \
|
|
||||||
(to)->m_flags = ((to)->m_flags & (M_EXT | M_CLUSTER)); \
|
|
||||||
(to)->m_flags |= (from)->m_flags & M_COPYFLAGS; \
|
|
||||||
M_MOVE_HDR((to), (from)); \
|
|
||||||
if (((to)->m_flags & M_EXT) == 0) \
|
|
||||||
(to)->m_data = (to)->m_pktdat; \
|
|
||||||
} while (/* CONSTCOND */ 0)
|
|
||||||
|
|
||||||
/* Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
|
|
||||||
* an object of the specified size at the end of the mbuf, longword aligned.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_ALIGN(m, len) \
|
|
||||||
(m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1)
|
|
||||||
|
|
||||||
/* As above, for mbufs allocated with m_gethdr/MGETHDR
|
|
||||||
* or initialized by M_MOVE_PKTHDR.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MH_ALIGN(m, len) \
|
|
||||||
(m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1)
|
|
||||||
|
|
||||||
/* Determine if an mbuf's data area is read-only. This is true for
|
|
||||||
* non-cluster external storage and for clusters that are being
|
|
||||||
* referenced by more than one mbuf.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_READONLY(m) \
|
|
||||||
(((m)->m_flags & M_EXT) != 0 && \
|
|
||||||
(((m)->m_flags & M_CLUSTER) == 0 || MCLISREFERENCED(m)))
|
|
||||||
|
|
||||||
/* Compute the amount of space available
|
|
||||||
* before the current start of data in an mbuf.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_LEADINGSPACE(m) m_leadingspace(m)
|
|
||||||
|
|
||||||
/* Compute the amount of space available
|
|
||||||
* after the end of data in an mbuf.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_TRAILINGSPACE(m) m_trailingspace(m)
|
|
||||||
|
|
||||||
/* Arrange to prepend space of size plen to mbuf m.
|
|
||||||
* If a new mbuf must be allocated, how specifies whether to wait.
|
|
||||||
* If how is M_DONTWAIT and allocation fails, the original mbuf chain
|
|
||||||
* is freed and m is set to NULL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define M_PREPEND(m, plen, how) \
|
|
||||||
(m) = m_prepend((m), (plen), (how))
|
|
||||||
|
|
||||||
/* Length to m_copy to copy all */
|
|
||||||
|
|
||||||
#define M_COPYALL 1000000000
|
|
||||||
|
|
||||||
/* Compatibility with 4.3 */
|
|
||||||
|
|
||||||
#define m_copy(m, o, l) m_copym((m), (o), (l), M_DONTWAIT)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* Header at beginning of each mbuf: */
|
|
||||||
|
|
||||||
struct m_hdr
|
|
||||||
{
|
|
||||||
struct mbuf *mh_next; /* Next buffer in chain */
|
|
||||||
struct mbuf *mh_nextpkt; /* Next chain in queue/record */
|
|
||||||
char *mh_data; /* Location of data */
|
|
||||||
unsigned int mh_len; /* Amount of data in this mbuf */
|
|
||||||
short mh_type; /* Type of data in this mbuf */
|
|
||||||
unsigned short mh_flags; /* Flags; see below */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Record/packet header in first mbuf of chain; valid if M_PKTHDR set */
|
|
||||||
|
|
||||||
struct pkthdr
|
|
||||||
{
|
|
||||||
struct ifnet *rcvif; /* rcv interface */
|
|
||||||
int len; /* Total packet length */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Description of external storage mapped into mbuf, valid if M_EXT set */
|
|
||||||
|
|
||||||
struct mbuf_ext
|
|
||||||
{
|
|
||||||
char* ext_buf; /* start of buffer */
|
|
||||||
/* free routine if not the usual */
|
|
||||||
// void (*ext_free)();
|
|
||||||
// void *ext_arg; /* argument for ext_free */
|
|
||||||
// unsigned int ext_size; /* size of buffer, for ext_free */
|
|
||||||
unsigned int ext_size; /* size of buffer, for ext_free */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mbuf
|
|
||||||
{
|
|
||||||
struct m_hdr m_hdr;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
struct pkthdr MH_pkthdr; /* M_PKTHDR set */
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct mbuf_ext MH_ext; /* M_EXT set */
|
|
||||||
char MH_databuf[MHLEN];
|
|
||||||
} MH_dat;
|
|
||||||
} MH;
|
|
||||||
char M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */
|
|
||||||
} M_dat;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define m_next m_hdr.mh_next
|
|
||||||
#define m_len m_hdr.mh_len
|
|
||||||
#define m_data m_hdr.mh_data
|
|
||||||
#define m_type m_hdr.mh_type
|
|
||||||
#define m_flags m_hdr.mh_flags
|
|
||||||
#define m_nextpkt m_hdr.mh_nextpkt
|
|
||||||
#define m_act m_nextpkt
|
|
||||||
#define m_pkthdr M_dat.MH.MH_pkthdr
|
|
||||||
#define m_ext M_dat.MH.MH_dat.MH_ext
|
|
||||||
#define m_pktdat M_dat.MH.MH_dat.MH_databuf
|
|
||||||
#define m_dat M_dat.M_databuf
|
|
||||||
|
|
||||||
/* Mbuf statistics.
|
|
||||||
* For statistics related to mbuf and cluster allocations, see also the
|
|
||||||
* pool headers (mbpool and mclpool).
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct mbstat
|
|
||||||
{
|
|
||||||
unsigned long _m_spare; /* formerly m_mbufs */
|
|
||||||
unsigned long _m_spare1; /* formerly m_clusters */
|
|
||||||
unsigned long _m_spare2; /* spare field */
|
|
||||||
unsigned long _m_spare3; /* formely m_clfree - free clusters */
|
|
||||||
unsigned long m_drops; /* times failed to find space */
|
|
||||||
unsigned long m_wait; /* times waited for space */
|
|
||||||
unsigned long m_drain; /* times drained protocols for space */
|
|
||||||
unsigned short m_mtypes[256]; /* type specific mbuf allocations */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mclsizes
|
|
||||||
{
|
|
||||||
unsigned int size;
|
|
||||||
unsigned int hwm;
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern struct mbstat mbstat;
|
|
||||||
extern int nmbclust; /* limit on the # of clusters */
|
|
||||||
extern int mblowat; /* mbuf low water mark */
|
|
||||||
extern int mcllowat; /* mbuf cluster low water mark */
|
|
||||||
extern int max_linkhdr; /* largest link-level header */
|
|
||||||
extern int max_protohdr; /* largest protocol header */
|
|
||||||
extern int max_hdr; /* largest link+protocol header */
|
|
||||||
extern int max_datalen; /* MHLEN - max_hdr */
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void mbinit(void);
|
|
||||||
struct mbuf *m_copym2(struct mbuf *, int, int, int);
|
|
||||||
struct mbuf *m_copym(struct mbuf *, int, int, int);
|
|
||||||
struct mbuf *m_free(struct mbuf *);
|
|
||||||
struct mbuf *m_free_unlocked(struct mbuf *);
|
|
||||||
struct mbuf *m_get(int, int);
|
|
||||||
struct mbuf *m_getclr(int, int);
|
|
||||||
struct mbuf *m_gethdr(int, int);
|
|
||||||
struct mbuf *m_inithdr(struct mbuf *);
|
|
||||||
int m_defrag(struct mbuf *, int);
|
|
||||||
struct mbuf *m_prepend(struct mbuf *, int, int);
|
|
||||||
struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
|
|
||||||
struct mbuf *m_pullup(struct mbuf *, int);
|
|
||||||
struct mbuf *m_split(struct mbuf *, int, int);
|
|
||||||
struct mbuf *m_inject(struct mbuf *, int, int, int);
|
|
||||||
struct mbuf *m_getptr(struct mbuf *, int, int *);
|
|
||||||
int m_leadingspace(struct mbuf *);
|
|
||||||
int m_trailingspace(struct mbuf *);
|
|
||||||
struct mbuf *m_clget(struct mbuf *, int, struct ifnet *, unsigned int);
|
|
||||||
void m_clsetwms(struct ifnet *, unsigned int, unsigned int, unsigned int);
|
|
||||||
int m_cldrop(struct ifnet *, int);
|
|
||||||
void m_clcount(struct ifnet *, int);
|
|
||||||
void m_cluncount(struct mbuf *, int);
|
|
||||||
void m_clinitifp(struct ifnet *);
|
|
||||||
void m_adj(struct mbuf *, int);
|
|
||||||
int m_copyback(struct mbuf *, int, int, const void *, int);
|
|
||||||
void m_freem(struct mbuf *);
|
|
||||||
void m_reclaim(void *, int);
|
|
||||||
void m_copydata(struct mbuf *, int, int, char*);
|
|
||||||
void m_cat(struct mbuf *, struct mbuf *);
|
|
||||||
struct mbuf *m_devget(char *, int, int, struct ifnet *,
|
|
||||||
void (*)(const void *, void *, size_t));
|
|
||||||
void m_zero(struct mbuf *);
|
|
||||||
int m_apply(struct mbuf *, int, int,
|
|
||||||
int (*)(char*, char*, unsigned int), char*);
|
|
||||||
int m_dup_pkthdr(struct mbuf *, struct mbuf *, int);
|
|
||||||
|
|
||||||
/* Packet tag routines */
|
|
||||||
|
|
||||||
struct m_tag *m_tag_get(int, int, int);
|
|
||||||
void m_tag_prepend(struct mbuf *, struct m_tag *);
|
|
||||||
void m_tag_delete(struct mbuf *, struct m_tag *);
|
|
||||||
void m_tag_delete_chain(struct mbuf *);
|
|
||||||
struct m_tag *m_tag_find(struct mbuf *, int, struct m_tag *);
|
|
||||||
struct m_tag *m_tag_copy(struct m_tag *, int);
|
|
||||||
int m_tag_copy_chain(struct mbuf *, struct mbuf *, int);
|
|
||||||
void m_tag_init(struct mbuf *);
|
|
||||||
struct m_tag *m_tag_first(struct mbuf *);
|
|
||||||
struct m_tag *m_tag_next(struct mbuf *, struct m_tag *);
|
|
||||||
|
|
||||||
#endif /* __FS_NFS_RPC_MBUF_H */
|
|
||||||
|
|
@ -1,456 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* fs/nfs/rpc_subr.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
|
||||||
* Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
|
|
||||||
* Author: Jose Pablo Rojas Vargas <jrojas@nx-engineering.com>
|
|
||||||
*
|
|
||||||
* Leveraged from OpenBSD:
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995 Gordon Ross, Adam Glass
|
|
||||||
* Copyright (c) 1992 Regents of the University of California.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software was developed by the Computer Systems Engineering group
|
|
||||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
|
||||||
* contributed to Berkeley.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Lawrence Berkeley Laboratory and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "rpc_v2.h"
|
|
||||||
#include "rpc.h"
|
|
||||||
#include "xdr_subs.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#define MIN_REPLY_HDR 16 /* xid, dir, astat, errno */
|
|
||||||
|
|
||||||
/* What is the longest we will wait before re-sending a request?
|
|
||||||
* Note this is also the frequency of "RPC timeout" messages.
|
|
||||||
* The re-send loop count sup linearly to this maximum, so the
|
|
||||||
* first complaint will happen after (1+2+3+4+5)=15 seconds.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MAX_RESEND_DELAY 5 /* seconds */
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* Generic RPC headers */
|
|
||||||
|
|
||||||
struct auth_info
|
|
||||||
{
|
|
||||||
uint32_t authtype; /* auth type */
|
|
||||||
uint32_t authlen; /* auth length */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct auth_unix
|
|
||||||
{
|
|
||||||
int32_t ua_time;
|
|
||||||
int32_t ua_hostname; /* null */
|
|
||||||
int32_t ua_uid;
|
|
||||||
int32_t ua_gid;
|
|
||||||
int32_t ua_gidlist; /* null */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rpc_call
|
|
||||||
{
|
|
||||||
uint32_t rp_xid; /* request transaction id */
|
|
||||||
int32_t rp_direction; /* call direction (0) */
|
|
||||||
uint32_t rp_rpcvers; /* rpc version (2) */
|
|
||||||
uint32_t rp_prog; /* program */
|
|
||||||
uint32_t rp_vers; /* version */
|
|
||||||
uint32_t rp_proc; /* procedure */
|
|
||||||
struct auth_info rpc_auth;
|
|
||||||
struct auth_unix rpc_unix;
|
|
||||||
struct auth_info rpc_verf;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rpc_reply
|
|
||||||
{
|
|
||||||
uint32_t rp_xid; /* request transaction id */
|
|
||||||
int32_t rp_direction; /* call direction (1) */
|
|
||||||
int32_t rp_astatus; /* accept status (0: accepted) */
|
|
||||||
union
|
|
||||||
{
|
|
||||||
uint32_t rpu_errno;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
struct auth_info rok_auth;
|
|
||||||
uint32_t rok_status;
|
|
||||||
} rpu_rok;
|
|
||||||
} rp_u;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define rp_errno rp_u.rpu_errno
|
|
||||||
#define rp_auth rp_u.rpu_rok.rok_auth
|
|
||||||
#define rp_status rp_u.rpu_rok.rok_status
|
|
||||||
|
|
||||||
/* String representation for RPC. */
|
|
||||||
|
|
||||||
struct xdr_string
|
|
||||||
{
|
|
||||||
uint32_t len; /* length without null or padding */
|
|
||||||
char data[4]; /* data (longer, of course) */
|
|
||||||
/* data is padded to a long-word boundary */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Inet address in RPC messages (Note, really four ints, NOT chars. Blech.) */
|
|
||||||
|
|
||||||
struct xdr_inaddr
|
|
||||||
{
|
|
||||||
uint32_t atype;
|
|
||||||
uint32_t addr[4];
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* Call portmap to lookup a port number for a particular rpc program
|
|
||||||
* Returns non-zero error on failure.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int krpc_portmap(struct sockaddr_in *sin, unsigned int prog, unsigned int vers,
|
|
||||||
uint16_t * portp)
|
|
||||||
{
|
|
||||||
struct sdata
|
|
||||||
{
|
|
||||||
uint32_t prog; /* call program */
|
|
||||||
uint32_t vers; /* call version */
|
|
||||||
uint32_t proto; /* call protocol */
|
|
||||||
uint32_t port; /* call port (unused) */
|
|
||||||
} *sdata;
|
|
||||||
struct rdata
|
|
||||||
{
|
|
||||||
uint16_t pad;
|
|
||||||
uint16_t port;
|
|
||||||
} *rdata;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
/* The portmapper port is fixed. */
|
|
||||||
|
|
||||||
if (prog == PMAPPROG)
|
|
||||||
{
|
|
||||||
*portp = htons(PMAPPORT);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Do the RPC to get it. */
|
|
||||||
|
|
||||||
sdata->prog = txdr_unsigned(prog);
|
|
||||||
sdata->vers = txdr_unsigned(vers);
|
|
||||||
sdata->proto = txdr_unsigned(IPPROTO_UDP);
|
|
||||||
sdata->port = txdr_unsigned(0);
|
|
||||||
|
|
||||||
sin->sin_port = htons(PMAPPORT);
|
|
||||||
error = krpc_call(sin, PMAPPROG, PMAPVERS, PMAPPROC_GETPORT, NULL, -1);
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
*portp = rdata->port;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Do a remote procedure call (RPC) and wait for its reply.
|
|
||||||
* data: input/output
|
|
||||||
*/
|
|
||||||
|
|
||||||
int krpc_call(struct sockaddr_in *sa, unsigned int prog, unsigned int vers,
|
|
||||||
unsigned int func, struct sockaddr **from_p, int retries)
|
|
||||||
{
|
|
||||||
struct socket *so;
|
|
||||||
struct sockaddr_in *sin;
|
|
||||||
struct rpc_call *call;
|
|
||||||
struct rpc_reply *reply;
|
|
||||||
int error, rcvflg, timo, secs;
|
|
||||||
static uint32_t xid = 0;
|
|
||||||
struct timeval *tv;
|
|
||||||
uint16_t tport;
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
/* Validate address family.
|
|
||||||
* Sorry, this is INET specific...
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (sa->sin_family != AF_INET)
|
|
||||||
{
|
|
||||||
return (EAFNOSUPPORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create socket and set its receive timeout. */
|
|
||||||
|
|
||||||
if ((error = psock_socket(AF_INET, SOCK_DGRAM, 0, so)))
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
tv->tv_sec = 1;
|
|
||||||
tv->tv_usec = 0;
|
|
||||||
|
|
||||||
if ((error = psock_setsockopt(so, SOL_SOCKET, SO_RCVTIMEO,(const void *) tv, sizeof (*tv))))
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable broadcast if necessary. */
|
|
||||||
|
|
||||||
if (from_p)
|
|
||||||
{
|
|
||||||
int on = 1;
|
|
||||||
if ((error = psock_setsockopt(so, SOL_SOCKET, SO_BROADCAST, (const void *) on, sizeof (on))))
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Bind the local endpoint to a reserved port,
|
|
||||||
* because some NFS servers refuse requests from
|
|
||||||
* non-reserved (non-privileged) ports.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sin->sin_family = AF_INET;
|
|
||||||
sin->sin_addr.s_addr = INADDR_ANY;
|
|
||||||
tport = 1024;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
tport--;
|
|
||||||
sin->sin_port = htons(tport);
|
|
||||||
error = psock_bind(so, (struct sockaddr*) sin, sizeof(*sin));
|
|
||||||
}
|
|
||||||
while (error == EADDRINUSE && tport > 1024 / 2);
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
printf("bind failed\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup socket address for the server. */
|
|
||||||
|
|
||||||
memmove((void*)sin,(void*)sa, sizeof(*sa));
|
|
||||||
|
|
||||||
/* Prepend RPC message header. */
|
|
||||||
|
|
||||||
memset((void*) call, 0, sizeof(*call));
|
|
||||||
|
|
||||||
/* rpc_call part */
|
|
||||||
|
|
||||||
xid = rand();
|
|
||||||
call->rp_xid = txdr_unsigned(xid);
|
|
||||||
call->rp_direction = txdr_unsigned(0);
|
|
||||||
call->rp_rpcvers = txdr_unsigned(2);
|
|
||||||
call->rp_prog = txdr_unsigned(prog);
|
|
||||||
call->rp_vers = txdr_unsigned(vers);
|
|
||||||
call->rp_proc = txdr_unsigned(func);
|
|
||||||
|
|
||||||
/* rpc_auth part (auth_unix as root) */
|
|
||||||
|
|
||||||
call->rpc_auth.authtype = txdr_unsigned(RPCAUTH_UNIX);
|
|
||||||
call->rpc_auth.authlen = txdr_unsigned(sizeof(struct auth_unix));
|
|
||||||
|
|
||||||
/* rpc_verf part (auth_null) */
|
|
||||||
|
|
||||||
call->rpc_verf.authtype = 0;
|
|
||||||
call->rpc_verf.authlen = 0;
|
|
||||||
|
|
||||||
/* Send it, repeatedly, until a reply is received,
|
|
||||||
* but delay each re-send by an increasing amount.
|
|
||||||
* If the delay hits the maximum, start complaining.
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (timo = 0; retries; retries--)
|
|
||||||
{
|
|
||||||
/* Send RPC request (or re-send). */
|
|
||||||
|
|
||||||
error = psock_send(so, call, sizeof(*call), 0);
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
printf("krpc_call: psock_send: %d\n", error);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Determine new timeout. */
|
|
||||||
|
|
||||||
if (timo < MAX_RESEND_DELAY)
|
|
||||||
{
|
|
||||||
timo++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("RPC timeout for server %s (0x%x) prog %u\n",
|
|
||||||
inet_ntoa(sin->sin_addr), ntohl(sin->sin_addr.s_addr), prog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for up to timo seconds for a reply.
|
|
||||||
* The socket receive timeout was set to 1 second.
|
|
||||||
*/
|
|
||||||
|
|
||||||
secs = timo;
|
|
||||||
while (secs > 0)
|
|
||||||
{
|
|
||||||
rcvflg = 0;
|
|
||||||
error = psock_recvfrom(so, reply, sizeof(*reply), rcvflg, NULL, 0);
|
|
||||||
if (error == EWOULDBLOCK)
|
|
||||||
{
|
|
||||||
secs--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Is it the right reply? */
|
|
||||||
|
|
||||||
if (reply->rp_direction != txdr_unsigned(RPC_REPLY))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply->rp_xid != txdr_unsigned(xid))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Was RPC accepted? (authorization OK) */
|
|
||||||
|
|
||||||
if (reply->rp_astatus != 0)
|
|
||||||
{
|
|
||||||
error = fxdr_unsigned(uint32_t, reply->rp_errno);
|
|
||||||
printf("rpc denied, error=%d\n", error);
|
|
||||||
error = ECONNREFUSED;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Did the call succeed? */
|
|
||||||
|
|
||||||
if (reply->rp_status != 0)
|
|
||||||
{
|
|
||||||
error = fxdr_unsigned(uint32_t, reply->rp_status);
|
|
||||||
printf("rpc denied, status=%d\n", error);
|
|
||||||
error = ECONNREFUSED;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto gotsucreply; /* break two levels */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
error = ETIMEDOUT;
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
gotsucreply:
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
out:
|
|
||||||
(void)psock_close(so);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* eXternal Data Representation routines. (but with non-standard args...) */
|
|
||||||
|
|
||||||
void xdr_string_encode(char *str, int len)
|
|
||||||
{
|
|
||||||
struct xdr_string *xs;
|
|
||||||
|
|
||||||
xs->len = txdr_unsigned(len);
|
|
||||||
strncpy(xs->data, str, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdr_string_decode(char *str, int *len_p)
|
|
||||||
{
|
|
||||||
struct xdr_string *xs;
|
|
||||||
int slen; /* string length */
|
|
||||||
|
|
||||||
slen = fxdr_unsigned(uint32_t, xs->len);
|
|
||||||
|
|
||||||
if (slen > *len_p)
|
|
||||||
{
|
|
||||||
slen = *len_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
str[slen] = '\0';
|
|
||||||
*len_p = slen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdr_inaddr_encode(struct in_addr *ia)
|
|
||||||
{
|
|
||||||
struct xdr_inaddr *xi;
|
|
||||||
uint8_t *cp;
|
|
||||||
uint32_t *ip;
|
|
||||||
|
|
||||||
xi->atype = txdr_unsigned(1);
|
|
||||||
ip = xi->addr;
|
|
||||||
cp = (uint8_t *) & ia->s_addr;
|
|
||||||
*ip++ = txdr_unsigned(*cp++);
|
|
||||||
*ip++ = txdr_unsigned(*cp++);
|
|
||||||
*ip++ = txdr_unsigned(*cp++);
|
|
||||||
*ip++ = txdr_unsigned(*cp++);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xdr_inaddr_decode(struct in_addr *ia)
|
|
||||||
{
|
|
||||||
struct xdr_inaddr *xi;
|
|
||||||
uint8_t *cp;
|
|
||||||
uint32_t *ip;
|
|
||||||
|
|
||||||
ip = xi->addr;
|
|
||||||
cp = (uint8_t *) & ia->s_addr;
|
|
||||||
*cp++ = fxdr_unsigned(uint8_t, *ip++);
|
|
||||||
*cp++ = fxdr_unsigned(uint8_t, *ip++);
|
|
||||||
*cp++ = fxdr_unsigned(uint8_t, *ip++);
|
|
||||||
*cp++ = fxdr_unsigned(uint8_t, *ip++);
|
|
||||||
|
|
||||||
if (xi->atype != txdr_unsigned(1))
|
|
||||||
{
|
|
||||||
ia->s_addr = INADDR_ANY;
|
|
||||||
}
|
|
||||||
}
|
|
@ -59,35 +59,33 @@ struct lock
|
|||||||
int dummy;
|
int dummy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct iovec
|
typedef struct { int32_t val[2]; } fsid_t; /* file system id type */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File identifier.
|
||||||
|
* These are unique per filesystem on a single machine.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAXFIDSZ 16
|
||||||
|
|
||||||
|
struct fid
|
||||||
{
|
{
|
||||||
void *iov_base; /* Base address. */
|
unsigned short fid_len; /* length of data in bytes */
|
||||||
size_t iov_len; /* Length. */
|
unsigned short fid_reserved; /* force longword alignment */
|
||||||
|
char fid_data[MAXFIDSZ]; /* data (variable length) */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum uio_rw
|
/*
|
||||||
|
* Generic file handle
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct fhandle
|
||||||
{
|
{
|
||||||
UIO_READ,
|
fsid_t fh_fsid; /* File system id of mount point */
|
||||||
UIO_WRITE
|
struct fid fh_fid; /* File sys specific id */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Segment flag values. */
|
typedef struct fhandle fhandle_t;
|
||||||
|
|
||||||
enum uio_seg
|
|
||||||
{
|
|
||||||
UIO_USERSPACE, /* from user data space */
|
|
||||||
UIO_SYSSPACE /* from system space */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct uio
|
|
||||||
{
|
|
||||||
struct iovec *uio_iov; /* scatter/gather list */
|
|
||||||
int uio_iovcnt; /* length of scatter/gather list */
|
|
||||||
off_t uio_offset; /* offset in target object */
|
|
||||||
ssize_t uio_resid; /* remaining bytes to process */
|
|
||||||
enum uio_seg uio_segflg; /* address space */
|
|
||||||
enum uio_rw uio_rw; /* operation */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct componentname
|
struct componentname
|
||||||
{
|
{
|
||||||
|
@ -92,12 +92,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define fxdr_hyper(f) \
|
#define fxdr_hyper(f) \
|
||||||
((((uint64_t)ntohl(((u_int32_t *)(f))[0])) << 32) | \
|
((((uint64_t)ntohl(((uint32_t *)(f))[0])) << 32) | \
|
||||||
(uint64_t)(ntohl(((u_int32_t *)(f))[1])))
|
(uint64_t)(ntohl(((uint32_t *)(f))[1])))
|
||||||
|
|
||||||
#define txdr_hyper(f, t) { \
|
#define txdr_hyper(f, t) { \
|
||||||
((u_int32_t *)(t))[0] = htonl((u_int32_t)((f) >> 32)); \
|
((uint32_t *)(t))[0] = htonl((uint32_t)((f) >> 32)); \
|
||||||
((u_int32_t *)(t))[1] = htonl((u_int32_t)((f) & 0xffffffff)); \
|
((uint32_t *)(t))[1] = htonl((uint32_t)((f) & 0xffffffff)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __FS_NFS_XDR_SUBS_H */
|
#endif /* __FS_NFS_XDR_SUBS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user