FreeBSD/lib/libstand/nfs.c
/*
 * Lookup a file.  Store handle and attributes.
 * Return zero or error number.
 */
Lookup a file.  Store handle and attributes.
Return zero or error number.
Lookup a file . Store handle and attributes . Return zero or error number .
int
nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd)
{
	int len, rlen;
	struct args {
		u_char	fh[NFS_FHSIZE];
		n_long	len;
		char	name[FNAME_SIZE];
	} *args;
	struct repl {
		n_long	errno;
		u_char	fh[NFS_FHSIZE];
		struct	nfsv2_fattrs fa;
	} *repl;
	struct {
		n_long	h[RPC_HEADER_WORDS];
		struct args d;
	} sdata;
	struct {
		n_long	h[RPC_HEADER_WORDS];
		struct repl d;
	} rdata;
	ssize_t cc;
#ifdef NFS_DEBUG
	if (debug)
		printf("lookupfh: called\n");
#endif
	args = &sdata.d;
	repl = &rdata.d;
	bzero(args, sizeof(*args));
	bcopy(d->fh, args->fh, sizeof(args->fh));
	len = strlen(name);
	if (len > sizeof(args->name))
		len = sizeof(args->name);
	bcopy(name, args->name, len);
	args->len = htonl(len);
	len = 4 + roundup(len, 4);
	len += NFS_FHSIZE;
	rlen = sizeof(*repl);
	cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP,
	    args, len, repl, rlen);
	if (cc == -1)
		return (errno);		
	if (cc < 4)
		return (EIO);
	if (repl->errno) {
		return (ntohl(repl->errno));
	}
	bcopy( repl->fh, &newfd->fh, sizeof(newfd->fh));
	bcopy(&repl->fa, &newfd->fa, sizeof(newfd->fa));
	return (0);
}
int nfs_lookupfh ( struct nfs_iodesc * d , const char * name , struct nfs_iodesc * newfd ) { int len , rlen ; struct args { u_char fh [ NFS_FHSIZE ] ; n_long len ; char name [ FNAME_SIZE ] ; } * args ; struct repl { n_long errno ; u_char fh [ NFS_FHSIZE ] ; struct nfsv2_fattrs fa ; } * repl ; struct { n_long h [ RPC_HEADER_WORDS ] ; struct args d ; } sdata ; struct { n_long h [ RPC_HEADER_WORDS ] ; struct repl d ; } rdata ; ssize_t cc ; #ifdef NFS_DEBUG if ( debug ) printf ( " \n " ) ; #endif args = & sdata . d ; repl = & rdata . d ; bzero ( args , sizeof ( * args ) ) ; bcopy ( d -> fh , args -> fh , sizeof ( args -> fh ) ) ; len = strlen ( name ) ; if ( len > sizeof ( args -> name ) ) len = sizeof ( args -> name ) ; bcopy ( name , args -> name , len ) ; args -> len = htonl ( len ) ; len = 4 + roundup ( len , 4 ) ; len += NFS_FHSIZE ; rlen = sizeof ( * repl ) ; cc = rpc_call ( d -> iodesc , NFS_PROG , NFS_VER2 , NFSPROC_LOOKUP , args , len , repl , rlen ) ; if ( cc == -1 ) return ( errno ) ; if ( cc < 4 ) return ( EIO ) ; if ( repl -> errno ) { return ( ntohl ( repl -> errno ) ) ; } bcopy ( repl -> fh , & newfd -> fh , sizeof ( newfd -> fh ) ) ; bcopy ( & repl -> fa , & newfd -> fa , sizeof ( newfd -> fa ) ) ; return ( 0 ) ; }
Lookup a file.
Lookup a file .
/* XXX - from rpc_call */ /* saerrno.h now matches NFS error numbers. */