FreeBSD/lib/libstand/nfs.c
/*
 * Fetch the root file handle (call mount daemon)
 * Return zero or error number.
 */
Fetch the root file handle (call mount daemon)
Return zero or error number.
Fetch the root file handle ( call mount daemon ) Return zero or error number .
int
nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
{
	int len;
	struct args {
		n_long	len;
		char	path[FNAME_SIZE];
	} *args;
	struct repl {
		n_long	errno;
		u_char	fh[NFS_FHSIZE];
	} *repl;
	struct {
		n_long	h[RPC_HEADER_WORDS];
		struct args d;
	} sdata;
	struct {
		n_long	h[RPC_HEADER_WORDS];
		struct repl d;
	} rdata;
	size_t cc;
#ifdef NFS_DEBUG
	if (debug)
		printf("nfs_getrootfh: %s\n", path);
#endif
	args = &sdata.d;
	repl = &rdata.d;
	bzero(args, sizeof(*args));
	len = strlen(path);
	if (len > sizeof(args->path))
		len = sizeof(args->path);
	args->len = htonl(len);
	bcopy(path, args->path, len);
	len = 4 + roundup(len, 4);
	cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT,
	    args, len, repl, sizeof(*repl));
	if (cc == -1) {
		return (errno);
	}
	if (cc < 4)
		return (EBADRPC);
	if (repl->errno)
		return (ntohl(repl->errno));
	bcopy(repl->fh, fhp, sizeof(repl->fh));
	return (0);
}
int nfs_getrootfh ( struct iodesc * d , char * path , u_char * fhp ) { int len ; struct args { n_long len ; char path [ FNAME_SIZE ] ; } * args ; struct repl { n_long errno ; u_char fh [ NFS_FHSIZE ] ; } * repl ; struct { n_long h [ RPC_HEADER_WORDS ] ; struct args d ; } sdata ; struct { n_long h [ RPC_HEADER_WORDS ] ; struct repl d ; } rdata ; size_t cc ; #ifdef NFS_DEBUG if ( debug ) printf ( " \n " , path ) ; #endif args = & sdata . d ; repl = & rdata . d ; bzero ( args , sizeof ( * args ) ) ; len = strlen ( path ) ; if ( len > sizeof ( args -> path ) ) len = sizeof ( args -> path ) ; args -> len = htonl ( len ) ; bcopy ( path , args -> path , len ) ; len = 4 + roundup ( len , 4 ) ; cc = rpc_call ( d , RPCPROG_MNT , RPCMNT_VER1 , RPCMNT_MOUNT , args , len , repl , sizeof ( * repl ) ) ; if ( cc == -1 ) { return ( errno ) ; } if ( cc < 4 ) return ( EBADRPC ) ; if ( repl -> errno ) return ( ntohl ( repl -> errno ) ) ; bcopy ( repl -> fh , fhp , sizeof ( repl -> fh ) ) ; return ( 0 ) ; }
Fetch the root file handle (call mount daemon)
 Return zero or error number.
Fetch the root file handle ( call mount daemon ) Return zero or error number .
/* errno was set by rpc_call */