summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/nshlib/nsh_fscmds.c4
-rw-r--r--nuttx/fs/nfs/nfs_mount.h8
-rw-r--r--nuttx/fs/nfs/nfs_proto.h62
-rw-r--r--nuttx/fs/nfs/nfs_socket.c12
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c105
-rw-r--r--nuttx/fs/nfs/rpc.h11
-rw-r--r--nuttx/fs/nfs/rpc_clnt.c13
-rw-r--r--nuttx/include/nuttx/fs/nfs.h26
8 files changed, 70 insertions, 171 deletions
diff --git a/apps/nshlib/nsh_fscmds.c b/apps/nshlib/nsh_fscmds.c
index 53b743476..4b43e1573 100644
--- a/apps/nshlib/nsh_fscmds.c
+++ b/apps/nshlib/nsh_fscmds.c
@@ -1344,10 +1344,8 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
data.sotype = SOCK_DGRAM;
- data.flags = NFS_NFSV3;
- data.retrans = 3;
data.path = rpath;
- data.timeo = 7;
+ data.flags = 0; /* 0=Use all defaults */
/* Perform the mount */
diff --git a/nuttx/fs/nfs/nfs_mount.h b/nuttx/fs/nfs/nfs_mount.h
index f0a5bcfe6..cfae14e37 100644
--- a/nuttx/fs/nfs/nfs_mount.h
+++ b/nuttx/fs/nfs/nfs_mount.h
@@ -77,14 +77,12 @@ 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 for NFSMNT_DUMBTIMR */
+ uint8_t nm_timeo; /* Init timer */
uint8_t nm_retry; /* Max retries */
- uint8_t nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
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 */
uint16_t nm_buflen; /* Size of I/O buffer */
- uint32_t nm_flag; /* Flags for soft/hard... */
/* Set aside memory on the stack to hold the largest call message. NOTE
* that for the case of the write call message, it is the reply message that
@@ -130,9 +128,7 @@ struct nfsmount
struct nfs_mount_parameters
{
-
- uint8_t flag; /* Flags for soft/hard... */
- uint8_t timeo; /* Init timer for NFSMNT_DUMBTIMR */
+ uint8_t timeo; /* Init timer */
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_proto.h b/nuttx/fs/nfs/nfs_proto.h
index 34d28aa56..cc53d8218 100644
--- a/nuttx/fs/nfs/nfs_proto.h
+++ b/nuttx/fs/nfs/nfs_proto.h
@@ -63,7 +63,6 @@
#define NFS_VER2 2
#define NFS_VER3 3
#define NFS_VER4 4
-#define NFS_V2MAXDATA 8192
#define NFS_MAXDGRAMDATA 32768
#define MAXBSIZE 64000
#define NFS_MAXDATA MAXBSIZE
@@ -117,14 +116,6 @@
#define NFSX_UNSIGNED 4
-/* Specific to NFS Version 2 */
-
-#define NFSX_V2FH 32
-#define NFSX_V2FATTR 68
-#define NFSX_V2SATTR 32
-#define NFSX_V2COOKIE 4
-#define NFSX_V2STATFS 20
-
/* Specific to NFS Version 3 */
#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
@@ -141,25 +132,6 @@
#define NFSX_V3FSINFO 48
#define NFSX_V3PATHCONF 24
-/* Variants for both versions */
-
-#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
- NFSX_V2FH)
-#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
-#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
-#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
-#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
-#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
- NFSX_V2FATTR)
-#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
-#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
-#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
-#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
-#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
-#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
- (2 * NFSX_UNSIGNED))
-#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
-
/* NFS RPC procedure numbers (before version mapping) */
#define NFSPROC_NULL 0
@@ -214,38 +186,6 @@
#define NFSV3FSINFO_HOMOGENEOUS 0x08
#define NFSV3FSINFO_CANSETTIME 0x10
-/* NFS mount option flags */
-
-#define NFSMNT_SOFT (1 << 0) /* Soft mount (hard is default) */
-#define NFSMNT_WSIZE (1 << 1) /* Set write size */
-#define NFSMNT_RSIZE (1 << 2) /* Set read size */
-#define NFSMNT_TIMEO (1 << 3) /* Set initial timeout */
-#define NFSMNT_RETRANS (1 << 4) /* Set number of request retries */
-#define NFSMNT_MAXGRPS (1 << 5) /* Set maximum grouplist size */
-#define NFSMNT_INT (1 << 6) /* Allow interrupts on hard mount */
-#define NFSMNT_NOCONN (1 << 7) /* Don't Connect the socket */
- /* Bit 8 free, was NFSMNT_NQNFS */
-#define NFSMNT_NFSV3 (1 << 9) /* Use NFS Version 3 protocol */
- /* Bit 10 free, was NFSMNT_KERB */
-#define NFSMNT_DUMBTIMR (1 << 11) /* Don't estimate rtt dynamically */
- /* Bit 12 free, was NFSMNT_LEASETERM */
-#define NFSMNT_READAHEAD (1 << 13) /* Set read ahead */
-#define NFSMNT_DEADTHRESH (1 << 14) /* Set dead server retry thresh */
-#define NFSMNT_RESVPORT (1 << 15) /* Allocate a reserved port */
-#define NFSMNT_RDIRPLUS (1 << 16) /* Use Readdirplus for V3 */
-#define NFSMNT_READDIRSIZE (1 << 17) /* Set readdir size */
-
-#define NFSMNT_INTERNAL 0xfffc0000 /* Bits set internally */
-#define NFSMNT_ACREGMIN (1 << 18)
-#define NFSMNT_ACREGMAX (1 << 19)
-#define NFSMNT_NOAC (1 << 19) /* Turn off attribute cache */
-#define NFSMNT_ACDIRMIN (1 << 20)
-#define NFSMNT_ACDIRMAX (1 << 21)
-#define NFSMNT_NOLOCKD (1 << 22) /* Locks are local */
-#define NFSMNT_NFSV4 (1 << 23) /* Use NFS Version 4 protocol */
-#define NFSMNT_HASWRITEVERF (1 << 24) /* NFSv4 Write verifier */
-#define NFSMNT_GOTFSINFO (1 << 25) /* Got the V3 fsinfo */
-
/* Conversion macros */
#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
@@ -333,8 +273,6 @@ typedef struct nfsv3_spec nfsv3spec;
* used so that one pointer can refer to both variants. These structures
* go out on the wire and must be densely packed, so no quad data types
* are used. (all fields are longs or u_longs or structures of same)
- * NB: You can't do sizeof(struct nfs_fattr), you must use the
- * NFSX_FATTR(v3) macro.
*/
struct nfs_fattr
diff --git a/nuttx/fs/nfs/nfs_socket.c b/nuttx/fs/nfs/nfs_socket.c
index c5fe9f1e4..dd2d45841 100644
--- a/nuttx/fs/nfs/nfs_socket.c
+++ b/nuttx/fs/nfs/nfs_socket.c
@@ -59,16 +59,6 @@
* Pre-processor Definitions
****************************************************************************/
-/* Flag translations */
-
-#define nfsmnt_to_rpcclnt(nf, rf, name) do \
- { \
- if (nf & NFSMNT_##name) \
- { \
- rf |= RPCCLNT_##name; \
- } \
- } while(0)
-
/****************************************************************************
* Private Variables
****************************************************************************/
@@ -177,7 +167,7 @@ tryagain:
{
error = fxdr_unsigned(int, replyh.rpc_verfi.authtype);
- if ((nmp->nm_flag & NFSMNT_NFSV3) && error == EAGAIN)
+ if (error == EAGAIN)
{
error = 0;
trylater_delay *= NFS_TIMEOUTMUL;
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index 414053a58..a8477823c 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -242,7 +242,7 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np,
#ifdef USE_GUARDED_CREATE
*ptr++ = HTONL(NFSV3CREATE_GUARDED);
#else
- *ptr++ = HTONL(NFSV3CREATE_GUARDED);
+ *ptr++ = HTONL(NFSV3CREATE_EXCLUSIVE);
#endif
}
else
@@ -996,18 +996,6 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
committed = commit;
}
- /* Save the verifier if needed or if it has change*/
-
- if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0)
- {
- memcpy(nmp->nm_verf, ptr, NFSX_V3WRITEVERF);
- nmp->nm_flag |= NFSMNT_HASWRITEVERF;
- }
- else if (memcmp(ptr, nmp->nm_verf, NFSX_V3WRITEVERF) != 0)
- {
- memcpy(nmp->nm_verf, ptr, NFSX_V3WRITEVERF);
- }
-
/* Update the read state data */
filep->f_pos += writesize;
@@ -1352,9 +1340,7 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
/* Update flags atomically. Don't change the lock bits. */
- nprmt->flag = (argp->flags & ~NFSMNT_INTERNAL) | (nprmt->flag & NFSMNT_INTERNAL);
-
- if ((argp->flags & NFSMNT_TIMEO) && argp->timeo > 0)
+ if ((argp->flags & NFSMNT_TIMEO) != 0 && argp->timeo > 0)
{
nprmt->timeo = (argp->timeo * NFS_HZ + 5) / 10;
if (nprmt->timeo < NFS_MINTIMEO)
@@ -1367,33 +1353,34 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
}
}
- if ((argp->flags & NFSMNT_RETRANS) && argp->retrans > 1)
+ if ((argp->flags & NFSMNT_RETRANS) != 0 && argp->retrans > 1)
{
- nprmt->retry = (argp->retrans < NFS_MAXREXMIT)? argp->retrans : NFS_MAXREXMIT;
+ if (argp->retrans < NFS_MAXREXMIT)
+ {
+ nprmt->retry = argp->retrans;
+ }
+ else
+ {
+ nprmt->retry = NFS_MAXREXMIT;
+ }
}
- if (!(nprmt->flag & NFSMNT_SOFT))
+ if ((argp->flags & NFSMNT_SOFT) == 0)
{
nprmt->retry = NFS_MAXREXMIT + 1; /* Past clip limit */
}
- if (argp->flags & NFSMNT_NFSV3)
+ if ((argp->sotype == SOCK_DGRAM) != 0)
{
- if (argp->sotype == SOCK_DGRAM)
- {
- maxio = NFS_MAXDGRAMDATA;
- }
- else
- {
- maxio = NFS_MAXDATA;
- }
+ maxio = NFS_MAXDGRAMDATA;
}
else
{
- maxio = NFS_V2MAXDATA;
+ fdbg("ERROR: Only SOCK_DRAM is supported\n");
+ maxio = NFS_MAXDATA;
}
- if ((argp->flags & NFSMNT_WSIZE) && argp->wsize > 0)
+ if ((argp->flags & NFSMNT_WSIZE) != 0 && argp->wsize > 0)
{
nprmt->wsize = argp->wsize;
@@ -1416,7 +1403,7 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
nprmt->wsize = MAXBSIZE;
}
- if ((argp->flags & NFSMNT_RSIZE) && argp->rsize > 0)
+ if ((argp->flags & NFSMNT_RSIZE) != 0 && argp->rsize > 0)
{
nprmt->rsize = argp->rsize;
@@ -1439,7 +1426,7 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
nprmt->rsize = MAXBSIZE;
}
- if ((argp->flags & NFSMNT_READDIRSIZE) && argp->readdirsize > 0)
+ if ((argp->flags & NFSMNT_READDIRSIZE) != 0 && argp->readdirsize > 0)
{
nprmt->readdirsize = argp->readdirsize;
@@ -1463,18 +1450,23 @@ void nfs_decode_args(struct nfs_mount_parameters *nprmt, struct nfs_args *argp)
}
/****************************************************************************
- * Name: mountnfs
+ * Name: nfs_bind
*
- * Description:
- * Common code for nfs_mount.
+ * 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().
*
* Returned Value:
- * 0 on success; a positive errno value on failure.
+ * 0 on success; a negated errno value on failure.
*
****************************************************************************/
-int mountnfs(struct nfs_args *argp, void **handle)
+static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data,
+ FAR void **handle)
{
+ FAR struct nfs_args *argp = (FAR struct nfs_args *)data;
FAR struct nfsmount *nmp;
struct rpc_call_fs getattr;
struct rpc_reply_getattr resok;
@@ -1483,9 +1475,12 @@ int mountnfs(struct nfs_args *argp, void **handle)
uint32_t tmp;
int error = 0;
- /* Set initial values of the parameters for decode */
+ DEBUGASSERT(data && handle);
+
+ /* Set default values of the parameters. These may be overridden by
+ * settings in the argp->flags.
+ */
- nprmt.flag = argp->flags;
nprmt.timeo = NFS_TIMEO;
nprmt.retry = NFS_RETRANS;
nprmt.wsize = NFS_WSIZE;
@@ -1542,7 +1537,6 @@ int mountnfs(struct nfs_args *argp, void **handle)
/* Set initial values of other fields */
- nmp->nm_flag = nprmt.flag;
nmp->nm_timeo = nprmt.timeo;
nmp->nm_retry = nprmt.retry;
nmp->nm_wsize = nprmt.wsize;
@@ -1623,37 +1617,6 @@ bad:
}
/****************************************************************************
- * 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().
- *
- * Returned Value:
- * 0 on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-static int nfs_bind(struct inode *blkdriver, const void *data, void **handle)
-{
- struct nfs_args args;
- int error;
-
- memcpy(&args, data, sizeof(struct nfs_args));
- args.flags &= ~(NFSMNT_INTERNAL | NFSMNT_NOAC);
-
- if ((args.flags & (NFSMNT_NFSV3 | NFSMNT_RDIRPLUS)) == NFSMNT_RDIRPLUS)
- {
- return -EINVAL;
- }
-
- error = mountnfs(&args, handle);
- return -error;
-}
-
-/****************************************************************************
* Name: nfs_unbind
*
* Description: This implements the filesystem portion of the umount
diff --git a/nuttx/fs/nfs/rpc.h b/nuttx/fs/nfs/rpc.h
index 5177108b7..4a95d6bc2 100644
--- a/nuttx/fs/nfs/rpc.h
+++ b/nuttx/fs/nfs/rpc.h
@@ -292,6 +292,12 @@ struct rpc_call_mount
struct call_args_mount mount;
};
+struct rpc_call_umount
+{
+ struct rpc_call_header ch;
+ struct call_args_mount mount;
+};
+
struct rpc_call_create
{
struct rpc_call_header ch;
@@ -387,6 +393,11 @@ struct rpc_reply_mount
struct call_result_mount mount;
};
+struct rpc_reply_umount
+{
+ struct rpc_reply_header rh;
+};
+
struct rpc_reply_create
{
struct rpc_reply_header rh;
diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c
index 705dad359..e6a3f7daf 100644
--- a/nuttx/fs/nfs/rpc_clnt.c
+++ b/nuttx/fs/nfs/rpc_clnt.c
@@ -569,8 +569,8 @@ int rpcclnt_umount(struct rpcclnt *rpc)
struct sockaddr_in *sa;
struct rpc_call_pmap sdata;
struct rpc_reply_pmap rdata;
- struct rpc_call_mount mountd;
- struct rpc_reply_mount mdata;
+ struct rpc_call_umount mountd;
+ struct rpc_reply_umount mdata;
uint32_t tmp;
int error;
int ret;
@@ -628,14 +628,7 @@ int rpcclnt_umount(struct rpcclnt *rpc)
(FAR void *)&mdata, sizeof(struct rpc_reply_mount));
if (error != 0)
{
- fdbg("ERROR: rpcclnt_request failed: %d\n", error);
- goto bad;
- }
-
- tmp = fxdr_unsigned(uint32_t, mdata.mount.status);
- if (tmp != 0)
- {
- fdbg("ERROR: Server returned umount status: %d\n", tmp);
+ fdbg("ERROR: rpcclnt_request failed: %d\n", error);
goto bad;
}
diff --git a/nuttx/include/nuttx/fs/nfs.h b/nuttx/include/nuttx/fs/nfs.h
index 3dbcc6dc8..2b1404461 100644
--- a/nuttx/include/nuttx/fs/nfs.h
+++ b/nuttx/include/nuttx/fs/nfs.h
@@ -53,8 +53,18 @@
* Pre-processor Definitions
****************************************************************************/
-#define NFS_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
-#define NFS_PMAPPORT 111
+/* NFS mount option flags */
+
+#define NFSMNT_SOFT (1 << 0) /* Soft mount (hard is default) */
+#define NFSMNT_WSIZE (1 << 1) /* Set write size */
+#define NFSMNT_RSIZE (1 << 2) /* Set read size */
+#define NFSMNT_TIMEO (1 << 3) /* Set initial timeout */
+#define NFSMNT_RETRANS (1 << 4) /* Set number of request retries */
+#define NFSMNT_READDIRSIZE (1 << 5) /* Set readdir size */
+
+/* Default PMAP port number to provide */
+
+#define NFS_PMAPPORT 111
/****************************************************************************
* Public Types
@@ -64,12 +74,12 @@ struct nfs_args
{
uint8_t addrlen; /* Length of address */
uint8_t sotype; /* Socket type */
- uint32_t flags; /* Flags */
- int wsize; /* Write size in bytes */
- int rsize; /* Read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* Initial timeout in .1 secs */
- int retrans; /* Times to retry send */
+ uint8_t flags; /* Flags, determines if following are valid: */
+ uint8_t timeo; /* Initial timeout in .1 secs (with NFSMNT_TIMEO) */
+ uint8_t retrans; /* Times to retry send (with NFSMNT_RETRANS) */
+ uint16_t wsize; /* Write size in bytes (with NFSMNT_WSIZE) */
+ uint16_t rsize; /* Read size in bytes (with NFSMNT_RSIZE) */
+ uint16_t readdirsize; /* readdir size in bytes (with NFSMNT_READDIRSIZE) */
char *path; /* Server's path of the directory being mount */
struct sockaddr_storage addr; /* File server address (requires 32-bit alignment) */
};