FreeBSD/sys/fs/nfsclient/nfs_clvnops.c
/*
 * Return POSIX pathconf information applicable to nfs filesystems.
 */
Return POSIX pathconf information applicable to nfs filesystems.
Return POSIX pathconf information applicable to nfs filesystems .
static int
nfs_pathconf(struct vop_pathconf_args *ap)
{
	struct nfsv3_pathconf pc;
	struct nfsvattr nfsva;
	struct vnode *vp = ap->a_vp;
	struct thread *td = curthread;
	int attrflag, error;
	if ((NFS_ISV34(vp) && (ap->a_name == _PC_LINK_MAX ||
	    ap->a_name == _PC_NAME_MAX || ap->a_name == _PC_CHOWN_RESTRICTED ||
	    ap->a_name == _PC_NO_TRUNC)) ||
	    (NFS_ISV4(vp) && ap->a_name == _PC_ACL_NFS4)) {
		error = nfsrpc_pathconf(vp, &pc, td->td_ucred, td, &nfsva,
		    &attrflag, NULL);
		if (attrflag != 0)
			(void) nfscl_loadattrcache(&vp, &nfsva, NULL, NULL, 0,
			    1);
		if (error != 0)
			return (error);
	} else {
		pc.pc_linkmax = LINK_MAX;
		pc.pc_namemax = NFS_MAXNAMLEN;
		pc.pc_notrunc = 1;
		pc.pc_chownrestricted = 1;
		pc.pc_caseinsensitive = 0;
		pc.pc_casepreserving = 1;
		error = 0;
	}
	switch (ap->a_name) {
	case _PC_LINK_MAX:
		*ap->a_retval = pc.pc_linkmax;
		break;
	case _PC_NAME_MAX:
		*ap->a_retval = pc.pc_namemax;
		break;
	case _PC_PATH_MAX:
		*ap->a_retval = PATH_MAX;
		break;
	case _PC_PIPE_BUF:
		*ap->a_retval = PIPE_BUF;
		break;
	case _PC_CHOWN_RESTRICTED:
		*ap->a_retval = pc.pc_chownrestricted;
		break;
	case _PC_NO_TRUNC:
		*ap->a_retval = pc.pc_notrunc;
		break;
	case _PC_ACL_EXTENDED:
		*ap->a_retval = 0;
		break;
	case _PC_ACL_NFS4:
		if (NFS_ISV4(vp) && nfsrv_useacl != 0 && attrflag != 0 &&
		    NFSISSET_ATTRBIT(&nfsva.na_suppattr, NFSATTRBIT_ACL))
			*ap->a_retval = 1;
		else
			*ap->a_retval = 0;
		break;
	case _PC_ACL_PATH_MAX:
		if (NFS_ISV4(vp))
			*ap->a_retval = ACL_MAX_ENTRIES;
		else
			*ap->a_retval = 3;
		break;
	case _PC_MAC_PRESENT:
		*ap->a_retval = 0;
		break;
	case _PC_ASYNC_IO:
		KASSERT(0, ("_PC_ASYNC_IO should not get here"));
		error = EINVAL;
		break;
	case _PC_PRIO_IO:
		*ap->a_retval = 0;
		break;
	case _PC_SYNC_IO:
		*ap->a_retval = 0;
		break;
	case _PC_ALLOC_SIZE_MIN:
		*ap->a_retval = vp->v_mount->mnt_stat.f_bsize;
		break;
	case _PC_FILESIZEBITS:
		if (NFS_ISV34(vp))
			*ap->a_retval = 64;
		else
			*ap->a_retval = 32;
		break;
	case _PC_REC_INCR_XFER_SIZE:
		*ap->a_retval = vp->v_mount->mnt_stat.f_iosize;
		break;
	case _PC_REC_MAX_XFER_SIZE:
		*ap->a_retval = -1; 
		break;
	case _PC_REC_MIN_XFER_SIZE:
		*ap->a_retval = vp->v_mount->mnt_stat.f_iosize;
		break;
	case _PC_REC_XFER_ALIGN:
		*ap->a_retval = PAGE_SIZE;
		break;
	case _PC_SYMLINK_MAX:
		*ap->a_retval = NFS_MAXPATHLEN;
		break;
	default:
		error = EINVAL;
		break;
	}
	return (error);
}
static int nfs_pathconf ( struct vop_pathconf_args * ap ) { struct nfsv3_pathconf pc ; struct nfsvattr nfsva ; struct vnode * vp = ap -> a_vp ; struct thread * td = curthread ; int attrflag , error ; if ( ( NFS_ISV34 ( vp ) && ( ap -> a_name == _PC_LINK_MAX || ap -> a_name == _PC_NAME_MAX || ap -> a_name == _PC_CHOWN_RESTRICTED || ap -> a_name == _PC_NO_TRUNC ) ) || ( NFS_ISV4 ( vp ) && ap -> a_name == _PC_ACL_NFS4 ) ) { error = nfsrpc_pathconf ( vp , & pc , td -> td_ucred , td , & nfsva , & attrflag , NULL ) ; if ( attrflag != 0 ) ( void ) nfscl_loadattrcache ( & vp , & nfsva , NULL , NULL , 0 , 1 ) ; if ( error != 0 ) return ( error ) ; } else { pc . pc_linkmax = LINK_MAX ; pc . pc_namemax = NFS_MAXNAMLEN ; pc . pc_notrunc = 1 ; pc . pc_chownrestricted = 1 ; pc . pc_caseinsensitive = 0 ; pc . pc_casepreserving = 1 ; error = 0 ; } switch ( ap -> a_name ) { case _PC_LINK_MAX : * ap -> a_retval = pc . pc_linkmax ; break ; case _PC_NAME_MAX : * ap -> a_retval = pc . pc_namemax ; break ; case _PC_PATH_MAX : * ap -> a_retval = PATH_MAX ; break ; case _PC_PIPE_BUF : * ap -> a_retval = PIPE_BUF ; break ; case _PC_CHOWN_RESTRICTED : * ap -> a_retval = pc . pc_chownrestricted ; break ; case _PC_NO_TRUNC : * ap -> a_retval = pc . pc_notrunc ; break ; case _PC_ACL_EXTENDED : * ap -> a_retval = 0 ; break ; case _PC_ACL_NFS4 : if ( NFS_ISV4 ( vp ) && nfsrv_useacl != 0 && attrflag != 0 && NFSISSET_ATTRBIT ( & nfsva . na_suppattr , NFSATTRBIT_ACL ) ) * ap -> a_retval = 1 ; else * ap -> a_retval = 0 ; break ; case _PC_ACL_PATH_MAX : if ( NFS_ISV4 ( vp ) ) * ap -> a_retval = ACL_MAX_ENTRIES ; else * ap -> a_retval = 3 ; break ; case _PC_MAC_PRESENT : * ap -> a_retval = 0 ; break ; case _PC_ASYNC_IO : KASSERT ( 0 , ( " " ) ) ; error = EINVAL ; break ; case _PC_PRIO_IO : * ap -> a_retval = 0 ; break ; case _PC_SYNC_IO : * ap -> a_retval = 0 ; break ; case _PC_ALLOC_SIZE_MIN : * ap -> a_retval = vp -> v_mount -> mnt_stat . f_bsize ; break ; case _PC_FILESIZEBITS : if ( NFS_ISV34 ( vp ) ) * ap -> a_retval = 64 ; else * ap -> a_retval = 32 ; break ; case _PC_REC_INCR_XFER_SIZE : * ap -> a_retval = vp -> v_mount -> mnt_stat . f_iosize ; break ; case _PC_REC_MAX_XFER_SIZE : * ap -> a_retval = -1 ; break ; case _PC_REC_MIN_XFER_SIZE : * ap -> a_retval = vp -> v_mount -> mnt_stat . f_iosize ; break ; case _PC_REC_XFER_ALIGN : * ap -> a_retval = PAGE_SIZE ; break ; case _PC_SYMLINK_MAX : * ap -> a_retval = NFS_MAXPATHLEN ; break ; default : error = EINVAL ; break ; } return ( error ) ; }
Return POSIX pathconf information applicable to nfs filesystems.
Return POSIX pathconf information applicable to nfs filesystems .
/*
		 * Since only the above 4 a_names are returned by the NFSv3
		 * Pathconf RPC, there is no point in doing it for others.
		 * For NFSv4, the Pathconf RPC (actually a Getattr Op.) can
		 * be used for _PC_NFS4_ACL as well.
		 */ /*
		 * For NFSv2 (or NFSv3 when not one of the above 4 a_names),
		 * just fake them.
		 */ /* _PC_ASYNC_IO should have been handled by upper layers. */ /* means ``unlimited'' */