FreeBSD/lib/libstand/nfs.c
/*
 * Get the destination of a symbolic link.
 */
Get the destination of a symbolic link.
Get the destination of a symbolic link .
int
nfs_readlink(struct nfs_iodesc *d, char *buf)
{
	struct {
		n_long	h[RPC_HEADER_WORDS];
		u_char fh[NFS_FHSIZE];
	} sdata;
	struct {
		n_long	h[RPC_HEADER_WORDS];
		struct nfs_readlnk_repl d;
	} rdata;
	ssize_t cc;
#ifdef NFS_DEBUG
	if (debug)
		printf("readlink: called\n");
#endif
	bcopy(d->fh, sdata.fh, NFS_FHSIZE);
	cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK,
		      sdata.fh, NFS_FHSIZE,
		      &rdata.d, sizeof(rdata.d));
	if (cc == -1)
		return (errno);
	if (cc < 4)
		return (EIO);
	if (rdata.d.errno)
		return (ntohl(rdata.d.errno));
	rdata.d.len = ntohl(rdata.d.len);
	if (rdata.d.len > NFS_MAXPATHLEN)
		return (ENAMETOOLONG);
	bcopy(rdata.d.path, buf, rdata.d.len);
	buf[rdata.d.len] = 0;
	return (0);
}
int nfs_readlink ( struct nfs_iodesc * d , char * buf ) { struct { n_long h [ RPC_HEADER_WORDS ] ; u_char fh [ NFS_FHSIZE ] ; } sdata ; struct { n_long h [ RPC_HEADER_WORDS ] ; struct nfs_readlnk_repl d ; } rdata ; ssize_t cc ; #ifdef NFS_DEBUG if ( debug ) printf ( " \n " ) ; #endif bcopy ( d -> fh , sdata . fh , NFS_FHSIZE ) ; cc = rpc_call ( d -> iodesc , NFS_PROG , NFS_VER2 , NFSPROC_READLINK , sdata . fh , NFS_FHSIZE , & rdata . d , sizeof ( rdata . d ) ) ; if ( cc == -1 ) return ( errno ) ; if ( cc < 4 ) return ( EIO ) ; if ( rdata . d . errno ) return ( ntohl ( rdata . d . errno ) ) ; rdata . d . len = ntohl ( rdata . d . len ) ; if ( rdata . d . len > NFS_MAXPATHLEN ) return ( ENAMETOOLONG ) ; bcopy ( rdata . d . path , buf , rdata . d . len ) ; buf [ rdata . d . len ] = 0 ; return ( 0 ) ; }
Get the destination of a symbolic link.
Get the destination of a symbolic link .