Deleted Added
full compact
1c1
< /* $FreeBSD: head/lib/libstand/nfs.c 59824 2000-05-01 10:53:21Z ps $ */
---
> /* $FreeBSD: head/lib/libstand/nfs.c 59853 2000-05-01 15:03:52Z ps $ */
93a94,110
> struct nfs_readdir_args {
> u_char fh[NFS_FHSIZE];
> n_long cookie;
> n_long count;
> };
>
> struct nfs_readdir_data {
> n_long fileid;
> n_long len;
> char name[0];
> };
>
> struct nfs_readdir_off {
> n_long cookie;
> n_long follows;
> };
>
110a128
> static int nfs_readdir(struct open_file *f, struct dirent *d);
122c140
< null_readdir
---
> nfs_readdir
667a686,746
>
> static int
> nfs_readdir(struct open_file *f, struct dirent *d)
> {
> register struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
> struct nfs_readdir_args *args;
> struct nfs_readdir_data *rd;
> struct nfs_readdir_off *roff = NULL;
> static char *buf;
> static n_long cookie = 0;
> size_t cc;
> n_long eof;
>
> struct {
> n_long h[RPC_HEADER_WORDS];
> struct nfs_readdir_args d;
> } sdata;
> static struct {
> n_long h[RPC_HEADER_WORDS];
> u_char d[NFS_READDIRSIZE];
> } rdata;
>
> if (cookie == 0) {
> refill:
> args = &sdata.d;
> bzero(args, sizeof(*args));
>
> bcopy(fp->fh, args->fh, NFS_FHSIZE);
> args->cookie = htonl(cookie);
> args->count = htonl(NFS_READDIRSIZE);
>
> cc = rpc_call(fp->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READDIR,
> args, sizeof(*args),
> rdata.d, sizeof(rdata.d));
> buf = rdata.d;
> roff = (struct nfs_readdir_off *)buf;
> if (ntohl(roff->cookie) != 0)
> return 1;
> }
> roff = (struct nfs_readdir_off *)buf;
>
> if (ntohl(roff->follows) == 0) {
> eof = ntohl((roff+1)->cookie);
> if (eof) {
> cookie = 0;
> return 1;
> }
> goto refill;
> }
>
> buf += sizeof(struct nfs_readdir_off);
> rd = (struct nfs_readdir_data *)buf;
> d->d_namlen = ntohl(rd->len);
> bcopy(rd->name, d->d_name, d->d_namlen);
> d->d_name[d->d_namlen] = '\0';
>
> buf += (sizeof(struct nfs_readdir_data) + roundup(htonl(rd->len),4));
> roff = (struct nfs_readdir_off *)buf;
> cookie = ntohl(roff->cookie);
> return 0;
> }