mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
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:
+16
-19
@@ -338,7 +338,7 @@ typedef struct fhandle fhandle_t;
|
|||||||
union nfsfh
|
union nfsfh
|
||||||
{
|
{
|
||||||
//fhandle_t fh_generic;
|
//fhandle_t fh_generic;
|
||||||
unsigned char fh_bytes[NFSX_V2FH];
|
uint8_t fh_bytes[NFSX_V2FH];
|
||||||
};
|
};
|
||||||
typedef union nfsfh nfsfh_t;
|
typedef union nfsfh nfsfh_t;
|
||||||
|
|
||||||
@@ -599,7 +599,7 @@ struct WRITE3resok
|
|||||||
struct wcc_data file_wcc;
|
struct wcc_data file_wcc;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
uint32_t committed;
|
uint32_t committed;
|
||||||
unsigned char verf[NFSX_V3WRITEVERF];
|
uint8_t verf[NFSX_V3WRITEVERF];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct REMOVE3args
|
struct REMOVE3args
|
||||||
@@ -652,30 +652,27 @@ struct READDIR3args
|
|||||||
{
|
{
|
||||||
struct file_handle dir;
|
struct file_handle dir;
|
||||||
nfsuint64 cookie;
|
nfsuint64 cookie;
|
||||||
unsigned char cookieverf[NFSX_V3COOKIEVERF];
|
uint8_t cookieverf[NFSX_V3COOKIEVERF];
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct entry3
|
|
||||||
{
|
|
||||||
uint64_t fileid;
|
|
||||||
unsigned char name;
|
|
||||||
nfsuint64 cookie;
|
|
||||||
#warning "This causes compilation errors"
|
|
||||||
//struct entry3 nextentry;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct dirlist3
|
/* The READDIR reply is variable length and consists of multiple entries, each
|
||||||
{
|
* of form:
|
||||||
struct entry3 entries;
|
*
|
||||||
bool eof;
|
* 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 READDIR3resok
|
||||||
{
|
{
|
||||||
struct nfs_fattr dir_attributes;
|
struct nfs_fattr dir_attributes;
|
||||||
unsigned char cookieverf[NFSX_V3COOKIEVERF];
|
uint8_t cookieverf[NFSX_V3COOKIEVERF];
|
||||||
struct dirlist3 reply;
|
uint32_t reply[1]; /* Variable length reply begins here */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FS3args
|
struct FS3args
|
||||||
|
|||||||
+65
-54
@@ -703,18 +703,27 @@ errout_with_semaphore:
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
|
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 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;
|
int error = 0;
|
||||||
|
|
||||||
/* Loop around doing readdir rpc's of size nm_readdirsize
|
/* Check in 'dir' if we are have directories entries?
|
||||||
* truncated to a multiple of NFS_READDIRBLKSIZ.
|
* 1) have data, and
|
||||||
* The stopping criteria is EOF.
|
* 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]++;
|
nfsstats.rpccnt[NFSPROC_READDIR]++;
|
||||||
memset(&readdir, 0, sizeof(struct READDIR3args));
|
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,
|
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)
|
if (error)
|
||||||
{
|
{
|
||||||
goto nfsmout;
|
goto nfsmout;
|
||||||
@@ -744,57 +753,21 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
|
|||||||
|
|
||||||
/* Save the node attributes and cooking information */
|
/* Save the node attributes and cooking information */
|
||||||
|
|
||||||
bcopy(&resok.readdir.dir_attributes, &np->n_fattr, sizeof(struct nfs_fattr));
|
resok = (struct rpc_reply_readdir *)buffer;
|
||||||
bcopy(&resok.readdir.cookieverf, np->n_cookieverf, NFSX_V3WRITEVERF);
|
|
||||||
|
|
||||||
dir->u.nfs.cookie[0] = resok.readdir.reply.entries.cookie.nfsuquad[0];
|
bcopy(&resok->readdir.dir_attributes, &np->n_fattr, sizeof(struct nfs_fattr));
|
||||||
dir->u.nfs.cookie[1] = resok.readdir.reply.entries.cookie.nfsuquad[1];
|
bcopy(&resok->readdir.cookieverf, np->n_cookieverf, NFSX_V3WRITEVERF);
|
||||||
|
|
||||||
/* Return the Type of the node to the caller */
|
/* Start with the first entry */
|
||||||
#if 0
|
|
||||||
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 */
|
ptr = resok->readdir.reply;
|
||||||
#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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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]);
|
np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* We signal the end of the directory by returning the
|
/* We signal the end of the directory by returning the
|
||||||
* special error -ENOENT
|
* special error -ENOENT
|
||||||
@@ -804,6 +777,44 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
|
|||||||
error = ENOENT;
|
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:
|
nfsmout:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -823,7 +834,6 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
struct nfsmount *nmp;
|
struct nfsmount *nmp;
|
||||||
struct nfsnode *np;
|
struct nfsnode *np;
|
||||||
bool eof = false;
|
|
||||||
//struct nfs_dirent *ndp;
|
//struct nfs_dirent *ndp;
|
||||||
|
|
||||||
fvdbg("Entry\n");
|
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);
|
(void)nfs_getfsinfo(nmp, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
error = nfs_readdirrpc(nmp, np, eof, dir);
|
error = nfs_readdirrpc(nmp, np, dir);
|
||||||
|
|
||||||
if (error == NFSERR_BAD_COOKIE)
|
if (error == NFSERR_BAD_COOKIE)
|
||||||
{
|
{
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
goto errout_with_semaphore;
|
goto errout_with_semaphore;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if (!error && eof)
|
if (!error && eof)
|
||||||
{
|
{
|
||||||
nfsstats.direofcache_misses++;
|
nfsstats.direofcache_misses++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
success_with_semaphore:
|
success_with_semaphore:
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|||||||
+1
-1
@@ -461,7 +461,7 @@ void uip_input(struct uip_driver_s *dev)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!uip_ipaddr_cmp(pbuf->destipaddr, dev->d_ipaddr) &&
|
if (!uip_ipaddr_cmp(pbuf->destipaddr, dev->d_ipaddr) &&
|
||||||
(pbuf->destipaddr[0] & 0xffff) != 0xff02)
|
pbuf->destipaddr[0] != 0xff02)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_STATISTICS
|
#ifdef CONFIG_NET_STATISTICS
|
||||||
uip_stat.ip.drop++;
|
uip_stat.ip.drop++;
|
||||||
|
|||||||
Reference in New Issue
Block a user