mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 14:47:44 +08:00
NFS update
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4827 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
+1
-1
@@ -374,7 +374,7 @@ EXTERN int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath,
|
||||
FAR struct nfs_fattr *dir_attributes);
|
||||
EXTERN int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
|
||||
FAR struct file_handle *fhandle,
|
||||
FAR struct nfs_fattr *attributes);
|
||||
FAR struct nfs_fattr *attributes, FAR char *filename);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
||||
@@ -54,10 +54,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Convert mount ptr to nfsmount ptr. */
|
||||
|
||||
#define VFSTONFS(mp) ((struct nfsmount *)((mp)->i_private))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
+50
-152
@@ -187,27 +187,6 @@
|
||||
#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 */
|
||||
|
||||
@@ -274,17 +253,11 @@
|
||||
|
||||
/* 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]
|
||||
|
||||
#define NFS_MAXFHSIZE 64
|
||||
|
||||
/* Mode bit values */
|
||||
|
||||
@@ -356,17 +329,11 @@ typedef struct fhandle fhandle_t;
|
||||
|
||||
struct nfsfh
|
||||
{
|
||||
uint8_t fh_bytes[NFSX_V2FH];
|
||||
uint8_t fh_bytes[NFSX_V3FHMAX];
|
||||
};
|
||||
typedef struct nfsfh nfsfh_t;
|
||||
#define SIZEOF_nfsfh_t(n) (n)
|
||||
|
||||
struct nfsv2_time
|
||||
{
|
||||
uint32_t nfsv2_sec;
|
||||
uint32_t nfsv2_usec;
|
||||
};
|
||||
typedef struct nfsv2_time nfstime2;
|
||||
|
||||
struct nfsv3_time
|
||||
{
|
||||
@@ -405,125 +372,54 @@ typedef struct nfsv3_spec nfsv3spec;
|
||||
|
||||
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;
|
||||
uint32_t fa_type;
|
||||
uint32_t fa_mode;
|
||||
uint32_t fa_nlink;
|
||||
uint32_t fa_uid;
|
||||
uint32_t fa_gid;
|
||||
nfsuint64 fa_size;
|
||||
nfsuint64 fa_used;
|
||||
nfsv3spec fa_rdev;
|
||||
nfsuint64 fa_fsid;
|
||||
nfsuint64 fa_fileid;
|
||||
nfstime3 fa_atime;
|
||||
nfstime3 fa_mtime;
|
||||
nfstime3 fa_ctime;
|
||||
};
|
||||
|
||||
/* 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. */
|
||||
/* NFS Version 3 sattr structure for the new node creation case. This is the
|
||||
* maximum size of the attributes; the actual size may vary if values are not
|
||||
* include.
|
||||
*/
|
||||
|
||||
struct nfsv3_sattr
|
||||
{
|
||||
uint32_t sa_modetrue;
|
||||
uint32_t sa_mode;
|
||||
uint32_t sa_uidfalse;
|
||||
//uint32_t sa_uid;
|
||||
uint32_t sa_gidfalse;
|
||||
//uint32_t sa_gid;
|
||||
uint32_t sa_sizefalse;
|
||||
uint32_t sa_atimetype;
|
||||
//nfstime3 sa_atime;
|
||||
uint32_t sa_mtimetype;
|
||||
//nfstime3 sa_mtime;
|
||||
uint32_t sa_modefollows; /* TRUE: Mode value follows */
|
||||
uint32_t sa_mode; /* Mode value */
|
||||
uint32_t sa_uidfollows; /* TRUE: Uid value follows */
|
||||
uint32_t sa_uid; /* Uid value */
|
||||
uint32_t sa_gidfollows; /* TRUE: Mode value follows */
|
||||
uint32_t sa_gid; /* Mode value */
|
||||
uint32_t sa_sizefollows; /* TRUE: Size value follows */
|
||||
uint32_t sa_size; /* Size value */
|
||||
uint32_t sa_atimetype; /* Don't change, use server timer, or use client time */
|
||||
nfstime3 sa_atime; /* Client time */
|
||||
uint32_t sa_mtimetype; /* Don't change, use server timer, or use client time */
|
||||
nfstime3 sa_mtime; /* Client time */
|
||||
};
|
||||
|
||||
struct nfs_statfs
|
||||
{
|
||||
struct nfs_fattr obj_attributes;
|
||||
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;
|
||||
nfsuint64 sf_tbytes;
|
||||
nfsuint64 sf_fbytes;
|
||||
nfsuint64 sf_abytes;
|
||||
nfsuint64 sf_tfiles;
|
||||
nfsuint64 sf_ffiles;
|
||||
nfsuint64 sf_afiles;
|
||||
uint32_t sf_invarsec;
|
||||
};
|
||||
|
||||
/*#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 post_attr
|
||||
{
|
||||
uint32_t obj_attributesfalse;
|
||||
@@ -570,9 +466,9 @@ struct file_handle
|
||||
|
||||
struct diropargs3
|
||||
{
|
||||
struct file_handle dir;
|
||||
uint32_t length;
|
||||
char name[64];
|
||||
struct file_handle fhandle; /* Variable length */
|
||||
uint32_t length; /* Size of name[] */
|
||||
uint32_t name[(NAME_MAX+3) >> 2]; /* Variable length */
|
||||
};
|
||||
|
||||
struct CREATE3args
|
||||
@@ -584,8 +480,10 @@ struct CREATE3args
|
||||
|
||||
struct CREATE3resok
|
||||
{
|
||||
struct file_handle fshandle;
|
||||
struct nfs_fattr attributes;
|
||||
uint32_t handle_follows; /* True, handle follows */
|
||||
struct file_handle fhandle; /* Variable length */
|
||||
uint32_t attributes_follows; /* True, attributes follows */
|
||||
struct nfs_fattr attributes; /* File attributes */
|
||||
struct wcc_data dir_wcc;
|
||||
};
|
||||
|
||||
@@ -595,7 +493,7 @@ struct CREATE3resok
|
||||
|
||||
struct LOOKUP3filename
|
||||
{
|
||||
uint32_t namelen; /* Size name */
|
||||
uint32_t namelen; /* Size of name[] */
|
||||
uint32_t name[(NAME_MAX+3) >> 2]; /* Variable length */
|
||||
};
|
||||
|
||||
@@ -612,7 +510,7 @@ struct LOOKUP3args
|
||||
|
||||
struct LOOKUP3resok
|
||||
{
|
||||
struct file_handle fshandle;
|
||||
struct file_handle fhandle;
|
||||
uint32_t obj_attributes_follow;
|
||||
struct nfs_fattr obj_attributes;
|
||||
uint32_t dir_attributes_follow;
|
||||
@@ -621,7 +519,7 @@ struct LOOKUP3resok
|
||||
|
||||
struct READ3args
|
||||
{
|
||||
struct file_handle fshandle; /* Variable length */
|
||||
struct file_handle fhandle; /* Variable length */
|
||||
uint64_t offset;
|
||||
uint32_t count;
|
||||
};
|
||||
@@ -644,7 +542,7 @@ struct READ3resok
|
||||
|
||||
struct nfs_wrhdr_s
|
||||
{
|
||||
struct file_handle fshandle; /* Variable length */
|
||||
struct file_handle fhandle; /* Variable length */
|
||||
uint64_t offset;
|
||||
uint32_t count;
|
||||
uint32_t stable;
|
||||
@@ -695,7 +593,7 @@ struct MKDIR3args
|
||||
|
||||
struct MKDIR3resok
|
||||
{
|
||||
struct file_handle fshandle;
|
||||
struct file_handle fhandle;
|
||||
uint32_t obj_attributesfalse;
|
||||
struct nfs_fattr obj_attributes;
|
||||
struct wcc_data dir_wcc;
|
||||
|
||||
@@ -540,10 +540,9 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath,
|
||||
|
||||
int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
|
||||
FAR struct file_handle *fhandle,
|
||||
FAR struct nfs_fattr *attributes)
|
||||
FAR struct nfs_fattr *attributes, FAR char *filename)
|
||||
{
|
||||
FAR const char *path = relpath;
|
||||
char buffer[NAME_MAX+1];
|
||||
uint32_t tmp;
|
||||
char terminator;
|
||||
int error;
|
||||
@@ -569,13 +568,13 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
|
||||
{
|
||||
/* Extract the next path segment name. */
|
||||
|
||||
error = nfs_pathsegment(&path, buffer, &terminator);
|
||||
error = nfs_pathsegment(&path, filename, &terminator);
|
||||
if (error != 0)
|
||||
{
|
||||
/* The filename segment contains is too long. */
|
||||
|
||||
fdbg("nfs_pathsegment of \"%s\" failed after \"%s\": %d\n",
|
||||
relpath, buffer, error);
|
||||
relpath, filename, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -595,11 +594,11 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
|
||||
|
||||
/* Look-up the next path segment */
|
||||
|
||||
error = nfs_lookup(nmp, buffer, fhandle, attributes, NULL);
|
||||
error = nfs_lookup(nmp, filename, fhandle, attributes, NULL);
|
||||
if (error != 0)
|
||||
{
|
||||
fdbg("nfs_lookup of \"%s\" failed at \"%s\": %d\n",
|
||||
relpath, buffer, error);
|
||||
relpath, filename, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -611,7 +610,7 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
|
||||
/* Ooops.. we found something else */
|
||||
|
||||
fdbg("ERROR: Intermediate segment \"%s\" of \'%s\" is not a directory\n",
|
||||
buffer, path);
|
||||
filename, path);
|
||||
return ENOTDIR;
|
||||
}
|
||||
}
|
||||
|
||||
+295
-170
File diff suppressed because it is too large
Load Diff
+11
-28
@@ -189,8 +189,6 @@ static uint32_t rpc_auth_null;
|
||||
|
||||
int rpcclnt_ticks;
|
||||
struct rpcstats rpcstats;
|
||||
//struct rpc_call *callmgs;
|
||||
//struct rpc_reply *replymsg;
|
||||
|
||||
/* Queue head for rpctask's */
|
||||
|
||||
@@ -658,7 +656,7 @@ static int rpcclnt_reply(struct rpctask *myrep, int procid, int prog,
|
||||
return 0;
|
||||
}
|
||||
|
||||
fdbg("ignoring routing error on connectionless protocol\n");
|
||||
fdbg("Ignoring routing error on connectionless protocol\n");
|
||||
continue;
|
||||
}
|
||||
return error;
|
||||
@@ -980,10 +978,10 @@ static void rpcclnt_fmtheader(FAR struct rpc_call_header *ch,
|
||||
ch->rp_vers = txdr_unsigned(vers);
|
||||
ch->rp_proc = txdr_unsigned(procid);
|
||||
|
||||
/* rpc_auth part (auth_unix as root) */
|
||||
/* rpc_auth part (auth_null) */
|
||||
|
||||
ch->rpc_auth.authtype = rpc_auth_null;
|
||||
//call->rpc_auth.authlen = 0;
|
||||
|
||||
#ifdef CONFIG_NFS_UNIX_AUTH
|
||||
ch->rpc_unix.stamp = txdr_unsigned(1);
|
||||
ch->rpc_unix.hostname = 0;
|
||||
@@ -991,10 +989,10 @@ static void rpcclnt_fmtheader(FAR struct rpc_call_header *ch,
|
||||
ch->rpc_unix.gid = setgid;
|
||||
ch->rpc_unix.gidlist = 0;
|
||||
#endif
|
||||
|
||||
/* rpc_verf part (auth_null) */
|
||||
|
||||
ch->rpc_verf.authtype = rpc_auth_null;
|
||||
//call->rpc_verf.authlen = 0;
|
||||
}
|
||||
|
||||
/* Build the RPC header and fill in the authorization info. */
|
||||
@@ -1029,24 +1027,6 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
value->xid = callmsg->ch.rp_xid;
|
||||
return 0;
|
||||
}
|
||||
else if (procid == PMAPPROC_UNSET)
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_pmap *callmsg = (struct rpc_call_pmap *)msgbuf;;
|
||||
memcpy(&callmsg->pmap, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct call_args_pmap));
|
||||
*reqlen = sizeof(struct rpc_call_pmap);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
value->xid = callmsg->ch.rp_xid;
|
||||
return 0;
|
||||
@@ -1097,15 +1077,18 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
|
||||
{
|
||||
case NFSPROC_CREATE:
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
/* Copy the variable length, caller-provided data into the call
|
||||
* message structure.
|
||||
*/
|
||||
|
||||
struct rpc_call_create *callmsg = (struct rpc_call_create *)msgbuf;
|
||||
memcpy(&callmsg->create, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct CREATE3args));
|
||||
*reqlen = sizeof(struct rpc_call_create);
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user