NFS update

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4817 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-06-08 15:45:40 +00:00
parent 11e1c6fb96
commit ac9fba297a
3 changed files with 82 additions and 74 deletions

View File

@ -338,7 +338,7 @@ typedef struct fhandle fhandle_t;
union nfsfh
{
//fhandle_t fh_generic;
unsigned char fh_bytes[NFSX_V2FH];
uint8_t fh_bytes[NFSX_V2FH];
};
typedef union nfsfh nfsfh_t;
@ -599,7 +599,7 @@ struct WRITE3resok
struct wcc_data file_wcc;
uint32_t count;
uint32_t committed;
unsigned char verf[NFSX_V3WRITEVERF];
uint8_t verf[NFSX_V3WRITEVERF];
};
struct REMOVE3args
@ -652,30 +652,27 @@ struct READDIR3args
{
struct file_handle dir;
nfsuint64 cookie;
unsigned char cookieverf[NFSX_V3COOKIEVERF];
uint8_t cookieverf[NFSX_V3COOKIEVERF];
uint32_t count;
};
struct entry3
{
uint64_t fileid;
unsigned char name;
nfsuint64 cookie;
#warning "This causes compilation errors"
//struct entry3 nextentry;
};
struct dirlist3
{
struct entry3 entries;
bool eof;
};
/* The READDIR reply is variable length and consists of multiple entries, each
* of form:
*
* EOF - OR -
*
* File ID (8 bytes)
* Name length (4 bytes)
* Name string (varaiable size but in multiples of 4 bytes)
* Cookie (8 bytes)
* next entry (4 bytes)
*/
struct READDIR3resok
{
struct nfs_fattr dir_attributes;
unsigned char cookieverf[NFSX_V3COOKIEVERF];
struct dirlist3 reply;
uint8_t cookieverf[NFSX_V3COOKIEVERF];
uint32_t reply[1]; /* Variable length reply begins here */
};
struct FS3args

View File

@ -703,18 +703,27 @@ errout_with_semaphore:
****************************************************************************/
int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
bool eod, struct fs_dirent_s *dir)
struct fs_dirent_s *dir)
{
/* This buffer needs to go into struct fs_dirent_s nuttx/dirent.h */
uint32_t buffer[64];
struct READDIR3args readdir;
struct rpc_reply_readdir resok;
struct rpc_reply_readdir *resok;
struct entry3 *entry;
uint32_t *ptr; /* This goes in fs_dirent_s */
uint8_t *name;
int length;
int error = 0;
/* Loop around doing readdir rpc's of size nm_readdirsize
* truncated to a multiple of NFS_READDIRBLKSIZ.
* The stopping criteria is EOF.
*/
/* Check in 'dir' if we are have directories entries?
* 1) have data, and
* 2) Index of the last returned entry has nextentry != 0
*
* If we have returned entries then read more entries if:
* 3) EOF = 0
*/
while (eod == false)
/* if need to read data */
{
nfsstats.rpccnt[NFSPROC_READDIR]++;
memset(&readdir, 0, sizeof(struct READDIR3args));
@ -736,7 +745,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
}
error = nfs_request(nmp, NFSPROC_READDIR, (FAR const void *)&readdir,
(FAR void *)&resok, sizeof(struct rpc_reply_readdir));
(FAR void *)buffer, sizeof(buffer));
if (error)
{
goto nfsmout;
@ -744,57 +753,21 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
/* Save the node attributes and cooking information */
bcopy(&resok.readdir.dir_attributes, &np->n_fattr, sizeof(struct nfs_fattr));
bcopy(&resok.readdir.cookieverf, np->n_cookieverf, NFSX_V3WRITEVERF);
resok = (struct rpc_reply_readdir *)buffer;
dir->u.nfs.cookie[0] = resok.readdir.reply.entries.cookie.nfsuquad[0];
dir->u.nfs.cookie[1] = resok.readdir.reply.entries.cookie.nfsuquad[1];
bcopy(&resok->readdir.dir_attributes, &np->n_fattr, sizeof(struct nfs_fattr));
bcopy(&resok->readdir.cookieverf, np->n_cookieverf, NFSX_V3WRITEVERF);
/* Return the Type of the node to the caller */
#if 0
dir->fd_dir.d_type = resok.readdir.reply.entries.fileid;
#warning "This must match the type values in dirent.h"
/* Start with the first entry */
/* 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 */
#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)
{
if (info_v3)
{
dir->u.nfs.cookie[0] = cookie.nfsuquad[0];
}
else
{
dir->u.nfs.cookie[0] = ndp->cookie[0] = 0;
}
dir->u.nfs.cookie[1] = ndp->cookie[1] = cookie.nfsuquad[1];
}
more = fxdr_unsigned(int, *ndp);
}
ptr = resok->readdir.reply;
}
/* We are now either at the end of the directory */
/* Check for EOF */
if (resok.readdir.reply.entries == NULL)
if (*ptr != 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
@ -804,6 +777,44 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
error = ENOENT;
}
/* Otherwise, there is an entry. Get the file ID and point to the length */
// dir->fd_dir.d_type = entry->fileid;
#warning "This must match the type values in dirent.h"
ptr += 2;
/* Get the length and point to the name */
length = *ptr++;
name = (uint8_t*)ptr;
/* Increment the pointer past the name (allowing for padding). ptr now points to the cookie. */
ptr += (length + 3) >> 2;
/* Return the first entry to the caller. On subsequent calls to readdir(),
* we will return the next entry. And so on until all of the entries have
* been returned. Then read the next next block of entries until EOF is
* report.
*/
#warning "Not implemented"
/* Save the cookie and increment the point to point to the next entry */
dir->u.nfs.cookie[0] = *ptr++;
dir->u.nfs.cookie[1] = *ptr++;
ptr++; /* Just skip over the nextentry for now */
/* Return the Type of the node to the caller */
/* MISSING LOGIC */
/* Return the name of the node to the caller */
memcpy(dir->fd_dir.d_name, name, length > NAME_MAX ? NAME_MAX : length);
dir->fd_dir.d_name[NAME_MAX] = '\0';
error = 0;
nfsmout:
return error;
}
@ -823,7 +834,6 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
int error = 0;
struct nfsmount *nmp;
struct nfsnode *np;
bool eof = false;
//struct nfs_dirent *ndp;
fvdbg("Entry\n");
@ -873,18 +883,19 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
(void)nfs_getfsinfo(nmp, NULL, NULL);
}
error = nfs_readdirrpc(nmp, np, eof, dir);
error = nfs_readdirrpc(nmp, np, dir);
if (error == NFSERR_BAD_COOKIE)
{
error = EINVAL;
goto errout_with_semaphore;
}
#if 0
if (!error && eof)
{
nfsstats.direofcache_misses++;
}
#endif
success_with_semaphore:
error = 0;

View File

@ -461,7 +461,7 @@ void uip_input(struct uip_driver_s *dev)
*/
if (!uip_ipaddr_cmp(pbuf->destipaddr, dev->d_ipaddr) &&
(pbuf->destipaddr[0] & 0xffff) != 0xff02)
pbuf->destipaddr[0] != 0xff02)
{
#ifdef CONFIG_NET_STATISTICS
uip_stat.ip.drop++;