summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-30 23:21:37 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-30 23:21:37 +0000
commiteb68069699e2bc904a278cdb310c561d5f3083c5 (patch)
tree9649d99f2c5779fcf43549ec2aac5e004830b780
parent89ade858089dde83dc3d993d4ca28f39c3b25538 (diff)
downloadnuttx-eb68069699e2bc904a278cdb310c561d5f3083c5.tar.gz
nuttx-eb68069699e2bc904a278cdb310c561d5f3083c5.tar.bz2
nuttx-eb68069699e2bc904a278cdb310c561d5f3083c5.zip
NFS update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4790 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/drivers/lcd/ssd1289.c4
-rw-r--r--nuttx/fs/nfs/nfs_node.h2
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c147
-rw-r--r--nuttx/fs/nfs/rpc_clnt.c35
5 files changed, 120 insertions, 72 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 3d7bc5a5d..0e7ab01c8 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2850,4 +2850,8 @@
compatible with the F4 and needs the same work-around for the missing BTF
signal that was needed for the F4.
* drivers/lcd/ssd1289.*: Fix some of the initial register settings.
+ * configs/stm32f4discovery/src/up_ssd1289.c: FSMC address bit 16 is used to
+ distinguish command and data. But FSMC address bits 0-24 correspond to ARM
+ address bits 1-25, se we need to set bit 17 in order generate output on
+ FSMC_A16.
diff --git a/nuttx/drivers/lcd/ssd1289.c b/nuttx/drivers/lcd/ssd1289.c
index 6e547228a..e55ff5fec 100644
--- a/nuttx/drivers/lcd/ssd1289.c
+++ b/nuttx/drivers/lcd/ssd1289.c
@@ -819,7 +819,7 @@ static int ssd1289_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast)
* Name: ssd1289_hwinitialize
*
* Description:
- * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST).
+ * Initialize the LCD hardware.
*
**************************************************************************************/
@@ -830,7 +830,7 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv)
uint16_t id;
#endif
- /* Select the LCD and home the cursor position */
+ /* Select the LCD */
lcd->select(lcd);
diff --git a/nuttx/fs/nfs/nfs_node.h b/nuttx/fs/nfs/nfs_node.h
index c2d2ca5e0..9a8799558 100644
--- a/nuttx/fs/nfs/nfs_node.h
+++ b/nuttx/fs/nfs/nfs_node.h
@@ -123,7 +123,7 @@ struct nfsnode
bool n_open; /* true: The file is (still) open */
uint64_t n_size; /* Current size of file */
struct nfs_fattr n_fattr; /* nfs file attribute cache */
- nfstype nfsv3_type; /* File type */
+ uint32_t nfsv3_type; /* File type */
time_t n_attrstamp; /* Attr. cache timestamp */
struct timespec n_mtime; /* Prev modify time. */
time_t n_ctime; /* Prev create time. */
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index ea73bd759..a56aa9f3b 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -176,12 +176,11 @@ const struct mountpt_operations nfs_operations =
* check to see if the type is ok and that deletion is not in progress.
****************************************************************************/
-static int
-nfs_open(FAR struct file *filep, FAR const char *relpath,
- int oflags, mode_t mode)
+static int nfs_open(FAR struct file *filep, FAR const char *relpath,
+ int oflags, mode_t mode)
{
struct inode *in;
- struct nfs_fattr vap;
+//struct nfs_fattr vap;
struct nfsv3_sattr sp;
struct nfsmount *nmp;
struct nfsnode *np;
@@ -220,17 +219,17 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
again:
nfsstats.rpccnt[NFSPROC_CREATE]++;
memset(&sp, 0, sizeof(struct nfsv3_sattr));
- memset(&vap, 0, sizeof(struct nfs_fattr));
- vap = nmp->nm_head->n_fattr;
+ //memset(&vap, 0, sizeof(struct nfs_fattr));
+ //vap = nmp->nm_head->n_fattr;
sp.sa_modetrue = true;
sp.sa_mode = txdr_unsigned(mode);
- sp.sa_uidfalse = nfs_xdrneg1;
- sp.sa_gidfalse = nfs_xdrneg1;
- sp.sa_sizefalse = nfs_xdrneg1;
- sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
- sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
- txdr_nfsv3time2(&vap.fa3_atime, &sp.sa_atime);
- txdr_nfsv3time2(&vap.fa3_mtime, &sp.sa_mtime);
+ sp.sa_uidfalse = 0;
+ sp.sa_gidfalse = 0;
+ sp.sa_sizefalse = 0;
+ sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
+ sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
+ //txdr_nfsv3time2(&vap.fa3_atime, &sp.sa_atime);
+ //txdr_nfsv3time2(&vap.fa3_mtime, &sp.sa_mtime);
memset(&create, 0, sizeof(struct CREATE3args));
create.how = sp;
@@ -259,7 +258,7 @@ again:
*/
np->n_open = true;
- np->nfsv3_type = NFREG;
+ np->nfsv3_type = fxdr_unsigned(uint32_t, resok.attributes.fa_type);
np->n_fhp = resok.fshandle.handle;
np->n_size = fxdr_hyper(&resok.attributes.fa3_size);
np->n_fattr = resok.attributes;
@@ -523,20 +522,19 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
nfsstats.rpccnt[NFSPROC_WRITE]++;
memset(&write, 0, sizeof(struct WRITE3args));
- write.file = np->nfsv3_type;
- write.offset = offset;
- write.count = buflen;
- write.stable = committed;
+ write.file = txdr_unsigned(np->nfsv3_type);
+ write.offset = txdr_unsigned(offset);
+ write.count = txdr_unsigned(buflen);
+ write.stable = txdr_unsigned(committed);
memcpy((void *)write.data, userbuffer, buflen);
- error = nfs_request(nmp, NFSPROC_WRITE, (FAR const void *)&write, (FAR void *)&resok);
+ error = nfs_request(nmp, NFSPROC_WRITE, (FAR const void *)&write,
+ (FAR void *)&resok);
if (error)
{
goto errout_with_semaphore;
}
-//bcopy (datareply, &resok, sizeof(struct WRITE3resok));
-//resok = (struct WRITE3resok *) datareply;
writesize = resok.count;
if (writesize == 0)
{
@@ -591,7 +589,8 @@ static int nfs_opendir(struct inode *mountpt, const char *relpath,
struct fs_dirent_s *dir)
{
struct nfsmount *nmp;
- //struct romfs_dirinfo_s dirinfo;
+ struct nfsnode *np;
+//struct romfs_dirinfo_s dirinfo;
int ret;
fvdbg("relpath: '%s'\n", relpath);
@@ -603,6 +602,7 @@ static int nfs_opendir(struct inode *mountpt, const char *relpath,
/* Recover our private data from the inode instance */
nmp = mountpt->i_private;
+ np = nmp->nm_head;
/* Make sure that the mount is still healthy */
@@ -616,9 +616,24 @@ static int nfs_opendir(struct inode *mountpt, const char *relpath,
/* The entry is a directory */
- dir->u.nfs.nd_direoffset = false;
- dir->u.nfs.cookie[0] = 0;
- dir->u.nfs.cookie[1] = 0;
+ if (np->nfsv3_type != NFREG && np->nfsv3_type != NFDIR)
+ {
+ ndbg("open eacces type=%d\n", np->nfsv3_type);
+ nfs_semgive(nmp);
+ return EACCES;
+ }
+
+ if (np->n_flag & NMODIFIED)
+ {
+ if (np->nfsv3_type == NFDIR)
+ {
+ np->n_direofoffset = 0;
+ dir->u.nfs.nd_direoffset = false;
+ dir->u.nfs.cookie[0] = 0;
+ dir->u.nfs.cookie[1] = 0;
+ }
+ }
+
nfs_semgive(nmp);
return OK;
@@ -637,9 +652,8 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
bool end_of_directory, struct fs_dirent_s *dir)
{
int error = 0;
- void *datareply;
struct READDIR3args readir;
- struct READDIR3resok *resok = NULL;
+ struct READDIR3resok resok;
/* Loop around doing readdir rpc's of size nm_readdirsize
* truncated to a multiple of NFS_READDIRBLKSIZ.
@@ -669,32 +683,30 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
readir.cookieverf.nfsuquad[1] = np->n_cookieverf.nfsuquad[1];
}
- error = nfs_request(nmp, NFSPROC_READDIR, &readir, &datareply);
-
+ error = nfs_request(nmp, NFSPROC_READDIR, (FAR const void *)&readir,
+ (FAR void *)&resok);
if (error)
{
goto nfsmout;
}
- //bcopy (datareply, &resok, sizeof(struct READDIR3resok));
- resok = (struct READDIR3resok *) datareply;
- np->n_fattr = resok->dir_attributes;
- np->n_cookieverf.nfsuquad[0] = resok->cookieverf.nfsuquad[0];
- np->n_cookieverf.nfsuquad[1] = resok->cookieverf.nfsuquad[1];
- dir->fd_dir.d_type = resok->reply.entries->fileid;
- memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok->reply.entries->name, NAME_MAX);
- //dir->fd_dir.d_name = resok->reply.entries->name;//
- dir->u.nfs.cookie[0] = resok->reply.entries->cookie.nfsuquad[0];
- dir->u.nfs.cookie[1] = resok->reply.entries->cookie.nfsuquad[1];
-
- if (resok->reply.eof == true)
+ np->n_fattr = resok.dir_attributes;
+ np->n_cookieverf.nfsuquad[0] = resok.cookieverf.nfsuquad[0];
+ np->n_cookieverf.nfsuquad[1] = resok.cookieverf.nfsuquad[1];
+ dir->fd_dir.d_type = resok.reply.entries->fileid;
+ memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok.reply.entries->name, NAME_MAX);
+ //dir->fd_dir.d_name = resok->reply.entries->name;//
+ dir->u.nfs.cookie[0] = resok.reply.entries->cookie.nfsuquad[0];
+ dir->u.nfs.cookie[1] = resok.reply.entries->cookie.nfsuquad[1];
+
+ if (resok.reply.eof == true)
{
end_of_directory = true;
}
- //more_dirs = fxdr_unsigned(int, *dp);
+ //more_dirs = fxdr_unsigned(int, *dp);
- /* loop thru the dir entries*/
+ /* loop thru the dir entries */
/*
while (more_dirs && bigenough)
{
@@ -719,7 +731,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
/* We are now either at the end of the directory */
- if (resok->reply.entries == NULL)
+ if (resok.reply.entries == NULL)
{
np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]);
@@ -1083,6 +1095,20 @@ int mountnfs(struct nfs_args *argp, void **handle)
nmp->nm_nam = argp->addr;
nfs_decode_args(nmp, argp);
+ /* Set up the sockets and per-host congestion */
+
+ nmp->nm_sotype = argp->sotype;
+ nmp->nm_soproto = argp->proto;
+
+ /* For Connection based sockets (TCP,...) defer the connect until
+ * the first request, in case the server is not responding.
+ */
+
+ if (nmp->nm_sotype == SOCK_DGRAM && (error = nfs_connect(nmp)))
+ {
+ goto bad;
+ }
+
/* Create an instance of the file private data to describe the opened
* file.
*/
@@ -1098,20 +1124,6 @@ int mountnfs(struct nfs_args *argp, void **handle)
np->n_open = true;
nmp->nm_head = np;
- /* Set up the sockets and per-host congestion */
-
- nmp->nm_sotype = argp->sotype;
- nmp->nm_soproto = argp->proto;
-
- /* For Connection based sockets (TCP,...) defer the connect until
- * the first request, in case the server is not responding.
- */
-
- if (nmp->nm_sotype == SOCK_DGRAM && (error = nfs_connect(nmp)))
- {
- goto bad;
- }
-
/* Mounted! */
nmp->nm_mounted = true;
@@ -1335,7 +1347,8 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
memset(&remove, 0, sizeof(struct REMOVE3args));
remove.object.dir.length = txdr_unsigned(np->n_fhsize);
remove.object.dir.handle = np->n_fhp;
- //remove.object.name = relpath;
+ remove.object.length = txdr_unsigned(64);
+ strncpy(remove.object.name, relpath, 64);
error = nfs_request(nmp, NFSPROC_REMOVE, (FAR const void *)&remove,
(FAR void*)&resok);
@@ -1413,8 +1426,8 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
sp.sa_uidfalse = 0;
sp.sa_gidfalse = 0;
sp.sa_sizefalse = 0;
- sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
- sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
+ sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
+ sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE);
memset(&sp.sa_atime, 0, sizeof(nfstime3));
memset(&sp.sa_mtime, 0, sizeof(nfstime3));
@@ -1428,10 +1441,14 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
goto errout_with_semaphore;
}
- np->nfsv3_type = NFDIR;
- np->n_fhp = resok.fshandle.handle;
- np->n_fattr = resok.obj_attributes;
- np->n_flag |= NMODIFIED;
+ np->n_open = true;
+ np->nfsv3_type = fxdr_unsigned(uint32_t, resok.obj_attributes.fa_type);
+ np->n_fhp = resok.fshandle.handle;
+ np->n_size = fxdr_hyper(&resok.obj_attributes.fa3_size);
+ np->n_fattr = resok.obj_attributes;
+ fxdr_nfsv3time(&resok.obj_attributes.fa3_mtime, &np->n_mtime)
+ np->n_ctime = fxdr_hyper(&resok.obj_attributes.fa3_ctime);
+ np->n_flag |= NMODIFIED;
NFS_INVALIDATE_ATTRCACHE(np);
diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c
index e39d1c161..b701eae9c 100644
--- a/nuttx/fs/nfs/rpc_clnt.c
+++ b/nuttx/fs/nfs/rpc_clnt.c
@@ -1267,7 +1267,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
if (error)
{
- ndbg("psock_connect to ppmap port returns %d", error);
+ ndbg("psock_connect to PMAP port returns %d", error);
goto bad;
}
@@ -1313,7 +1313,8 @@ int rpcclnt_connect(struct rpcclnt *rpc)
goto bad;
}
- if ((fxdr_unsigned(uint32_t, mdata.mount.status)) != 0)
+ error = fxdr_unsigned(uint32_t, mdata.mount.status);
+ if (error != 0)
{
ndbg("error mounting with the server %d\n", error);
goto bad;
@@ -1321,9 +1322,35 @@ int rpcclnt_connect(struct rpcclnt *rpc)
rpc->rc_fh = mdata.mount.fhandle;
- /* NFS port in the socket*/
+ /* Do the RPC to get a dynamic bounding with the server using PMAP.
+ * NFS port in the socket.
+ */
+
+ memset(&sdata, 0, sizeof(sdata));
+ memset(&rdata, 0, sizeof(rdata));
+ sa->sin_port = htons(PMAPPORT);
+
+ error = psock_connect(rpc->rc_so, saddr, sizeof(*saddr));
+ if (error)
+ {
+ ndbg("psock_connect PMAP port returns %d\n", error);
+ goto bad;
+ }
+
+ sdata.prog = txdr_unsigned(NFS_PROG);
+ sdata.vers = txdr_unsigned(NFS_VER3);
+ sdata.proc = txdr_unsigned(IPPROTO_UDP);
+ sdata.port = 0;
+
+ error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS,
+ (void *)&rdata, (FAR const void *)&sdata);
+ if (error != 0)
+ {
+ goto bad;
+ }
+
+ sa->sin_port = htons(fxdr_unsigned(uint32_t, rdata.pmap.port));
- sa->sin_port = htons(NFS_PORT);
error = psock_connect(rpc->rc_so, saddr, sizeof(*saddr));
if (error)
{