NFS update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4827 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-06-11 17:14:46 +00:00
parent 5471665ce7
commit 1449f429dd
6 changed files with 363 additions and 362 deletions
+1 -1
View File
@@ -374,7 +374,7 @@ EXTERN int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath,
FAR struct nfs_fattr *dir_attributes); FAR struct nfs_fattr *dir_attributes);
EXTERN int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath, EXTERN int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
FAR struct file_handle *fhandle, FAR struct file_handle *fhandle,
FAR struct nfs_fattr *attributes); FAR struct nfs_fattr *attributes, FAR char *filename);
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
-4
View File
@@ -54,10 +54,6 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Convert mount ptr to nfsmount ptr. */
#define VFSTONFS(mp) ((struct nfsmount *)((mp)->i_private))
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
+49 -151
View File
@@ -187,27 +187,6 @@
#define NFSPROC_NOOP 22 #define NFSPROC_NOOP 22
#define NFS_NPROCS 23 #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 */ /* Constants used by the Version 3 protocol for various RPCs */
@@ -274,17 +253,11 @@
/* Conversion macros */ /* 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 vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&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 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 nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
#define NFS_MAXFHSIZE 64
/* Mode bit values */ /* Mode bit values */
@@ -356,17 +329,11 @@ typedef struct fhandle fhandle_t;
struct nfsfh struct nfsfh
{ {
uint8_t fh_bytes[NFSX_V2FH]; uint8_t fh_bytes[NFSX_V3FHMAX];
}; };
typedef struct nfsfh nfsfh_t; typedef struct nfsfh nfsfh_t;
#define SIZEOF_nfsfh_t(n) (n) #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 struct nfsv3_time
{ {
@@ -405,125 +372,54 @@ typedef struct nfsv3_spec nfsv3spec;
struct nfs_fattr struct nfs_fattr
{ {
uint32_t fa_type; uint32_t fa_type;
uint32_t fa_mode; uint32_t fa_mode;
uint32_t fa_nlink; uint32_t fa_nlink;
uint32_t fa_uid; uint32_t fa_uid;
uint32_t fa_gid; uint32_t fa_gid;
union nfsuint64 fa_size;
{ nfsuint64 fa_used;
/*struct nfsv3spec fa_rdev;
{ nfsuint64 fa_fsid;
uint32_t nfsv2fa_size; nfsuint64 fa_fileid;
uint32_t nfsv2fa_blocksize; nfstime3 fa_atime;
uint32_t nfsv2fa_rdev; nfstime3 fa_mtime;
uint32_t nfsv2fa_blocks; nfstime3 fa_ctime;
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 */ /* 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
/*#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size * include.
#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 struct nfsv3_sattr
{ {
uint32_t sa_modetrue; uint32_t sa_modefollows; /* TRUE: Mode value follows */
uint32_t sa_mode; uint32_t sa_mode; /* Mode value */
uint32_t sa_uidfalse; uint32_t sa_uidfollows; /* TRUE: Uid value follows */
//uint32_t sa_uid; uint32_t sa_uid; /* Uid value */
uint32_t sa_gidfalse; uint32_t sa_gidfollows; /* TRUE: Mode value follows */
//uint32_t sa_gid; uint32_t sa_gid; /* Mode value */
uint32_t sa_sizefalse; uint32_t sa_sizefollows; /* TRUE: Size value follows */
uint32_t sa_atimetype; uint32_t sa_size; /* Size value */
//nfstime3 sa_atime; uint32_t sa_atimetype; /* Don't change, use server timer, or use client time */
uint32_t sa_mtimetype; nfstime3 sa_atime; /* Client time */
//nfstime3 sa_mtime; uint32_t sa_mtimetype; /* Don't change, use server timer, or use client time */
nfstime3 sa_mtime; /* Client time */
}; };
struct nfs_statfs struct nfs_statfs
{ {
struct nfs_fattr obj_attributes; struct nfs_fattr obj_attributes;
union nfsuint64 sf_tbytes;
{ nfsuint64 sf_fbytes;
/*struct nfsuint64 sf_abytes;
{ nfsuint64 sf_tfiles;
uint32_t nfsv2sf_tsize; nfsuint64 sf_ffiles;
uint32_t nfsv2sf_bsize; nfsuint64 sf_afiles;
uint32_t nfsv2sf_blocks; uint32_t sf_invarsec;
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 post_attr struct post_attr
{ {
uint32_t obj_attributesfalse; uint32_t obj_attributesfalse;
@@ -570,9 +466,9 @@ struct file_handle
struct diropargs3 struct diropargs3
{ {
struct file_handle dir; struct file_handle fhandle; /* Variable length */
uint32_t length; uint32_t length; /* Size of name[] */
char name[64]; uint32_t name[(NAME_MAX+3) >> 2]; /* Variable length */
}; };
struct CREATE3args struct CREATE3args
@@ -584,8 +480,10 @@ struct CREATE3args
struct CREATE3resok struct CREATE3resok
{ {
struct file_handle fshandle; uint32_t handle_follows; /* True, handle follows */
struct nfs_fattr attributes; struct file_handle fhandle; /* Variable length */
uint32_t attributes_follows; /* True, attributes follows */
struct nfs_fattr attributes; /* File attributes */
struct wcc_data dir_wcc; struct wcc_data dir_wcc;
}; };
@@ -595,7 +493,7 @@ struct CREATE3resok
struct LOOKUP3filename struct LOOKUP3filename
{ {
uint32_t namelen; /* Size name */ uint32_t namelen; /* Size of name[] */
uint32_t name[(NAME_MAX+3) >> 2]; /* Variable length */ uint32_t name[(NAME_MAX+3) >> 2]; /* Variable length */
}; };
@@ -612,7 +510,7 @@ struct LOOKUP3args
struct LOOKUP3resok struct LOOKUP3resok
{ {
struct file_handle fshandle; struct file_handle fhandle;
uint32_t obj_attributes_follow; uint32_t obj_attributes_follow;
struct nfs_fattr obj_attributes; struct nfs_fattr obj_attributes;
uint32_t dir_attributes_follow; uint32_t dir_attributes_follow;
@@ -621,7 +519,7 @@ struct LOOKUP3resok
struct READ3args struct READ3args
{ {
struct file_handle fshandle; /* Variable length */ struct file_handle fhandle; /* Variable length */
uint64_t offset; uint64_t offset;
uint32_t count; uint32_t count;
}; };
@@ -644,7 +542,7 @@ struct READ3resok
struct nfs_wrhdr_s struct nfs_wrhdr_s
{ {
struct file_handle fshandle; /* Variable length */ struct file_handle fhandle; /* Variable length */
uint64_t offset; uint64_t offset;
uint32_t count; uint32_t count;
uint32_t stable; uint32_t stable;
@@ -695,7 +593,7 @@ struct MKDIR3args
struct MKDIR3resok struct MKDIR3resok
{ {
struct file_handle fshandle; struct file_handle fhandle;
uint32_t obj_attributesfalse; uint32_t obj_attributesfalse;
struct nfs_fattr obj_attributes; struct nfs_fattr obj_attributes;
struct wcc_data dir_wcc; struct wcc_data dir_wcc;
+6 -7
View File
@@ -540,10 +540,9 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath,
int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath, int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
FAR struct file_handle *fhandle, FAR struct file_handle *fhandle,
FAR struct nfs_fattr *attributes) FAR struct nfs_fattr *attributes, FAR char *filename)
{ {
FAR const char *path = relpath; FAR const char *path = relpath;
char buffer[NAME_MAX+1];
uint32_t tmp; uint32_t tmp;
char terminator; char terminator;
int error; int error;
@@ -569,13 +568,13 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
{ {
/* Extract the next path segment name. */ /* Extract the next path segment name. */
error = nfs_pathsegment(&path, buffer, &terminator); error = nfs_pathsegment(&path, filename, &terminator);
if (error != 0) if (error != 0)
{ {
/* The filename segment contains is too long. */ /* The filename segment contains is too long. */
fdbg("nfs_pathsegment of \"%s\" failed after \"%s\": %d\n", fdbg("nfs_pathsegment of \"%s\" failed after \"%s\": %d\n",
relpath, buffer, error); relpath, filename, error);
return error; return error;
} }
@@ -595,11 +594,11 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
/* Look-up the next path segment */ /* 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) if (error != 0)
{ {
fdbg("nfs_lookup of \"%s\" failed at \"%s\": %d\n", fdbg("nfs_lookup of \"%s\" failed at \"%s\": %d\n",
relpath, buffer, error); relpath, filename, error);
return error; return error;
} }
@@ -611,7 +610,7 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
/* Ooops.. we found something else */ /* Ooops.. we found something else */
fdbg("ERROR: Intermediate segment \"%s\" of \'%s\" is not a directory\n", fdbg("ERROR: Intermediate segment \"%s\" of \'%s\" is not a directory\n",
buffer, path); filename, path);
return ENOTDIR; return ENOTDIR;
} }
} }
+295 -170
View File
File diff suppressed because it is too large Load Diff
+11 -28
View File
@@ -189,8 +189,6 @@ static uint32_t rpc_auth_null;
int rpcclnt_ticks; int rpcclnt_ticks;
struct rpcstats rpcstats; struct rpcstats rpcstats;
//struct rpc_call *callmgs;
//struct rpc_reply *replymsg;
/* Queue head for rpctask's */ /* Queue head for rpctask's */
@@ -658,7 +656,7 @@ static int rpcclnt_reply(struct rpctask *myrep, int procid, int prog,
return 0; return 0;
} }
fdbg("ignoring routing error on connectionless protocol\n"); fdbg("Ignoring routing error on connectionless protocol\n");
continue; continue;
} }
return error; return error;
@@ -980,10 +978,10 @@ static void rpcclnt_fmtheader(FAR struct rpc_call_header *ch,
ch->rp_vers = txdr_unsigned(vers); ch->rp_vers = txdr_unsigned(vers);
ch->rp_proc = txdr_unsigned(procid); 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; ch->rpc_auth.authtype = rpc_auth_null;
//call->rpc_auth.authlen = 0;
#ifdef CONFIG_NFS_UNIX_AUTH #ifdef CONFIG_NFS_UNIX_AUTH
ch->rpc_unix.stamp = txdr_unsigned(1); ch->rpc_unix.stamp = txdr_unsigned(1);
ch->rpc_unix.hostname = 0; 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.gid = setgid;
ch->rpc_unix.gidlist = 0; ch->rpc_unix.gidlist = 0;
#endif #endif
/* rpc_verf part (auth_null) */ /* rpc_verf part (auth_null) */
ch->rpc_verf.authtype = rpc_auth_null; ch->rpc_verf.authtype = rpc_auth_null;
//call->rpc_verf.authlen = 0;
} }
/* Build the RPC header and fill in the authorization info. */ /* 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 */ /* 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); rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
value->xid = callmsg->ch.rp_xid; value->xid = callmsg->ch.rp_xid;
return 0; return 0;
@@ -1097,15 +1077,18 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
{ {
case NFSPROC_CREATE: 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; struct rpc_call_create *callmsg = (struct rpc_call_create *)msgbuf;
memcpy(&callmsg->create, request, *reqlen); 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_header);
*reqlen = sizeof(struct rpc_call_create);
/* Format the message header */ /* Format the message header */