FreeBSD/lib/libstand/nfs.c
/*
 * read a portion of a file
 */
read a portion of a file
read a portion of a file
int
nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
{
	struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
	ssize_t cc;
	char *addr = buf;
#ifdef NFS_DEBUG
	if (debug)
		printf("nfs_read: size=%lu off=%d\n", (u_long)size,
		       (int)fp->off);
#endif
	while ((int)size > 0) {
		twiddle(16);
		cc = nfs_readdata(fp, fp->off, (void *)addr, size);
		if (cc == -1) {
#ifdef NFS_DEBUG
			if (debug)
				printf("nfs_read: read: %s", strerror(errno));
#endif
			return (errno);	
		}
		if (cc == 0) {
#ifdef NFS_DEBUG
			if (debug)
				printf("nfs_read: hit EOF unexpectantly");
#endif
			goto ret;
		}
		fp->off += cc;
		addr += cc;
		size -= cc;
	}
ret:
	if (resid)
		*resid = size;
	return (0);
}
int nfs_read ( struct open_file * f , void * buf , size_t size , size_t * resid ) { struct nfs_iodesc * fp = ( struct nfs_iodesc * ) f -> f_fsdata ; ssize_t cc ; char * addr = buf ; #ifdef NFS_DEBUG if ( debug ) printf ( " \n " , ( u_long ) size , ( int ) fp -> off ) ; #endif while ( ( int ) size > 0 ) { twiddle ( 16 ) ; cc = nfs_readdata ( fp , fp -> off , ( void * ) addr , size ) ; if ( cc == -1 ) { #ifdef NFS_DEBUG if ( debug ) printf ( " " , strerror ( errno ) ) ; #endif return ( errno ) ; } if ( cc == 0 ) { #ifdef NFS_DEBUG if ( debug ) printf ( " " ) ; #endif goto ret ; } fp -> off += cc ; addr += cc ; size -= cc ; } ret : if ( resid ) * resid = size ; return ( 0 ) ; }
read a portion of a file
read a portion of a file
/* XXX maybe should retry on certain errors */ /* XXX - from nfs_readdata */