summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-10 01:16:46 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-10 01:16:46 +0000
commit16efc815bddec5f830a35316aeb4080f112dc554 (patch)
tree85d140be8017d4b97fcf1f6cc103d39aa115acb3
parente56f40210903c13eb07168de2acdf61c8babd2ae (diff)
downloadpx4-nuttx-16efc815bddec5f830a35316aeb4080f112dc554.tar.gz
px4-nuttx-16efc815bddec5f830a35316aeb4080f112dc554.tar.bz2
px4-nuttx-16efc815bddec5f830a35316aeb4080f112dc554.zip
NFS update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4823 42af7a65-404d-4744-a932-0658087f49c3
-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 c07c6e519..e9d7ac863 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 c3268efbf..ad4100539 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 9c36a69e7..a95249118 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 */