Lines Matching +full:pkt +full:- +full:size
3 /*-
89 * For NFSv3, the file handle is variable in size, so most fixed sized
91 * that starts with any fixed size section is followed by an array
92 * that covers the maximum size required.
125 static int nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
185 void *pkt = NULL; in nfs_getrootfh() local
213 if (len > sizeof(args->path)) in nfs_getrootfh()
214 len = sizeof(args->path); in nfs_getrootfh()
215 args->len = htonl(len); in nfs_getrootfh()
216 bcopy(path, args->path, len); in nfs_getrootfh()
220 args, len, (void **)&repl, &pkt); in nfs_getrootfh()
221 if (cc == -1) { in nfs_getrootfh()
222 free(pkt); in nfs_getrootfh()
227 free(pkt); in nfs_getrootfh()
230 if (repl->errno != 0) { in nfs_getrootfh()
231 free(pkt); in nfs_getrootfh()
232 return (ntohl(repl->errno)); in nfs_getrootfh()
234 *fhlenp = ntohl(repl->fhsize); in nfs_getrootfh()
235 bcopy(repl->fh, fhp, *fhlenp); in nfs_getrootfh()
238 free(pkt); in nfs_getrootfh()
249 void *pkt = NULL; in nfs_lookupfh() local
277 args->fhsize = htonl(d->fhsize); in nfs_lookupfh()
278 bcopy(d->fh, args->fhplusname, d->fhsize); in nfs_lookupfh()
282 pos = roundup(d->fhsize, sizeof(uint32_t)) / sizeof(uint32_t); in nfs_lookupfh()
283 args->fhplusname[pos++] = htonl(len); in nfs_lookupfh()
284 bcopy(name, &args->fhplusname[pos], len); in nfs_lookupfh()
288 cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_LOOKUP, in nfs_lookupfh()
289 args, len, (void **)&repl, &pkt); in nfs_lookupfh()
290 if (cc == -1) { in nfs_lookupfh()
291 free(pkt); in nfs_lookupfh()
292 return (errno); /* XXX - from rpc_call */ in nfs_lookupfh()
295 free(pkt); in nfs_lookupfh()
298 if (repl->errno != 0) { in nfs_lookupfh()
299 free(pkt); in nfs_lookupfh()
301 return (ntohl(repl->errno)); in nfs_lookupfh()
303 newfd->fhsize = ntohl(repl->fhsize); in nfs_lookupfh()
304 bcopy(repl->fhplusattr, &newfd->fh, newfd->fhsize); in nfs_lookupfh()
305 pos = roundup(newfd->fhsize, sizeof(uint32_t)) / sizeof(uint32_t); in nfs_lookupfh()
306 if (repl->fhplusattr[pos++] == 0) { in nfs_lookupfh()
307 free(pkt); in nfs_lookupfh()
310 bcopy(&repl->fhplusattr[pos], &newfd->fa, sizeof(newfd->fa)); in nfs_lookupfh()
311 free(pkt); in nfs_lookupfh()
322 void *pkt = NULL; in nfs_readlink() local
349 args->fhsize = htonl(d->fhsize); in nfs_readlink()
350 bcopy(d->fh, args->fh, d->fhsize); in nfs_readlink()
351 cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READLINK, in nfs_readlink()
352 args, sizeof(uint32_t) + roundup(d->fhsize, sizeof(uint32_t)), in nfs_readlink()
353 (void **)&repl, &pkt); in nfs_readlink()
354 if (cc == -1) in nfs_readlink()
362 if (repl->errno != 0) { in nfs_readlink()
363 rc = ntohl(repl->errno); in nfs_readlink()
367 if (repl->ok == 0) { in nfs_readlink()
372 repl->len = ntohl(repl->len); in nfs_readlink()
373 if (repl->len > NFS_MAXPATHLEN) { in nfs_readlink()
378 bcopy(repl->path, buf, repl->len); in nfs_readlink()
379 buf[repl->len] = 0; in nfs_readlink()
381 free(pkt); in nfs_readlink()
388 * Return transfer count or -1 (and set errno)
393 void *pkt = NULL; in nfs_readdata() local
418 args->fhsize = htonl(d->fhsize); in nfs_readdata()
419 bcopy(d->fh, args->fhoffcnt, d->fhsize); in nfs_readdata()
420 pos = roundup(d->fhsize, sizeof(uint32_t)) / sizeof(uint32_t); in nfs_readdata()
421 args->fhoffcnt[pos++] = 0; in nfs_readdata()
422 args->fhoffcnt[pos++] = htonl((uint32_t)off); in nfs_readdata()
425 args->fhoffcnt[pos] = htonl((uint32_t)len); in nfs_readdata()
428 cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READ, in nfs_readdata()
429 args, 4 * sizeof(uint32_t) + roundup(d->fhsize, sizeof(uint32_t)), in nfs_readdata()
430 (void **)&repl, &pkt); in nfs_readdata()
431 if (cc == -1) { in nfs_readdata()
433 return (-1); in nfs_readdata()
437 free(pkt); in nfs_readdata()
438 return (-1); in nfs_readdata()
440 if (repl->errno != 0) { in nfs_readdata()
441 errno = ntohl(repl->errno); in nfs_readdata()
442 free(pkt); in nfs_readdata()
443 return (-1); in nfs_readdata()
445 rlen = cc - hlen; in nfs_readdata()
446 x = ntohl(repl->count); in nfs_readdata()
450 free(pkt); in nfs_readdata()
451 return (-1); in nfs_readdata()
453 bcopy(repl->data, addr, x); in nfs_readdata()
454 free(pkt); in nfs_readdata()
486 dev = f->f_devdata; in nfs_open()
497 if (f->f_dev->dv_type != DEVT_NET) in nfs_open()
500 if (!(desc = socktodesc(*(int *)(dev->d_opendata)))) in nfs_open()
504 desc->myport = htons(--rpc_port); in nfs_open()
505 desc->destip = rootip; in nfs_open()
553 if (currfd->fa.fa_type != htonl(NFDIR)) { in nfs_open()
564 newfd->iodesc = currfd->iodesc; in nfs_open()
592 if (newfd->fa.fa_type == htonl(NFLNK)) { in nfs_open()
636 currfd->iodesc = desc; in nfs_open()
641 currfd->off = 0; in nfs_open()
642 currfd->cookie = 0; in nfs_open()
643 f->f_fsdata = (void *)currfd; in nfs_open()
660 struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; in nfs_close()
668 f->f_fsdata = NULL; in nfs_close()
677 nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid) in nfs_read() argument
679 struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; in nfs_read()
685 printf("nfs_read: size=%lu off=%d\n", (u_long)size, in nfs_read()
686 (int)fp->off); in nfs_read()
688 while ((int)size > 0) { in nfs_read()
690 cc = nfs_readdata(fp, fp->off, (void *)addr, size); in nfs_read()
692 if (cc == -1) { in nfs_read()
697 return (errno); /* XXX - from nfs_readdata */ in nfs_read()
706 fp->off += cc; in nfs_read()
708 size -= cc; in nfs_read()
712 *resid = size; in nfs_read()
720 struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata; in nfs_seek()
721 uint32_t size = ntohl(d->fa.fa_size.val[1]); in nfs_seek() local
725 d->off = offset; in nfs_seek()
728 d->off += offset; in nfs_seek()
731 d->off = size - offset; in nfs_seek()
735 return (-1); in nfs_seek()
738 return (d->off); in nfs_seek()
748 struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; in nfs_stat()
751 ftype = ntohl(fp->fa.fa_type); in nfs_stat()
752 mode = ntohl(fp->fa.fa_mode); in nfs_stat()
755 sb->st_mode = mode; in nfs_stat()
756 sb->st_nlink = ntohl(fp->fa.fa_nlink); in nfs_stat()
757 sb->st_uid = ntohl(fp->fa.fa_uid); in nfs_stat()
758 sb->st_gid = ntohl(fp->fa.fa_gid); in nfs_stat()
759 sb->st_size = ntohl(fp->fa.fa_size.val[1]); in nfs_stat()
767 struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; in nfs_readdir()
770 static void *pkt = NULL; in nfs_readdir() local
786 if (fp != pfp || fp->off != cookie) { in nfs_readdir()
789 free(pkt); in nfs_readdir()
790 pkt = NULL; in nfs_readdir()
794 args->fhsize = htonl(fp->fhsize); in nfs_readdir()
795 bcopy(fp->fh, args->fhpluscookie, fp->fhsize); in nfs_readdir()
796 pos = roundup(fp->fhsize, sizeof(uint32_t)) / sizeof(uint32_t); in nfs_readdir()
797 args->fhpluscookie[pos++] = htonl(fp->off >> 32); in nfs_readdir()
798 args->fhpluscookie[pos++] = htonl(fp->off); in nfs_readdir()
799 args->fhpluscookie[pos++] = htonl(fp->cookie >> 32); in nfs_readdir()
800 args->fhpluscookie[pos++] = htonl(fp->cookie); in nfs_readdir()
801 args->fhpluscookie[pos] = htonl(NFS_READDIRSIZE); in nfs_readdir()
803 cc = rpc_call(fp->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READDIR, in nfs_readdir()
805 roundup(fp->fhsize, sizeof(uint32_t)), in nfs_readdir()
806 (void **)&buf, &pkt); in nfs_readdir()
807 if (cc == -1) { in nfs_readdir()
812 if (repl->errno != 0) { in nfs_readdir()
813 rc = ntohl(repl->errno); in nfs_readdir()
817 cookie = fp->off; in nfs_readdir()
818 fp->cookie = ((uint64_t)ntohl(repl->cookiev0) << 32) | in nfs_readdir()
819 ntohl(repl->cookiev1); in nfs_readdir()
824 if (rent->follows == 0) { in nfs_readdir()
826 if (rent->fid0 != 0) { in nfs_readdir()
833 d->d_namlen = ntohl(rent->len); in nfs_readdir()
834 bcopy(rent->nameplus, d->d_name, d->d_namlen); in nfs_readdir()
835 d->d_name[d->d_namlen] = '\0'; in nfs_readdir()
837 pos = roundup(d->d_namlen, sizeof(uint32_t)) / sizeof(uint32_t); in nfs_readdir()
838 fp->off = cookie = ((uint64_t)ntohl(rent->nameplus[pos]) << 32) | in nfs_readdir()
839 ntohl(rent->nameplus[pos + 1]); in nfs_readdir()
841 buf = (char *)&rent->nameplus[pos]; in nfs_readdir()
845 free(pkt); in nfs_readdir()
846 pkt = NULL; in nfs_readdir()