From f21df2e6f5340903bb8457171fe3be784f63ff53 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 7 Jun 2012 18:47:20 +0000 Subject: [PATCH] Cosmetic NFS update git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4812 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/fs/nfs/nfs_vfsops.c | 90 ++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c index db11355d4f..577b97a499 100644 --- a/nuttx/fs/nfs/nfs_vfsops.c +++ b/nuttx/fs/nfs/nfs_vfsops.c @@ -704,9 +704,9 @@ errout_with_semaphore: ****************************************************************************/ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np, - bool end_of_directory, struct fs_dirent_s *dir) + bool eod, struct fs_dirent_s *dir) { - struct READDIR3args readir; + struct READDIR3args readdir; struct rpc_reply_readdir resok; int error = 0; @@ -715,54 +715,66 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np, * The stopping criteria is EOF. */ - while (end_of_directory == false) + while (eod == false) { nfsstats.rpccnt[NFSPROC_READDIR]++; - memset(&readir, 0, sizeof(struct READDIR3args)); - readir.dir.length = txdr_unsigned(np->n_fhsize); - readir.dir.handle = np->n_fhp; - readir.count = nmp->nm_readdirsize; + memset(&readdir, 0, sizeof(struct READDIR3args)); + readdir.dir.length = txdr_unsigned(np->n_fhsize); + readdir.dir.handle = np->n_fhp; + readdir.count = nmp->nm_readdirsize; if (nfsstats.rpccnt[NFSPROC_READDIR] == 1) { - readir.cookie.nfsuquad[0] = 0; - readir.cookie.nfsuquad[1] = 0; - readir.cookieverf.nfsuquad[0] = 0; - readir.cookieverf.nfsuquad[1] = 0; + readdir.cookie.nfsuquad[0] = 0; + readdir.cookie.nfsuquad[1] = 0; + readdir.cookieverf.nfsuquad[0] = 0; + readdir.cookieverf.nfsuquad[1] = 0; } else { - readir.cookie.nfsuquad[0] = dir->u.nfs.cookie[0]; - readir.cookie.nfsuquad[1] = dir->u.nfs.cookie[1]; - readir.cookieverf.nfsuquad[0] = np->n_cookieverf.nfsuquad[0]; - readir.cookieverf.nfsuquad[1] = np->n_cookieverf.nfsuquad[1]; + readdir.cookie.nfsuquad[0] = dir->u.nfs.cookie[0]; + readdir.cookie.nfsuquad[1] = dir->u.nfs.cookie[1]; + readdir.cookieverf.nfsuquad[0] = np->n_cookieverf.nfsuquad[0]; + readdir.cookieverf.nfsuquad[1] = np->n_cookieverf.nfsuquad[1]; } - error = nfs_request(nmp, NFSPROC_READDIR, (FAR const void *)&readir, + error = nfs_request(nmp, NFSPROC_READDIR, (FAR const void *)&readdir, (FAR void *)&resok, sizeof(struct rpc_reply_readdir)); if (error) { goto nfsmout; } - //dir->fd_dir.d_name = resok->reply.entries->name;// - /*np->n_fattr = resok.readir.dir_attributes; - np->n_cookieverf.nfsuquad[0] = resok.readir.cookieverf.nfsuquad[0]; - np->n_cookieverf.nfsuquad[1] = resok.readir.cookieverf.nfsuquad[1]; - dir->fd_dir.d_type = resok.readir.reply.entries->fileid; - memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok.readir.reply.entries->name, NAME_MAX); - dir->u.nfs.cookie[0] = resok.readir.reply.entries->cookie.nfsuquad[0]; - dir->u.nfs.cookie[1] = resok.readir.reply.entries->cookie.nfsuquad[1]; - - if (resok.readir.reply.eof == true) - { - end_of_directory = true; - } -*/ - //more_dirs = fxdr_unsigned(int, *dp); + +#if 0 + /* Save the node attributes and cooking information */ + + np->n_fattr = resok.readdir.dir_attributes; + np->n_cookieverf.nfsuquad[0] = resok.readdir.cookieverf.nfsuquad[0]; + np->n_cookieverf.nfsuquad[1] = resok.readdir.cookieverf.nfsuquad[1]; + + dir->u.nfs.cookie[0] = resok.readdir.reply.entries->cookie.nfsuquad[0]; + dir->u.nfs.cookie[1] = resok.readdir.reply.entries->cookie.nfsuquad[1]; + + /* Return the Type of the node to the caller */ + + dir->fd_dir.d_type = resok.readdir.reply.entries->fileid; +#warning "This must match the type values in dirent.h" + + /* Return the name of the node to the caller */ +#warning "The name in the structure is only a char -- that won't work!" + + strncpy(dir->fd_dir.d_name, resok.readdir.reply.entries->name, NAME_MAX); + dir->fd_dir.d_name[NAME_MAX] = '\0'; + + /* Check for the end of the directory listing */ + + eof = resok.readdir.reply.eof; /* loop thru the dir entries */ -/* - while (more_dirs && bigenough) +#warning "The result structure contains a pointer to the next entry -- that won't work!" + + more = fxdr_unsigned(int, *dp); + while (more && bigenough) { if (bigenough) { @@ -778,16 +790,16 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np, dir->u.nfs.cookie[1] = ndp->cookie[1] = cookie.nfsuquad[1]; } - more_dirs = fxdr_unsigned(int, *ndp); + more = fxdr_unsigned(int, *ndp); } - } -*/ + /* We are now either at the end of the directory */ -/* - if (resok.readir.reply.entries == NULL) + + if (resok.readdir.reply.entries == NULL) { - np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]);*/ + np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]); +#endif /* We signal the end of the directory by returning the * special error -ENOENT