diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-06-14 21:54:50 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-06-14 21:54:50 +0000 |
commit | 6d538ea469affc6b33254109c3c2b65c24c14e5d (patch) | |
tree | 674689e2c7da31b70ca838eeceed0ec4996276d2 /nuttx/fs/nfs/nfs_vfsops.c | |
parent | 8f09b6e49a22230c26f0af2f7b20a0bf10ca8e9b (diff) | |
download | px4-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/nfs_vfsops.c')
-rw-r--r-- | nuttx/fs/nfs/nfs_vfsops.c | 75 |
1 files changed, 61 insertions, 14 deletions
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. |