17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
527242a7cSthurlow * Common Development and Distribution License (the "License").
627242a7cSthurlow * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
226764e83bSVallish Vaidyeshwara * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
2427246829SVitaliy Gusev *
25ef1d0734SMarcel Telka * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #include <sys/param.h>
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/systm.h>
317c478bd9Sstevel@tonic-gate #include <sys/cred.h>
327c478bd9Sstevel@tonic-gate #include <sys/proc.h>
337c478bd9Sstevel@tonic-gate #include <sys/user.h>
347c478bd9Sstevel@tonic-gate #include <sys/buf.h>
357c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
367c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
377c478bd9Sstevel@tonic-gate #include <sys/pathname.h>
387c478bd9Sstevel@tonic-gate #include <sys/uio.h>
397c478bd9Sstevel@tonic-gate #include <sys/file.h>
407c478bd9Sstevel@tonic-gate #include <sys/stat.h>
417c478bd9Sstevel@tonic-gate #include <sys/errno.h>
427c478bd9Sstevel@tonic-gate #include <sys/socket.h>
437c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
447c478bd9Sstevel@tonic-gate #include <sys/siginfo.h>
457c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
467c478bd9Sstevel@tonic-gate #include <sys/statvfs.h>
477c478bd9Sstevel@tonic-gate #include <sys/t_kuser.h>
487c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
497c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
507c478bd9Sstevel@tonic-gate #include <sys/acl.h>
517c478bd9Sstevel@tonic-gate #include <sys/dirent.h>
527c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
537c478bd9Sstevel@tonic-gate #include <sys/debug.h>
547c478bd9Sstevel@tonic-gate #include <sys/unistd.h>
557c478bd9Sstevel@tonic-gate #include <sys/vtrace.h>
567c478bd9Sstevel@tonic-gate #include <sys/mode.h>
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate #include <rpc/types.h>
597c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
607c478bd9Sstevel@tonic-gate #include <rpc/svc.h>
617c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate #include <nfs/nfs.h>
647c478bd9Sstevel@tonic-gate #include <nfs/export.h>
657c478bd9Sstevel@tonic-gate #include <nfs/nfssys.h>
667c478bd9Sstevel@tonic-gate #include <nfs/nfs_clnt.h>
677c478bd9Sstevel@tonic-gate #include <nfs/nfs_acl.h>
687c478bd9Sstevel@tonic-gate
69fa9e4066Sahrens #include <fs/fs_subr.h>
70fa9e4066Sahrens
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate * These are the interface routines for the server side of the
737c478bd9Sstevel@tonic-gate * NFS ACL server. See the NFS ACL protocol specification
747c478bd9Sstevel@tonic-gate * for a description of this interface.
757c478bd9Sstevel@tonic-gate */
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate /* ARGSUSED */
787c478bd9Sstevel@tonic-gate void
acl2_getacl(GETACL2args * args,GETACL2res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)797c478bd9Sstevel@tonic-gate acl2_getacl(GETACL2args *args, GETACL2res *resp, struct exportinfo *exi,
805cb0d679SMarcel Telka struct svc_req *req, cred_t *cr, bool_t ro)
817c478bd9Sstevel@tonic-gate {
827c478bd9Sstevel@tonic-gate int error;
837c478bd9Sstevel@tonic-gate vnode_t *vp;
847c478bd9Sstevel@tonic-gate vattr_t va;
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi);
877c478bd9Sstevel@tonic-gate if (vp == NULL) {
887c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE;
897c478bd9Sstevel@tonic-gate return;
907c478bd9Sstevel@tonic-gate }
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate bzero((caddr_t)&resp->resok.acl, sizeof (resp->resok.acl));
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_mask = args->mask;
957c478bd9Sstevel@tonic-gate
96da6c28aaSamw error = VOP_GETSECATTR(vp, &resp->resok.acl, 0, cr, NULL);
977c478bd9Sstevel@tonic-gate
986764e83bSVallish Vaidyeshwara if ((error == ENOSYS) && !(exi->exi_export.ex_flags & EX_NOACLFAB)) {
99fa9e4066Sahrens /*
100fa9e4066Sahrens * If the underlying file system doesn't support
101fa9e4066Sahrens * aclent_t type acls, fabricate an acl. This is
102fa9e4066Sahrens * required in order to to support existing clients
103fa9e4066Sahrens * that require the call to VOP_GETSECATTR to
104fa9e4066Sahrens * succeed while making the assumption that all
105fa9e4066Sahrens * file systems support aclent_t type acls. This
106fa9e4066Sahrens * causes problems for servers exporting ZFS file
107fa9e4066Sahrens * systems because ZFS supports ace_t type acls,
108fa9e4066Sahrens * and fails (with ENOSYS) when asked for aclent_t
109fa9e4066Sahrens * type acls.
110fa9e4066Sahrens *
111fa9e4066Sahrens * Note: if the fs_fab_acl() fails, we have other problems.
112fa9e4066Sahrens * This error should be returned to the caller.
113fa9e4066Sahrens */
114da6c28aaSamw error = fs_fab_acl(vp, &resp->resok.acl, 0, cr, NULL);
115fa9e4066Sahrens }
116fa9e4066Sahrens
1177c478bd9Sstevel@tonic-gate if (error) {
1187c478bd9Sstevel@tonic-gate VN_RELE(vp);
1197c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
1207c478bd9Sstevel@tonic-gate return;
1217c478bd9Sstevel@tonic-gate }
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
1247c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr);
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate VN_RELE(vp);
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate /* check for overflowed values */
1297c478bd9Sstevel@tonic-gate if (!error) {
1307c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr);
1317c478bd9Sstevel@tonic-gate }
1327c478bd9Sstevel@tonic-gate if (error) {
1337c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
1347c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 &&
1357c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) {
1367c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp,
1377c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t));
1387c478bd9Sstevel@tonic-gate }
1397c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 &&
1407c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) {
1417c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp,
1427c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t));
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate return;
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate resp->status = NFS_OK;
1487c478bd9Sstevel@tonic-gate if (!(args->mask & NA_ACL)) {
1497c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 &&
1507c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) {
1517c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp,
1527c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t));
1537c478bd9Sstevel@tonic-gate }
1547c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp = NULL;
1557c478bd9Sstevel@tonic-gate }
1567c478bd9Sstevel@tonic-gate if (!(args->mask & NA_DFACL)) {
1577c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 &&
1587c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) {
1597c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp,
1607c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t));
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp = NULL;
1637c478bd9Sstevel@tonic-gate }
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate
16627242a7cSthurlow void *
acl2_getacl_getfh(GETACL2args * args)1677c478bd9Sstevel@tonic-gate acl2_getacl_getfh(GETACL2args *args)
1687c478bd9Sstevel@tonic-gate {
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate return (&args->fh);
1717c478bd9Sstevel@tonic-gate }
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate void
acl2_getacl_free(GETACL2res * resp)1747c478bd9Sstevel@tonic-gate acl2_getacl_free(GETACL2res *resp)
1757c478bd9Sstevel@tonic-gate {
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate if (resp->status == NFS_OK) {
1787c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 &&
1797c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) {
1807c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp,
1817c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t));
1827c478bd9Sstevel@tonic-gate }
1837c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 &&
1847c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) {
1857c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp,
1867c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t));
1877c478bd9Sstevel@tonic-gate }
1887c478bd9Sstevel@tonic-gate }
1897c478bd9Sstevel@tonic-gate }
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate /* ARGSUSED */
1927c478bd9Sstevel@tonic-gate void
acl2_setacl(SETACL2args * args,SETACL2res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)1937c478bd9Sstevel@tonic-gate acl2_setacl(SETACL2args *args, SETACL2res *resp, struct exportinfo *exi,
1945cb0d679SMarcel Telka struct svc_req *req, cred_t *cr, bool_t ro)
1957c478bd9Sstevel@tonic-gate {
1967c478bd9Sstevel@tonic-gate int error;
1977c478bd9Sstevel@tonic-gate vnode_t *vp;
1987c478bd9Sstevel@tonic-gate vattr_t va;
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi);
2017c478bd9Sstevel@tonic-gate if (vp == NULL) {
2027c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE;
2037c478bd9Sstevel@tonic-gate return;
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate
2065cb0d679SMarcel Telka if (rdonly(ro, vp)) {
2077c478bd9Sstevel@tonic-gate VN_RELE(vp);
2087c478bd9Sstevel@tonic-gate resp->status = NFSERR_ROFS;
2097c478bd9Sstevel@tonic-gate return;
2107c478bd9Sstevel@tonic-gate }
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate (void) VOP_RWLOCK(vp, V_WRITELOCK_TRUE, NULL);
213da6c28aaSamw error = VOP_SETSECATTR(vp, &args->acl, 0, cr, NULL);
2147c478bd9Sstevel@tonic-gate if (error) {
2157c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL);
2167c478bd9Sstevel@tonic-gate VN_RELE(vp);
2177c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
2187c478bd9Sstevel@tonic-gate return;
2197c478bd9Sstevel@tonic-gate }
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
2227c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr);
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL);
2257c478bd9Sstevel@tonic-gate VN_RELE(vp);
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate /* check for overflowed values */
2287c478bd9Sstevel@tonic-gate if (!error) {
2297c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr);
2307c478bd9Sstevel@tonic-gate }
2317c478bd9Sstevel@tonic-gate if (error) {
2327c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
2337c478bd9Sstevel@tonic-gate return;
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate resp->status = NFS_OK;
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate
23927242a7cSthurlow void *
acl2_setacl_getfh(SETACL2args * args)2407c478bd9Sstevel@tonic-gate acl2_setacl_getfh(SETACL2args *args)
2417c478bd9Sstevel@tonic-gate {
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate return (&args->fh);
2447c478bd9Sstevel@tonic-gate }
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate /* ARGSUSED */
2477c478bd9Sstevel@tonic-gate void
acl2_getattr(GETATTR2args * args,GETATTR2res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)2487c478bd9Sstevel@tonic-gate acl2_getattr(GETATTR2args *args, GETATTR2res *resp, struct exportinfo *exi,
2495cb0d679SMarcel Telka struct svc_req *req, cred_t *cr, bool_t ro)
2507c478bd9Sstevel@tonic-gate {
2517c478bd9Sstevel@tonic-gate int error;
2527c478bd9Sstevel@tonic-gate vnode_t *vp;
2537c478bd9Sstevel@tonic-gate vattr_t va;
2547c478bd9Sstevel@tonic-gate
2557c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi);
2567c478bd9Sstevel@tonic-gate if (vp == NULL) {
2577c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE;
2587c478bd9Sstevel@tonic-gate return;
2597c478bd9Sstevel@tonic-gate }
2607c478bd9Sstevel@tonic-gate
2617c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
2627c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr);
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gate VN_RELE(vp);
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gate /* check for overflowed values */
2677c478bd9Sstevel@tonic-gate if (!error) {
2687c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr);
2697c478bd9Sstevel@tonic-gate }
2707c478bd9Sstevel@tonic-gate if (error) {
2717c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
2727c478bd9Sstevel@tonic-gate return;
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate
2757c478bd9Sstevel@tonic-gate resp->status = NFS_OK;
2767c478bd9Sstevel@tonic-gate }
2777c478bd9Sstevel@tonic-gate
27827242a7cSthurlow void *
acl2_getattr_getfh(GETATTR2args * args)2797c478bd9Sstevel@tonic-gate acl2_getattr_getfh(GETATTR2args *args)
2807c478bd9Sstevel@tonic-gate {
2817c478bd9Sstevel@tonic-gate
2827c478bd9Sstevel@tonic-gate return (&args->fh);
2837c478bd9Sstevel@tonic-gate }
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate /* ARGSUSED */
2867c478bd9Sstevel@tonic-gate void
acl2_access(ACCESS2args * args,ACCESS2res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)2877c478bd9Sstevel@tonic-gate acl2_access(ACCESS2args *args, ACCESS2res *resp, struct exportinfo *exi,
2885cb0d679SMarcel Telka struct svc_req *req, cred_t *cr, bool_t ro)
2897c478bd9Sstevel@tonic-gate {
2907c478bd9Sstevel@tonic-gate int error;
2917c478bd9Sstevel@tonic-gate vnode_t *vp;
2927c478bd9Sstevel@tonic-gate vattr_t va;
2937c478bd9Sstevel@tonic-gate int checkwriteperm;
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi);
2967c478bd9Sstevel@tonic-gate if (vp == NULL) {
2977c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE;
2987c478bd9Sstevel@tonic-gate return;
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate /*
3027c478bd9Sstevel@tonic-gate * If the file system is exported read only, it is not appropriate
3037c478bd9Sstevel@tonic-gate * to check write permissions for regular files and directories.
3047c478bd9Sstevel@tonic-gate * Special files are interpreted by the client, so the underlying
3057c478bd9Sstevel@tonic-gate * permissions are sent back to the client for interpretation.
3067c478bd9Sstevel@tonic-gate */
3075cb0d679SMarcel Telka if (rdonly(ro, vp) && (vp->v_type == VREG || vp->v_type == VDIR))
3087c478bd9Sstevel@tonic-gate checkwriteperm = 0;
3097c478bd9Sstevel@tonic-gate else
3107c478bd9Sstevel@tonic-gate checkwriteperm = 1;
3117c478bd9Sstevel@tonic-gate
3127c478bd9Sstevel@tonic-gate /*
3137c478bd9Sstevel@tonic-gate * We need the mode so that we can correctly determine access
3147c478bd9Sstevel@tonic-gate * permissions relative to a mandatory lock file. Access to
3157c478bd9Sstevel@tonic-gate * mandatory lock files is denied on the server, so it might
3167c478bd9Sstevel@tonic-gate * as well be reflected to the server during the open.
3177c478bd9Sstevel@tonic-gate */
3187c478bd9Sstevel@tonic-gate va.va_mask = AT_MODE;
319da6c28aaSamw error = VOP_GETATTR(vp, &va, 0, cr, NULL);
3207c478bd9Sstevel@tonic-gate if (error) {
3217c478bd9Sstevel@tonic-gate VN_RELE(vp);
3227c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
3237c478bd9Sstevel@tonic-gate return;
3247c478bd9Sstevel@tonic-gate }
3257c478bd9Sstevel@tonic-gate
3267c478bd9Sstevel@tonic-gate resp->resok.access = 0;
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate if (args->access & ACCESS2_READ) {
329da6c28aaSamw error = VOP_ACCESS(vp, VREAD, 0, cr, NULL);
3307c478bd9Sstevel@tonic-gate if (!error && !MANDLOCK(vp, va.va_mode))
3317c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_READ;
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate if ((args->access & ACCESS2_LOOKUP) && vp->v_type == VDIR) {
334da6c28aaSamw error = VOP_ACCESS(vp, VEXEC, 0, cr, NULL);
3357c478bd9Sstevel@tonic-gate if (!error)
3367c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_LOOKUP;
3377c478bd9Sstevel@tonic-gate }
3387c478bd9Sstevel@tonic-gate if (checkwriteperm &&
3397c478bd9Sstevel@tonic-gate (args->access & (ACCESS2_MODIFY|ACCESS2_EXTEND))) {
340da6c28aaSamw error = VOP_ACCESS(vp, VWRITE, 0, cr, NULL);
3417c478bd9Sstevel@tonic-gate if (!error && !MANDLOCK(vp, va.va_mode))
3427c478bd9Sstevel@tonic-gate resp->resok.access |=
3437c478bd9Sstevel@tonic-gate (args->access & (ACCESS2_MODIFY|ACCESS2_EXTEND));
3447c478bd9Sstevel@tonic-gate }
3457c478bd9Sstevel@tonic-gate if (checkwriteperm &&
3467c478bd9Sstevel@tonic-gate (args->access & ACCESS2_DELETE) && (vp->v_type == VDIR)) {
347da6c28aaSamw error = VOP_ACCESS(vp, VWRITE, 0, cr, NULL);
3487c478bd9Sstevel@tonic-gate if (!error)
3497c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_DELETE;
3507c478bd9Sstevel@tonic-gate }
3517c478bd9Sstevel@tonic-gate if (args->access & ACCESS2_EXECUTE) {
352da6c28aaSamw error = VOP_ACCESS(vp, VEXEC, 0, cr, NULL);
3537c478bd9Sstevel@tonic-gate if (!error && !MANDLOCK(vp, va.va_mode))
3547c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_EXECUTE;
3557c478bd9Sstevel@tonic-gate }
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
3587c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr);
3597c478bd9Sstevel@tonic-gate
3607c478bd9Sstevel@tonic-gate VN_RELE(vp);
3617c478bd9Sstevel@tonic-gate
3627c478bd9Sstevel@tonic-gate /* check for overflowed values */
3637c478bd9Sstevel@tonic-gate if (!error) {
3647c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr);
3657c478bd9Sstevel@tonic-gate }
3667c478bd9Sstevel@tonic-gate if (error) {
3677c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
3687c478bd9Sstevel@tonic-gate return;
3697c478bd9Sstevel@tonic-gate }
3707c478bd9Sstevel@tonic-gate
3717c478bd9Sstevel@tonic-gate resp->status = NFS_OK;
3727c478bd9Sstevel@tonic-gate }
3737c478bd9Sstevel@tonic-gate
37427242a7cSthurlow void *
acl2_access_getfh(ACCESS2args * args)3757c478bd9Sstevel@tonic-gate acl2_access_getfh(ACCESS2args *args)
3767c478bd9Sstevel@tonic-gate {
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gate return (&args->fh);
3797c478bd9Sstevel@tonic-gate }
3807c478bd9Sstevel@tonic-gate
3817c478bd9Sstevel@tonic-gate /* ARGSUSED */
3827c478bd9Sstevel@tonic-gate void
acl2_getxattrdir(GETXATTRDIR2args * args,GETXATTRDIR2res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)3837c478bd9Sstevel@tonic-gate acl2_getxattrdir(GETXATTRDIR2args *args, GETXATTRDIR2res *resp,
3845cb0d679SMarcel Telka struct exportinfo *exi, struct svc_req *req, cred_t *cr, bool_t ro)
3857c478bd9Sstevel@tonic-gate {
3867c478bd9Sstevel@tonic-gate int error;
3877c478bd9Sstevel@tonic-gate int flags;
3887c478bd9Sstevel@tonic-gate vnode_t *vp, *avp;
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi);
3917c478bd9Sstevel@tonic-gate if (vp == NULL) {
3927c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE;
3937c478bd9Sstevel@tonic-gate return;
3947c478bd9Sstevel@tonic-gate }
3957c478bd9Sstevel@tonic-gate
3967c478bd9Sstevel@tonic-gate flags = LOOKUP_XATTR;
3977c478bd9Sstevel@tonic-gate if (args->create)
3987c478bd9Sstevel@tonic-gate flags |= CREATE_XATTR_DIR;
3997c478bd9Sstevel@tonic-gate else {
4007c478bd9Sstevel@tonic-gate ulong_t val = 0;
40193aeed83Smarks error = VOP_PATHCONF(vp, _PC_SATTR_EXISTS, &val, cr, NULL);
40293aeed83Smarks if (!error && val == 0) {
40393aeed83Smarks error = VOP_PATHCONF(vp, _PC_XATTR_EXISTS,
40493aeed83Smarks &val, cr, NULL);
4057c478bd9Sstevel@tonic-gate if (!error && val == 0) {
4067c478bd9Sstevel@tonic-gate VN_RELE(vp);
4077c478bd9Sstevel@tonic-gate resp->status = NFSERR_NOENT;
4087c478bd9Sstevel@tonic-gate return;
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate }
41193aeed83Smarks }
4127c478bd9Sstevel@tonic-gate
413da6c28aaSamw error = VOP_LOOKUP(vp, "", &avp, NULL, flags, NULL, cr,
414da6c28aaSamw NULL, NULL, NULL);
4157c478bd9Sstevel@tonic-gate if (!error && avp == vp) { /* lookup of "" on old FS? */
4167c478bd9Sstevel@tonic-gate error = EINVAL;
4177c478bd9Sstevel@tonic-gate VN_RELE(avp);
4187c478bd9Sstevel@tonic-gate }
4197c478bd9Sstevel@tonic-gate if (!error) {
4207c478bd9Sstevel@tonic-gate struct vattr va;
4217c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
4227c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(avp, &va, 0, cr);
4237c478bd9Sstevel@tonic-gate if (!error) {
4247c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr);
4257c478bd9Sstevel@tonic-gate if (!error)
4267c478bd9Sstevel@tonic-gate error = makefh(&resp->resok.fh, avp, exi);
4277c478bd9Sstevel@tonic-gate }
4287c478bd9Sstevel@tonic-gate VN_RELE(avp);
4297c478bd9Sstevel@tonic-gate }
4307c478bd9Sstevel@tonic-gate
4317c478bd9Sstevel@tonic-gate VN_RELE(vp);
4327c478bd9Sstevel@tonic-gate
4337c478bd9Sstevel@tonic-gate if (error) {
4347c478bd9Sstevel@tonic-gate resp->status = puterrno(error);
4357c478bd9Sstevel@tonic-gate return;
4367c478bd9Sstevel@tonic-gate }
4377c478bd9Sstevel@tonic-gate resp->status = NFS_OK;
4387c478bd9Sstevel@tonic-gate }
4397c478bd9Sstevel@tonic-gate
44027242a7cSthurlow void *
acl2_getxattrdir_getfh(GETXATTRDIR2args * args)4417c478bd9Sstevel@tonic-gate acl2_getxattrdir_getfh(GETXATTRDIR2args *args)
4427c478bd9Sstevel@tonic-gate {
4437c478bd9Sstevel@tonic-gate return (&args->fh);
4447c478bd9Sstevel@tonic-gate }
4457c478bd9Sstevel@tonic-gate
4467c478bd9Sstevel@tonic-gate void
acl3_getacl(GETACL3args * args,GETACL3res * resp,struct exportinfo * exi,struct svc_req * req __unused,cred_t * cr,bool_t ro __unused)4477c478bd9Sstevel@tonic-gate acl3_getacl(GETACL3args *args, GETACL3res *resp, struct exportinfo *exi,
448*f44e1126SVitaliy Gusev struct svc_req *req __unused, cred_t *cr, bool_t ro __unused)
4497c478bd9Sstevel@tonic-gate {
4507c478bd9Sstevel@tonic-gate int error;
4517c478bd9Sstevel@tonic-gate vnode_t *vp;
4527c478bd9Sstevel@tonic-gate vattr_t *vap;
4537c478bd9Sstevel@tonic-gate vattr_t va;
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate vap = NULL;
4567c478bd9Sstevel@tonic-gate
4577c478bd9Sstevel@tonic-gate vp = nfs3_fhtovp(&args->fh, exi);
4587c478bd9Sstevel@tonic-gate if (vp == NULL) {
4597c478bd9Sstevel@tonic-gate error = ESTALE;
4607c478bd9Sstevel@tonic-gate goto out;
4617c478bd9Sstevel@tonic-gate }
4627c478bd9Sstevel@tonic-gate
4637c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
4647c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
4657c478bd9Sstevel@tonic-gate
4667c478bd9Sstevel@tonic-gate bzero((caddr_t)&resp->resok.acl, sizeof (resp->resok.acl));
4677c478bd9Sstevel@tonic-gate
4687c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_mask = args->mask;
4697c478bd9Sstevel@tonic-gate
470da6c28aaSamw error = VOP_GETSECATTR(vp, &resp->resok.acl, 0, cr, NULL);
4717c478bd9Sstevel@tonic-gate
4726764e83bSVallish Vaidyeshwara if ((error == ENOSYS) && !(exi->exi_export.ex_flags & EX_NOACLFAB)) {
473fa9e4066Sahrens /*
474fa9e4066Sahrens * If the underlying file system doesn't support
475fa9e4066Sahrens * aclent_t type acls, fabricate an acl. This is
476fa9e4066Sahrens * required in order to to support existing clients
477fa9e4066Sahrens * that require the call to VOP_GETSECATTR to
478fa9e4066Sahrens * succeed while making the assumption that all
479fa9e4066Sahrens * file systems support aclent_t type acls. This
480fa9e4066Sahrens * causes problems for servers exporting ZFS file
481fa9e4066Sahrens * systems because ZFS supports ace_t type acls,
482fa9e4066Sahrens * and fails (with ENOSYS) when asked for aclent_t
483fa9e4066Sahrens * type acls.
484fa9e4066Sahrens *
485fa9e4066Sahrens * Note: if the fs_fab_acl() fails, we have other problems.
486fa9e4066Sahrens * This error should be returned to the caller.
487fa9e4066Sahrens */
488da6c28aaSamw error = fs_fab_acl(vp, &resp->resok.acl, 0, cr, NULL);
489fa9e4066Sahrens }
490fa9e4066Sahrens
4917c478bd9Sstevel@tonic-gate if (error)
4927c478bd9Sstevel@tonic-gate goto out;
4937c478bd9Sstevel@tonic-gate
4947c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
4957c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
4967c478bd9Sstevel@tonic-gate
4977c478bd9Sstevel@tonic-gate VN_RELE(vp);
4987c478bd9Sstevel@tonic-gate
4997c478bd9Sstevel@tonic-gate resp->status = NFS3_OK;
5007c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resok.attr);
5017c478bd9Sstevel@tonic-gate if (!(args->mask & NA_ACL)) {
5027c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 &&
5037c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) {
5047c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp,
5057c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t));
5067c478bd9Sstevel@tonic-gate }
5077c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp = NULL;
5087c478bd9Sstevel@tonic-gate }
5097c478bd9Sstevel@tonic-gate if (!(args->mask & NA_DFACL)) {
5107c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 &&
5117c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) {
5127c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp,
5137c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t));
5147c478bd9Sstevel@tonic-gate }
5157c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp = NULL;
5167c478bd9Sstevel@tonic-gate }
5177c478bd9Sstevel@tonic-gate return;
5187c478bd9Sstevel@tonic-gate
5197c478bd9Sstevel@tonic-gate out:
5207c478bd9Sstevel@tonic-gate if (curthread->t_flag & T_WOULDBLOCK) {
5217c478bd9Sstevel@tonic-gate curthread->t_flag &= ~T_WOULDBLOCK;
5227c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_JUKEBOX;
523*f44e1126SVitaliy Gusev } else {
5247c478bd9Sstevel@tonic-gate resp->status = puterrno3(error);
525*f44e1126SVitaliy Gusev }
526*f44e1126SVitaliy Gusev
5277c478bd9Sstevel@tonic-gate if (vp != NULL)
5287c478bd9Sstevel@tonic-gate VN_RELE(vp);
5297c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resfail.attr);
5307c478bd9Sstevel@tonic-gate }
5317c478bd9Sstevel@tonic-gate
53227242a7cSthurlow void *
acl3_getacl_getfh(GETACL3args * args)5337c478bd9Sstevel@tonic-gate acl3_getacl_getfh(GETACL3args *args)
5347c478bd9Sstevel@tonic-gate {
5357c478bd9Sstevel@tonic-gate
53627242a7cSthurlow return (&args->fh);
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate
5397c478bd9Sstevel@tonic-gate void
acl3_getacl_free(GETACL3res * resp)5407c478bd9Sstevel@tonic-gate acl3_getacl_free(GETACL3res *resp)
5417c478bd9Sstevel@tonic-gate {
5427c478bd9Sstevel@tonic-gate
5437c478bd9Sstevel@tonic-gate if (resp->status == NFS3_OK) {
5447c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 &&
5457c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) {
5467c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp,
5477c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t));
5487c478bd9Sstevel@tonic-gate }
5497c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 &&
5507c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) {
5517c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp,
5527c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t));
5537c478bd9Sstevel@tonic-gate }
5547c478bd9Sstevel@tonic-gate }
5557c478bd9Sstevel@tonic-gate }
5567c478bd9Sstevel@tonic-gate
5577c478bd9Sstevel@tonic-gate /* ARGSUSED */
5587c478bd9Sstevel@tonic-gate void
acl3_setacl(SETACL3args * args,SETACL3res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)5597c478bd9Sstevel@tonic-gate acl3_setacl(SETACL3args *args, SETACL3res *resp, struct exportinfo *exi,
5605cb0d679SMarcel Telka struct svc_req *req, cred_t *cr, bool_t ro)
5617c478bd9Sstevel@tonic-gate {
5627c478bd9Sstevel@tonic-gate int error;
5637c478bd9Sstevel@tonic-gate vnode_t *vp;
5647c478bd9Sstevel@tonic-gate vattr_t *vap;
5657c478bd9Sstevel@tonic-gate vattr_t va;
5667c478bd9Sstevel@tonic-gate
5677c478bd9Sstevel@tonic-gate vap = NULL;
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gate vp = nfs3_fhtovp(&args->fh, exi);
5707c478bd9Sstevel@tonic-gate if (vp == NULL) {
5717c478bd9Sstevel@tonic-gate error = ESTALE;
5727c478bd9Sstevel@tonic-gate goto out1;
5737c478bd9Sstevel@tonic-gate }
5747c478bd9Sstevel@tonic-gate
5757c478bd9Sstevel@tonic-gate (void) VOP_RWLOCK(vp, V_WRITELOCK_TRUE, NULL);
5767c478bd9Sstevel@tonic-gate
5777c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
5787c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
5797c478bd9Sstevel@tonic-gate
5805cb0d679SMarcel Telka if (rdonly(ro, vp)) {
5817c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_ROFS;
5827c478bd9Sstevel@tonic-gate goto out1;
5837c478bd9Sstevel@tonic-gate }
5847c478bd9Sstevel@tonic-gate
585da6c28aaSamw error = VOP_SETSECATTR(vp, &args->acl, 0, cr, NULL);
5867c478bd9Sstevel@tonic-gate
5877c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
5887c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va;
5897c478bd9Sstevel@tonic-gate
5907c478bd9Sstevel@tonic-gate if (error)
5917c478bd9Sstevel@tonic-gate goto out;
5927c478bd9Sstevel@tonic-gate
5937c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL);
5947c478bd9Sstevel@tonic-gate VN_RELE(vp);
5957c478bd9Sstevel@tonic-gate
5967c478bd9Sstevel@tonic-gate resp->status = NFS3_OK;
5977c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resok.attr);
5987c478bd9Sstevel@tonic-gate return;
5997c478bd9Sstevel@tonic-gate
6007c478bd9Sstevel@tonic-gate out:
6017c478bd9Sstevel@tonic-gate if (curthread->t_flag & T_WOULDBLOCK) {
6027c478bd9Sstevel@tonic-gate curthread->t_flag &= ~T_WOULDBLOCK;
6037c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_JUKEBOX;
6047c478bd9Sstevel@tonic-gate } else
6057c478bd9Sstevel@tonic-gate resp->status = puterrno3(error);
6067c478bd9Sstevel@tonic-gate out1:
6077c478bd9Sstevel@tonic-gate if (vp != NULL) {
6087c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL);
6097c478bd9Sstevel@tonic-gate VN_RELE(vp);
6107c478bd9Sstevel@tonic-gate }
6117c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resfail.attr);
6127c478bd9Sstevel@tonic-gate }
6137c478bd9Sstevel@tonic-gate
61427242a7cSthurlow void *
acl3_setacl_getfh(SETACL3args * args)6157c478bd9Sstevel@tonic-gate acl3_setacl_getfh(SETACL3args *args)
6167c478bd9Sstevel@tonic-gate {
6177c478bd9Sstevel@tonic-gate
61827242a7cSthurlow return (&args->fh);
6197c478bd9Sstevel@tonic-gate }
6207c478bd9Sstevel@tonic-gate
6217c478bd9Sstevel@tonic-gate /* ARGSUSED */
6227c478bd9Sstevel@tonic-gate void
acl3_getxattrdir(GETXATTRDIR3args * args,GETXATTRDIR3res * resp,struct exportinfo * exi,struct svc_req * req,cred_t * cr,bool_t ro)6237c478bd9Sstevel@tonic-gate acl3_getxattrdir(GETXATTRDIR3args *args, GETXATTRDIR3res *resp,
6245cb0d679SMarcel Telka struct exportinfo *exi, struct svc_req *req, cred_t *cr, bool_t ro)
6257c478bd9Sstevel@tonic-gate {
6267c478bd9Sstevel@tonic-gate int error;
6277c478bd9Sstevel@tonic-gate int flags;
6287c478bd9Sstevel@tonic-gate vnode_t *vp, *avp;
6297c478bd9Sstevel@tonic-gate
6307c478bd9Sstevel@tonic-gate vp = nfs3_fhtovp(&args->fh, exi);
6317c478bd9Sstevel@tonic-gate if (vp == NULL) {
6327c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_STALE;
6337c478bd9Sstevel@tonic-gate return;
6347c478bd9Sstevel@tonic-gate }
6357c478bd9Sstevel@tonic-gate
6367c478bd9Sstevel@tonic-gate flags = LOOKUP_XATTR;
6377c478bd9Sstevel@tonic-gate if (args->create)
6387c478bd9Sstevel@tonic-gate flags |= CREATE_XATTR_DIR;
6397c478bd9Sstevel@tonic-gate else {
6407c478bd9Sstevel@tonic-gate ulong_t val = 0;
64193aeed83Smarks
64293aeed83Smarks error = VOP_PATHCONF(vp, _PC_SATTR_EXISTS, &val, cr, NULL);
64393aeed83Smarks if (!error && val == 0) {
64493aeed83Smarks error = VOP_PATHCONF(vp, _PC_XATTR_EXISTS,
64593aeed83Smarks &val, cr, NULL);
6467c478bd9Sstevel@tonic-gate if (!error && val == 0) {
6477c478bd9Sstevel@tonic-gate VN_RELE(vp);
6487c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_NOENT;
6497c478bd9Sstevel@tonic-gate return;
6507c478bd9Sstevel@tonic-gate }
6517c478bd9Sstevel@tonic-gate }
65293aeed83Smarks }
6537c478bd9Sstevel@tonic-gate
654da6c28aaSamw error = VOP_LOOKUP(vp, "", &avp, NULL, flags, NULL, cr,
655da6c28aaSamw NULL, NULL, NULL);
6567c478bd9Sstevel@tonic-gate if (!error && avp == vp) { /* lookup of "" on old FS? */
6577c478bd9Sstevel@tonic-gate error = EINVAL;
6587c478bd9Sstevel@tonic-gate VN_RELE(avp);
6597c478bd9Sstevel@tonic-gate }
6607c478bd9Sstevel@tonic-gate if (!error) {
6617c478bd9Sstevel@tonic-gate struct vattr va;
6627c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL;
6637c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(avp, &va, 0, cr);
6647c478bd9Sstevel@tonic-gate if (!error) {
6657c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(&va, &resp->resok.attr);
6667c478bd9Sstevel@tonic-gate error = makefh3(&resp->resok.fh, avp, exi);
6677c478bd9Sstevel@tonic-gate }
6687c478bd9Sstevel@tonic-gate VN_RELE(avp);
6697c478bd9Sstevel@tonic-gate }
6707c478bd9Sstevel@tonic-gate
6717c478bd9Sstevel@tonic-gate VN_RELE(vp);
6727c478bd9Sstevel@tonic-gate
6737c478bd9Sstevel@tonic-gate if (error) {
6747c478bd9Sstevel@tonic-gate resp->status = puterrno3(error);
6757c478bd9Sstevel@tonic-gate return;
6767c478bd9Sstevel@tonic-gate }
6777c478bd9Sstevel@tonic-gate resp->status = NFS3_OK;
6787c478bd9Sstevel@tonic-gate }
6797c478bd9Sstevel@tonic-gate
68027242a7cSthurlow void *
acl3_getxattrdir_getfh(GETXATTRDIR3args * args)6817c478bd9Sstevel@tonic-gate acl3_getxattrdir_getfh(GETXATTRDIR3args *args)
6827c478bd9Sstevel@tonic-gate {
68327242a7cSthurlow return (&args->fh);
6847c478bd9Sstevel@tonic-gate }
685