summaryrefslogtreecommitdiff
path: root/nuttx/fs/nfs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-14 21:54:50 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-14 21:54:50 +0000
commit6d538ea469affc6b33254109c3c2b65c24c14e5d (patch)
tree674689e2c7da31b70ca838eeceed0ec4996276d2 /nuttx/fs/nfs
parent8f09b6e49a22230c26f0af2f7b20a0bf10ca8e9b (diff)
downloadpx4-nuttx-6d538ea469affc6b33254109c3c2b65c24c14e5d.tar.gz
px4-nuttx-6d538ea469affc6b33254109c3c2b65c24c14e5d.tar.bz2
px4-nuttx-6d538ea469affc6b33254109c3c2b65c24c14e5d.zip
Add NFS rewinddir support; fixe some NFS warnings
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4844 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/nfs')
-rw-r--r--nuttx/fs/nfs/nfs.h35
-rw-r--r--nuttx/fs/nfs/nfs_mount.h4
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c75
3 files changed, 77 insertions, 37 deletions
diff --git a/nuttx/fs/nfs/nfs.h b/nuttx/fs/nfs/nfs.h
index b35ef2c8d..dfff4a96d 100644
--- a/nuttx/fs/nfs/nfs.h
+++ b/nuttx/fs/nfs/nfs.h
@@ -47,39 +47,32 @@
/****************************************************************************
* Included Files
****************************************************************************/
-
+
#include "nfs_mount.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#if MSEC_PER_TICK <= 5
-# define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
-# define NFS_TICKS (CLOCKS_PER_SEC * NFS_TICKINTVL + 500) / 1000
-# define NFS_HZ (CLOCKS_PER_SEC / NFS_TICKS) /* Ticks/sec */
-#else
-# define NFS_TICKINTVL MSEC_PER_TICK /* Smallest that we can get */
-# define NFS_TICKS 1 /* Number of system ticks */
-# define NFS_HZ CLOCKS_PER_SEC /* Ticks/sec */
-#endif
-
-#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_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_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_TICKINTVL MSEC_PER_TICK /* Smallest that we can get */
+#define NFS_TICKS 1 /* Number of system ticks */
+#define NFS_HZ CLOCKS_PER_SEC /* 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_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_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_NPROCS 23
/* 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_DIRBLKSIZ 1024 /* Must be a multiple of DIRBLKSIZ */
/* Increment NFS statistics */
diff --git a/nuttx/fs/nfs/nfs_mount.h b/nuttx/fs/nfs/nfs_mount.h
index 30b644db6..8f1f7be53 100644
--- a/nuttx/fs/nfs/nfs_mount.h
+++ b/nuttx/fs/nfs/nfs_mount.h
@@ -77,8 +77,8 @@ struct nfsmount
bool nm_mounted; /* true: The file system is ready */
uint8_t nm_fhsize; /* Size of root file handle (host order) */
uint8_t nm_sotype; /* Type of socket */
- uint8_t nm_timeo; /* Init timer */
uint8_t nm_retry; /* Max retries */
+ uint16_t nm_timeo; /* Timeout value (in system clock ticks) */
uint16_t nm_rsize; /* Max size of read RPC */
uint16_t nm_wsize; /* Max size of write RPC */
uint16_t nm_readdirsize; /* Size of a readdir RPC */
@@ -130,7 +130,7 @@ struct nfsmount
struct nfs_mount_parameters
{
- uint8_t timeo; /* Init timer */
+ uint8_t timeo; /* Timeout value (in deciseconds) */
uint8_t retry; /* Max retries */
uint16_t rsize; /* Max size of read RPC */
uint16_t wsize; /* Max size of write RPC */
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index 4e444423e..12c4705dd 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -125,6 +125,10 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
static int nfs_opendir(struct inode *mountpt, const char *relpath,
struct fs_dirent_s *dir);
static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
+static int nfs_rewinddir(FAR struct inode *mountpt,
+ FAR struct fs_dirent_s *dir);
+static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt,
+ FAR struct nfs_args *argp);
static int nfs_bind(FAR struct inode *blkdriver, const void *data,
void **handle);
static int nfs_unbind(void *handle, FAR struct inode **blkdriver);
@@ -156,7 +160,7 @@ const struct mountpt_operations nfs_operations =
nfs_opendir, /* opendir */
NULL, /* closedir */
nfs_readdir, /* readdir */
- NULL, /* rewinddir */
+ nfs_rewinddir, /* rewinddir */
nfs_bind, /* bind */
nfs_unbind, /* unbind */
@@ -365,7 +369,8 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np,
* Name: nfs_fileopen
*
* Description:
- * Truncate an open file to zero length.
+ * Truncate an open file to zero length. This is part of the file open
+ * logic.
*
* Returned Value:
* 0 on success; a positive errno value on failure.
@@ -1390,6 +1395,36 @@ errout_with_semaphore:
}
/****************************************************************************
+ * Name: nfs_rewinddir
+ *
+ * Description:
+ * Reset the directory traveral logic to the first entry in the open
+ * directory.
+ *
+ * Returned Value:
+ * 0 on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int nfs_rewinddir(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir)
+{
+ fvdbg("Entry\n");
+
+ /* Sanity checks */
+
+ DEBUGASSERT(mountpt != NULL && dir != NULL);
+
+ /* Reset the NFS-specific portions of dirent structure, retaining only the
+ * file handle.
+ */
+
+ memset(&dir->u.nfs.nfs_verifier, 0, DIRENT_NFS_VERFLEN);
+ dir->u.nfs.nfs_cookie[0] = 0;
+ dir->u.nfs.nfs_cookie[1] = 0;
+ return OK;
+}
+
+/****************************************************************************
* Name: nfs_decode_args
*
* Returned Value:
@@ -1397,25 +1432,29 @@ errout_with_semaphore:
*
****************************************************************************/
-void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
+static void nfs_decode_args(FAR struct nfs_mount_parameters *nprmt,
+ FAR struct nfs_args *argp)
{
int maxio;
- /* Update flags atomically. Don't change the lock bits. */
+ /* Get the selected timeout value */
if ((argp->flags & NFSMNT_TIMEO) != 0 && argp->timeo > 0)
{
- nprmt->timeo = (argp->timeo * NFS_HZ + 5) / 10;
- if (nprmt->timeo < NFS_MINTIMEO)
+ uint32_t tmp = ((uint32_t)argp->timeo * NFS_HZ + 5) / 10;
+ if (tmp < NFS_MINTIMEO)
{
- nprmt->timeo = NFS_MINTIMEO;
+ tmp = NFS_MINTIMEO;
}
- else if (nprmt->timeo > NFS_MAXTIMEO)
+ else if (tmp > NFS_MAXTIMEO)
{
- nprmt->timeo = NFS_MAXTIMEO;
+ tmp = NFS_MAXTIMEO;
}
+ nprmt->timeo = tmp;
}
+ /* Get the selected retransmission count */
+
if ((argp->flags & NFSMNT_RETRANS) != 0 && argp->retrans > 1)
{
if (argp->retrans < NFS_MAXREXMIT)
@@ -1433,6 +1472,8 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
nprmt->retry = NFS_MAXREXMIT + 1; /* Past clip limit */
}
+ /* Get the maximum amount of data that can be transferred in one packet */
+
if ((argp->sotype == SOCK_DGRAM) != 0)
{
maxio = NFS_MAXDGRAMDATA;
@@ -1443,6 +1484,8 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
maxio = NFS_MAXDATA;
}
+ /* Get the maximum amount of data that can be transferred in one write transfer */
+
if ((argp->flags & NFSMNT_WSIZE) != 0 && argp->wsize > 0)
{
nprmt->wsize = argp->wsize;
@@ -1466,6 +1509,8 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
nprmt->wsize = MAXBSIZE;
}
+ /* Get the maximum amount of data that can be transferred in one read transfer */
+
if ((argp->flags & NFSMNT_RSIZE) != 0 && argp->rsize > 0)
{
nprmt->rsize = argp->rsize;
@@ -1489,6 +1534,8 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
nprmt->rsize = MAXBSIZE;
}
+ /* Get the maximum amount of data that can be transferred in directory transfer */
+
if ((argp->flags & NFSMNT_READDIRSIZE) != 0 && argp->readdirsize > 0)
{
nprmt->readdirsize = argp->readdirsize;
@@ -1515,11 +1562,11 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
/****************************************************************************
* Name: nfs_bind
*
- * Description: This implements a portion of the mount operation. This
- * function allocates and initializes the mountpoint private data and
- * binds the blockdriver inode to the filesystem private data. The final
- * binding of the private data (containing the blockdriver) to the
- * mountpoint is performed by mount().
+ * Description:
+ * This implements a portion of the mount operation. This function allocates
+ * and initializes the mountpoint private data and gets mount information
+ * from the NFS server. The final binding of the private data (containing
+ * NFS server mount information) to the mountpoint is performed by mount().
*
* Returned Value:
* 0 on success; a negated errno value on failure.