summaryrefslogtreecommitdiffstats
path: root/nuttx/fs/nfs
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-06-10 01:16:46 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-06-10 01:16:46 +0000
commit509c5ce9761e4f5551b1b281ea7131f7d464cf4b (patch)
tree85d140be8017d4b97fcf1f6cc103d39aa115acb3 /nuttx/fs/nfs
parentebc2c1d3e4aa4ac56f4d5b465117cd16507a7c64 (diff)
NFS update
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4823 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/fs/nfs')
-rw-r--r--nuttx/fs/nfs/nfs_util.c36
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c4
-rw-r--r--nuttx/fs/nfs/xdr_subs.h2
3 files changed, 30 insertions, 12 deletions
diff --git a/nuttx/fs/nfs/nfs_util.c b/nuttx/fs/nfs/nfs_util.c
index c07c6e5193..e9d7ac8637 100644
--- a/nuttx/fs/nfs/nfs_util.c
+++ b/nuttx/fs/nfs/nfs_util.c
@@ -312,6 +312,8 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
{
struct LOOKUP3args request;
struct rpc_reply_lookup response;
+ uint32_t *ptr;
+ uint32_t value;
int namelen;
int error = 0;
@@ -321,8 +323,8 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
memset(&request, 0, sizeof(struct LOOKUP3args));
memset(&response, 0, sizeof(struct rpc_reply_lookup));
- memset(&obj_attributes, 0, sizeof(struct nfs_fattr));
- memset(&dir_attributes, 0, sizeof(struct nfs_fattr));
+ memset(obj_attributes, 0, sizeof(struct nfs_fattr));
+ memset(dir_attributes, 0, sizeof(struct nfs_fattr));
/* Get the length of the string to be sent */
@@ -352,20 +354,34 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
return error;
}
- /* Return the data to the caller's buffers */
+ /* Return the data to the caller's buffers. NOTE: Here we ignore the
+ * the exact layout of the rpc_reply_lookup structure. File handles
+ * may differ in size whereas struct rpc_reply_lookup uses a fixed size.
+ */
+
+ ptr = (uint32_t*)&response.lookup;
- memcpy(fhandle, &response.lookup.fshandle, sizeof(struct file_handle));
+ /* Get the length of the file handle and return the file handle */
- if (response.lookup.obj_attributes_follow != 0)
+ value = txdr_unsigned(*ptr) + sizeof(uint32_t);
+ memcpy(fhandle, ptr, value);
+ ptr += uint32_increment(value);
+
+ /* Check if there are object attributes and, if so, copy them to the user buffer */
+
+ value = *ptr++;
+ if (value)
{
- memcpy(obj_attributes, &response.lookup.obj_attributes,
- sizeof(struct nfs_fattr));
+ memcpy(obj_attributes, ptr, sizeof(struct nfs_fattr));
+ ptr += uint32_increment(sizeof(struct nfs_fattr));
}
- if (response.lookup.dir_attributes_follow != 0)
+ /* Check if there are directory attributes and, if so, copy them to the user buffer */
+
+ value = *ptr++;
+ if (value)
{
- memcpy(dir_attributes, &response.lookup.dir_attributes,
- sizeof(struct nfs_fattr));
+ memcpy(dir_attributes, ptr, sizeof(struct nfs_fattr));
}
return OK;
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index c3268efbf5..ad41005399 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -936,7 +936,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
* now points to the cookie.
*/
- ptr += (length + 3) >> 2;
+ ptr += uint32_increment(length);
/* Save the cookie and increment the pointer to the next entry */
@@ -972,7 +972,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
/* Set the dirent file type */
- switch (obj_attributes.fa_type)
+ switch (fxdr_unsigned(uint32_t, obj_attributes.fa_type))
{
default:
case NFNON: /* Unknown type */
diff --git a/nuttx/fs/nfs/xdr_subs.h b/nuttx/fs/nfs/xdr_subs.h
index 9c36a69e7b..a952491184 100644
--- a/nuttx/fs/nfs/xdr_subs.h
+++ b/nuttx/fs/nfs/xdr_subs.h
@@ -118,4 +118,6 @@
((uint32_t *)(t))[1] = htonl((uint32_t)((f) & 0xffffffff)); \
}
+#define uint32_increment(b) (((b) + 3) >> 2)
+
#endif /* __FS_NFS_XDR_SUBS_H */