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 /* 22*da6c28aaSamw * Copyright 2007 Sun Microsystems, Inc. 237c478bd9Sstevel@tonic-gate * All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/param.h> 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <sys/systm.h> 327c478bd9Sstevel@tonic-gate #include <sys/cred.h> 337c478bd9Sstevel@tonic-gate #include <sys/proc.h> 347c478bd9Sstevel@tonic-gate #include <sys/user.h> 357c478bd9Sstevel@tonic-gate #include <sys/buf.h> 367c478bd9Sstevel@tonic-gate #include <sys/vfs.h> 377c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 387c478bd9Sstevel@tonic-gate #include <sys/pathname.h> 397c478bd9Sstevel@tonic-gate #include <sys/uio.h> 407c478bd9Sstevel@tonic-gate #include <sys/file.h> 417c478bd9Sstevel@tonic-gate #include <sys/stat.h> 427c478bd9Sstevel@tonic-gate #include <sys/errno.h> 437c478bd9Sstevel@tonic-gate #include <sys/socket.h> 447c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 457c478bd9Sstevel@tonic-gate #include <sys/siginfo.h> 467c478bd9Sstevel@tonic-gate #include <sys/tiuser.h> 477c478bd9Sstevel@tonic-gate #include <sys/statvfs.h> 487c478bd9Sstevel@tonic-gate #include <sys/t_kuser.h> 497c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 507c478bd9Sstevel@tonic-gate #include <sys/kstat.h> 517c478bd9Sstevel@tonic-gate #include <sys/acl.h> 527c478bd9Sstevel@tonic-gate #include <sys/dirent.h> 537c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 547c478bd9Sstevel@tonic-gate #include <sys/debug.h> 557c478bd9Sstevel@tonic-gate #include <sys/unistd.h> 567c478bd9Sstevel@tonic-gate #include <sys/vtrace.h> 577c478bd9Sstevel@tonic-gate #include <sys/mode.h> 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #include <rpc/types.h> 607c478bd9Sstevel@tonic-gate #include <rpc/auth.h> 617c478bd9Sstevel@tonic-gate #include <rpc/svc.h> 627c478bd9Sstevel@tonic-gate #include <rpc/xdr.h> 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 657c478bd9Sstevel@tonic-gate #include <nfs/export.h> 667c478bd9Sstevel@tonic-gate #include <nfs/nfssys.h> 677c478bd9Sstevel@tonic-gate #include <nfs/nfs_clnt.h> 687c478bd9Sstevel@tonic-gate #include <nfs/nfs_acl.h> 697c478bd9Sstevel@tonic-gate 70fa9e4066Sahrens #include <fs/fs_subr.h> 71fa9e4066Sahrens 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * These are the interface routines for the server side of the 747c478bd9Sstevel@tonic-gate * NFS ACL server. See the NFS ACL protocol specification 757c478bd9Sstevel@tonic-gate * for a description of this interface. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* ARGSUSED */ 797c478bd9Sstevel@tonic-gate void 807c478bd9Sstevel@tonic-gate acl2_getacl(GETACL2args *args, GETACL2res *resp, struct exportinfo *exi, 817c478bd9Sstevel@tonic-gate struct svc_req *req, cred_t *cr) 827c478bd9Sstevel@tonic-gate { 837c478bd9Sstevel@tonic-gate int error; 847c478bd9Sstevel@tonic-gate vnode_t *vp; 857c478bd9Sstevel@tonic-gate vattr_t va; 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi); 887c478bd9Sstevel@tonic-gate if (vp == NULL) { 897c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE; 907c478bd9Sstevel@tonic-gate return; 917c478bd9Sstevel@tonic-gate } 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate bzero((caddr_t)&resp->resok.acl, sizeof (resp->resok.acl)); 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_mask = args->mask; 967c478bd9Sstevel@tonic-gate 97*da6c28aaSamw error = VOP_GETSECATTR(vp, &resp->resok.acl, 0, cr, NULL); 987c478bd9Sstevel@tonic-gate 99fa9e4066Sahrens if (error == ENOSYS) { 100fa9e4066Sahrens /* 101fa9e4066Sahrens * If the underlying file system doesn't support 102fa9e4066Sahrens * aclent_t type acls, fabricate an acl. This is 103fa9e4066Sahrens * required in order to to support existing clients 104fa9e4066Sahrens * that require the call to VOP_GETSECATTR to 105fa9e4066Sahrens * succeed while making the assumption that all 106fa9e4066Sahrens * file systems support aclent_t type acls. This 107fa9e4066Sahrens * causes problems for servers exporting ZFS file 108fa9e4066Sahrens * systems because ZFS supports ace_t type acls, 109fa9e4066Sahrens * and fails (with ENOSYS) when asked for aclent_t 110fa9e4066Sahrens * type acls. 111fa9e4066Sahrens * 112fa9e4066Sahrens * Note: if the fs_fab_acl() fails, we have other problems. 113fa9e4066Sahrens * This error should be returned to the caller. 114fa9e4066Sahrens */ 115*da6c28aaSamw error = fs_fab_acl(vp, &resp->resok.acl, 0, cr, NULL); 116fa9e4066Sahrens } 117fa9e4066Sahrens 1187c478bd9Sstevel@tonic-gate if (error) { 1197c478bd9Sstevel@tonic-gate VN_RELE(vp); 1207c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 1217c478bd9Sstevel@tonic-gate return; 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 1257c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate VN_RELE(vp); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* check for overflowed values */ 1307c478bd9Sstevel@tonic-gate if (!error) { 1317c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr); 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate if (error) { 1347c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 1357c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 && 1367c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) { 1377c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp, 1387c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t)); 1397c478bd9Sstevel@tonic-gate } 1407c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 && 1417c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) { 1427c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp, 1437c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t)); 1447c478bd9Sstevel@tonic-gate } 1457c478bd9Sstevel@tonic-gate return; 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate resp->status = NFS_OK; 1497c478bd9Sstevel@tonic-gate if (!(args->mask & NA_ACL)) { 1507c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 && 1517c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) { 1527c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp, 1537c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t)); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp = NULL; 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate if (!(args->mask & NA_DFACL)) { 1587c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 && 1597c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) { 1607c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp, 1617c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t)); 1627c478bd9Sstevel@tonic-gate } 1637c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp = NULL; 1647c478bd9Sstevel@tonic-gate } 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate 16727242a7cSthurlow void * 1687c478bd9Sstevel@tonic-gate acl2_getacl_getfh(GETACL2args *args) 1697c478bd9Sstevel@tonic-gate { 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate return (&args->fh); 1727c478bd9Sstevel@tonic-gate } 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate void 1757c478bd9Sstevel@tonic-gate acl2_getacl_free(GETACL2res *resp) 1767c478bd9Sstevel@tonic-gate { 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate if (resp->status == NFS_OK) { 1797c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 && 1807c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) { 1817c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp, 1827c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t)); 1837c478bd9Sstevel@tonic-gate } 1847c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 && 1857c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) { 1867c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp, 1877c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t)); 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate } 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1937c478bd9Sstevel@tonic-gate void 1947c478bd9Sstevel@tonic-gate acl2_setacl(SETACL2args *args, SETACL2res *resp, struct exportinfo *exi, 1957c478bd9Sstevel@tonic-gate struct svc_req *req, cred_t *cr) 1967c478bd9Sstevel@tonic-gate { 1977c478bd9Sstevel@tonic-gate int error; 1987c478bd9Sstevel@tonic-gate vnode_t *vp; 1997c478bd9Sstevel@tonic-gate vattr_t va; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi); 2027c478bd9Sstevel@tonic-gate if (vp == NULL) { 2037c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE; 2047c478bd9Sstevel@tonic-gate return; 2057c478bd9Sstevel@tonic-gate } 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate if (rdonly(exi, req) || vn_is_readonly(vp)) { 2087c478bd9Sstevel@tonic-gate VN_RELE(vp); 2097c478bd9Sstevel@tonic-gate resp->status = NFSERR_ROFS; 2107c478bd9Sstevel@tonic-gate return; 2117c478bd9Sstevel@tonic-gate } 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate (void) VOP_RWLOCK(vp, V_WRITELOCK_TRUE, NULL); 214*da6c28aaSamw error = VOP_SETSECATTR(vp, &args->acl, 0, cr, NULL); 2157c478bd9Sstevel@tonic-gate if (error) { 2167c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL); 2177c478bd9Sstevel@tonic-gate VN_RELE(vp); 2187c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 2197c478bd9Sstevel@tonic-gate return; 2207c478bd9Sstevel@tonic-gate } 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 2237c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr); 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL); 2267c478bd9Sstevel@tonic-gate VN_RELE(vp); 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate /* check for overflowed values */ 2297c478bd9Sstevel@tonic-gate if (!error) { 2307c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr); 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate if (error) { 2337c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 2347c478bd9Sstevel@tonic-gate return; 2357c478bd9Sstevel@tonic-gate } 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate resp->status = NFS_OK; 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate 24027242a7cSthurlow void * 2417c478bd9Sstevel@tonic-gate acl2_setacl_getfh(SETACL2args *args) 2427c478bd9Sstevel@tonic-gate { 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate return (&args->fh); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2487c478bd9Sstevel@tonic-gate void 2497c478bd9Sstevel@tonic-gate acl2_getattr(GETATTR2args *args, GETATTR2res *resp, struct exportinfo *exi, 2507c478bd9Sstevel@tonic-gate struct svc_req *req, cred_t *cr) 2517c478bd9Sstevel@tonic-gate { 2527c478bd9Sstevel@tonic-gate int error; 2537c478bd9Sstevel@tonic-gate vnode_t *vp; 2547c478bd9Sstevel@tonic-gate vattr_t va; 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi); 2577c478bd9Sstevel@tonic-gate if (vp == NULL) { 2587c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE; 2597c478bd9Sstevel@tonic-gate return; 2607c478bd9Sstevel@tonic-gate } 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 2637c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr); 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate VN_RELE(vp); 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* check for overflowed values */ 2687c478bd9Sstevel@tonic-gate if (!error) { 2697c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr); 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate if (error) { 2727c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 2737c478bd9Sstevel@tonic-gate return; 2747c478bd9Sstevel@tonic-gate } 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate resp->status = NFS_OK; 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate 27927242a7cSthurlow void * 2807c478bd9Sstevel@tonic-gate acl2_getattr_getfh(GETATTR2args *args) 2817c478bd9Sstevel@tonic-gate { 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate return (&args->fh); 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2877c478bd9Sstevel@tonic-gate void 2887c478bd9Sstevel@tonic-gate acl2_access(ACCESS2args *args, ACCESS2res *resp, struct exportinfo *exi, 2897c478bd9Sstevel@tonic-gate struct svc_req *req, cred_t *cr) 2907c478bd9Sstevel@tonic-gate { 2917c478bd9Sstevel@tonic-gate int error; 2927c478bd9Sstevel@tonic-gate vnode_t *vp; 2937c478bd9Sstevel@tonic-gate vattr_t va; 2947c478bd9Sstevel@tonic-gate int checkwriteperm; 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi); 2977c478bd9Sstevel@tonic-gate if (vp == NULL) { 2987c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE; 2997c478bd9Sstevel@tonic-gate return; 3007c478bd9Sstevel@tonic-gate } 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate /* 3037c478bd9Sstevel@tonic-gate * If the file system is exported read only, it is not appropriate 3047c478bd9Sstevel@tonic-gate * to check write permissions for regular files and directories. 3057c478bd9Sstevel@tonic-gate * Special files are interpreted by the client, so the underlying 3067c478bd9Sstevel@tonic-gate * permissions are sent back to the client for interpretation. 3077c478bd9Sstevel@tonic-gate */ 3087c478bd9Sstevel@tonic-gate if (rdonly(exi, req) && (vp->v_type == VREG || vp->v_type == VDIR)) 3097c478bd9Sstevel@tonic-gate checkwriteperm = 0; 3107c478bd9Sstevel@tonic-gate else 3117c478bd9Sstevel@tonic-gate checkwriteperm = 1; 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* 3147c478bd9Sstevel@tonic-gate * We need the mode so that we can correctly determine access 3157c478bd9Sstevel@tonic-gate * permissions relative to a mandatory lock file. Access to 3167c478bd9Sstevel@tonic-gate * mandatory lock files is denied on the server, so it might 3177c478bd9Sstevel@tonic-gate * as well be reflected to the server during the open. 3187c478bd9Sstevel@tonic-gate */ 3197c478bd9Sstevel@tonic-gate va.va_mask = AT_MODE; 320*da6c28aaSamw error = VOP_GETATTR(vp, &va, 0, cr, NULL); 3217c478bd9Sstevel@tonic-gate if (error) { 3227c478bd9Sstevel@tonic-gate VN_RELE(vp); 3237c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 3247c478bd9Sstevel@tonic-gate return; 3257c478bd9Sstevel@tonic-gate } 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate resp->resok.access = 0; 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate if (args->access & ACCESS2_READ) { 330*da6c28aaSamw error = VOP_ACCESS(vp, VREAD, 0, cr, NULL); 3317c478bd9Sstevel@tonic-gate if (!error && !MANDLOCK(vp, va.va_mode)) 3327c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_READ; 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate if ((args->access & ACCESS2_LOOKUP) && vp->v_type == VDIR) { 335*da6c28aaSamw error = VOP_ACCESS(vp, VEXEC, 0, cr, NULL); 3367c478bd9Sstevel@tonic-gate if (!error) 3377c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_LOOKUP; 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate if (checkwriteperm && 3407c478bd9Sstevel@tonic-gate (args->access & (ACCESS2_MODIFY|ACCESS2_EXTEND))) { 341*da6c28aaSamw error = VOP_ACCESS(vp, VWRITE, 0, cr, NULL); 3427c478bd9Sstevel@tonic-gate if (!error && !MANDLOCK(vp, va.va_mode)) 3437c478bd9Sstevel@tonic-gate resp->resok.access |= 3447c478bd9Sstevel@tonic-gate (args->access & (ACCESS2_MODIFY|ACCESS2_EXTEND)); 3457c478bd9Sstevel@tonic-gate } 3467c478bd9Sstevel@tonic-gate if (checkwriteperm && 3477c478bd9Sstevel@tonic-gate (args->access & ACCESS2_DELETE) && (vp->v_type == VDIR)) { 348*da6c28aaSamw error = VOP_ACCESS(vp, VWRITE, 0, cr, NULL); 3497c478bd9Sstevel@tonic-gate if (!error) 3507c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_DELETE; 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate if (args->access & ACCESS2_EXECUTE) { 353*da6c28aaSamw error = VOP_ACCESS(vp, VEXEC, 0, cr, NULL); 3547c478bd9Sstevel@tonic-gate if (!error && !MANDLOCK(vp, va.va_mode)) 3557c478bd9Sstevel@tonic-gate resp->resok.access |= ACCESS2_EXECUTE; 3567c478bd9Sstevel@tonic-gate } 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 3597c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(vp, &va, 0, cr); 3607c478bd9Sstevel@tonic-gate 3617c478bd9Sstevel@tonic-gate VN_RELE(vp); 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate /* check for overflowed values */ 3647c478bd9Sstevel@tonic-gate if (!error) { 3657c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr); 3667c478bd9Sstevel@tonic-gate } 3677c478bd9Sstevel@tonic-gate if (error) { 3687c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 3697c478bd9Sstevel@tonic-gate return; 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate resp->status = NFS_OK; 3737c478bd9Sstevel@tonic-gate } 3747c478bd9Sstevel@tonic-gate 37527242a7cSthurlow void * 3767c478bd9Sstevel@tonic-gate acl2_access_getfh(ACCESS2args *args) 3777c478bd9Sstevel@tonic-gate { 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate return (&args->fh); 3807c478bd9Sstevel@tonic-gate } 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate /* ARGSUSED */ 3837c478bd9Sstevel@tonic-gate void 3847c478bd9Sstevel@tonic-gate acl2_getxattrdir(GETXATTRDIR2args *args, GETXATTRDIR2res *resp, 3857c478bd9Sstevel@tonic-gate struct exportinfo *exi, struct svc_req *req, cred_t *cr) 3867c478bd9Sstevel@tonic-gate { 3877c478bd9Sstevel@tonic-gate int error; 3887c478bd9Sstevel@tonic-gate int flags; 3897c478bd9Sstevel@tonic-gate vnode_t *vp, *avp; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate vp = nfs_fhtovp(&args->fh, exi); 3927c478bd9Sstevel@tonic-gate if (vp == NULL) { 3937c478bd9Sstevel@tonic-gate resp->status = NFSERR_STALE; 3947c478bd9Sstevel@tonic-gate return; 3957c478bd9Sstevel@tonic-gate } 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate flags = LOOKUP_XATTR; 3987c478bd9Sstevel@tonic-gate if (args->create) 3997c478bd9Sstevel@tonic-gate flags |= CREATE_XATTR_DIR; 4007c478bd9Sstevel@tonic-gate else { 4017c478bd9Sstevel@tonic-gate ulong_t val = 0; 402*da6c28aaSamw error = VOP_PATHCONF(vp, _PC_XATTR_EXISTS, &val, cr, NULL); 4037c478bd9Sstevel@tonic-gate if (!error && val == 0) { 4047c478bd9Sstevel@tonic-gate VN_RELE(vp); 4057c478bd9Sstevel@tonic-gate resp->status = NFSERR_NOENT; 4067c478bd9Sstevel@tonic-gate return; 4077c478bd9Sstevel@tonic-gate } 4087c478bd9Sstevel@tonic-gate } 4097c478bd9Sstevel@tonic-gate 410*da6c28aaSamw error = VOP_LOOKUP(vp, "", &avp, NULL, flags, NULL, cr, 411*da6c28aaSamw NULL, NULL, NULL); 4127c478bd9Sstevel@tonic-gate if (!error && avp == vp) { /* lookup of "" on old FS? */ 4137c478bd9Sstevel@tonic-gate error = EINVAL; 4147c478bd9Sstevel@tonic-gate VN_RELE(avp); 4157c478bd9Sstevel@tonic-gate } 4167c478bd9Sstevel@tonic-gate if (!error) { 4177c478bd9Sstevel@tonic-gate struct vattr va; 4187c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 4197c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(avp, &va, 0, cr); 4207c478bd9Sstevel@tonic-gate if (!error) { 4217c478bd9Sstevel@tonic-gate error = vattr_to_nattr(&va, &resp->resok.attr); 4227c478bd9Sstevel@tonic-gate if (!error) 4237c478bd9Sstevel@tonic-gate error = makefh(&resp->resok.fh, avp, exi); 4247c478bd9Sstevel@tonic-gate } 4257c478bd9Sstevel@tonic-gate VN_RELE(avp); 4267c478bd9Sstevel@tonic-gate } 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate VN_RELE(vp); 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate if (error) { 4317c478bd9Sstevel@tonic-gate resp->status = puterrno(error); 4327c478bd9Sstevel@tonic-gate return; 4337c478bd9Sstevel@tonic-gate } 4347c478bd9Sstevel@tonic-gate resp->status = NFS_OK; 4357c478bd9Sstevel@tonic-gate } 4367c478bd9Sstevel@tonic-gate 43727242a7cSthurlow void * 4387c478bd9Sstevel@tonic-gate acl2_getxattrdir_getfh(GETXATTRDIR2args *args) 4397c478bd9Sstevel@tonic-gate { 4407c478bd9Sstevel@tonic-gate return (&args->fh); 4417c478bd9Sstevel@tonic-gate } 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate /* ARGSUSED */ 4447c478bd9Sstevel@tonic-gate void 4457c478bd9Sstevel@tonic-gate acl3_getacl(GETACL3args *args, GETACL3res *resp, struct exportinfo *exi, 4467c478bd9Sstevel@tonic-gate struct svc_req *req, cred_t *cr) 4477c478bd9Sstevel@tonic-gate { 4487c478bd9Sstevel@tonic-gate int error; 4497c478bd9Sstevel@tonic-gate vnode_t *vp; 4507c478bd9Sstevel@tonic-gate vattr_t *vap; 4517c478bd9Sstevel@tonic-gate vattr_t va; 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate vap = NULL; 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate vp = nfs3_fhtovp(&args->fh, exi); 4567c478bd9Sstevel@tonic-gate if (vp == NULL) { 4577c478bd9Sstevel@tonic-gate error = ESTALE; 4587c478bd9Sstevel@tonic-gate goto out; 4597c478bd9Sstevel@tonic-gate } 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate #ifdef DEBUG 4627c478bd9Sstevel@tonic-gate if (rfs3_do_post_op_attr) { 4637c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 4647c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 4657c478bd9Sstevel@tonic-gate } else 4667c478bd9Sstevel@tonic-gate vap = NULL; 4677c478bd9Sstevel@tonic-gate #else 4687c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 4697c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 4707c478bd9Sstevel@tonic-gate #endif 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate bzero((caddr_t)&resp->resok.acl, sizeof (resp->resok.acl)); 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_mask = args->mask; 4757c478bd9Sstevel@tonic-gate 476*da6c28aaSamw error = VOP_GETSECATTR(vp, &resp->resok.acl, 0, cr, NULL); 4777c478bd9Sstevel@tonic-gate 478fa9e4066Sahrens if (error == ENOSYS) { 479fa9e4066Sahrens /* 480fa9e4066Sahrens * If the underlying file system doesn't support 481fa9e4066Sahrens * aclent_t type acls, fabricate an acl. This is 482fa9e4066Sahrens * required in order to to support existing clients 483fa9e4066Sahrens * that require the call to VOP_GETSECATTR to 484fa9e4066Sahrens * succeed while making the assumption that all 485fa9e4066Sahrens * file systems support aclent_t type acls. This 486fa9e4066Sahrens * causes problems for servers exporting ZFS file 487fa9e4066Sahrens * systems because ZFS supports ace_t type acls, 488fa9e4066Sahrens * and fails (with ENOSYS) when asked for aclent_t 489fa9e4066Sahrens * type acls. 490fa9e4066Sahrens * 491fa9e4066Sahrens * Note: if the fs_fab_acl() fails, we have other problems. 492fa9e4066Sahrens * This error should be returned to the caller. 493fa9e4066Sahrens */ 494*da6c28aaSamw error = fs_fab_acl(vp, &resp->resok.acl, 0, cr, NULL); 495fa9e4066Sahrens } 496fa9e4066Sahrens 4977c478bd9Sstevel@tonic-gate if (error) 4987c478bd9Sstevel@tonic-gate goto out; 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate #ifdef DEBUG 5017c478bd9Sstevel@tonic-gate if (rfs3_do_post_op_attr) { 5027c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 5037c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 5047c478bd9Sstevel@tonic-gate } else 5057c478bd9Sstevel@tonic-gate vap = NULL; 5067c478bd9Sstevel@tonic-gate #else 5077c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 5087c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 5097c478bd9Sstevel@tonic-gate #endif 5107c478bd9Sstevel@tonic-gate 5117c478bd9Sstevel@tonic-gate VN_RELE(vp); 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate resp->status = NFS3_OK; 5147c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resok.attr); 5157c478bd9Sstevel@tonic-gate if (!(args->mask & NA_ACL)) { 5167c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 && 5177c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) { 5187c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp, 5197c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t)); 5207c478bd9Sstevel@tonic-gate } 5217c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp = NULL; 5227c478bd9Sstevel@tonic-gate } 5237c478bd9Sstevel@tonic-gate if (!(args->mask & NA_DFACL)) { 5247c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 && 5257c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) { 5267c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp, 5277c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t)); 5287c478bd9Sstevel@tonic-gate } 5297c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp = NULL; 5307c478bd9Sstevel@tonic-gate } 5317c478bd9Sstevel@tonic-gate return; 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate out: 5347c478bd9Sstevel@tonic-gate if (curthread->t_flag & T_WOULDBLOCK) { 5357c478bd9Sstevel@tonic-gate curthread->t_flag &= ~T_WOULDBLOCK; 5367c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_JUKEBOX; 5377c478bd9Sstevel@tonic-gate } else 5387c478bd9Sstevel@tonic-gate resp->status = puterrno3(error); 5397c478bd9Sstevel@tonic-gate out1: 5407c478bd9Sstevel@tonic-gate if (vp != NULL) 5417c478bd9Sstevel@tonic-gate VN_RELE(vp); 5427c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resfail.attr); 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate 54527242a7cSthurlow void * 5467c478bd9Sstevel@tonic-gate acl3_getacl_getfh(GETACL3args *args) 5477c478bd9Sstevel@tonic-gate { 5487c478bd9Sstevel@tonic-gate 54927242a7cSthurlow return (&args->fh); 5507c478bd9Sstevel@tonic-gate } 5517c478bd9Sstevel@tonic-gate 5527c478bd9Sstevel@tonic-gate void 5537c478bd9Sstevel@tonic-gate acl3_getacl_free(GETACL3res *resp) 5547c478bd9Sstevel@tonic-gate { 5557c478bd9Sstevel@tonic-gate 5567c478bd9Sstevel@tonic-gate if (resp->status == NFS3_OK) { 5577c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_aclcnt > 0 && 5587c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclentp != NULL) { 5597c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_aclentp, 5607c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_aclcnt * sizeof (aclent_t)); 5617c478bd9Sstevel@tonic-gate } 5627c478bd9Sstevel@tonic-gate if (resp->resok.acl.vsa_dfaclcnt > 0 && 5637c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclentp != NULL) { 5647c478bd9Sstevel@tonic-gate kmem_free((caddr_t)resp->resok.acl.vsa_dfaclentp, 5657c478bd9Sstevel@tonic-gate resp->resok.acl.vsa_dfaclcnt * sizeof (aclent_t)); 5667c478bd9Sstevel@tonic-gate } 5677c478bd9Sstevel@tonic-gate } 5687c478bd9Sstevel@tonic-gate } 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate /* ARGSUSED */ 5717c478bd9Sstevel@tonic-gate void 5727c478bd9Sstevel@tonic-gate acl3_setacl(SETACL3args *args, SETACL3res *resp, struct exportinfo *exi, 5737c478bd9Sstevel@tonic-gate struct svc_req *req, cred_t *cr) 5747c478bd9Sstevel@tonic-gate { 5757c478bd9Sstevel@tonic-gate int error; 5767c478bd9Sstevel@tonic-gate vnode_t *vp; 5777c478bd9Sstevel@tonic-gate vattr_t *vap; 5787c478bd9Sstevel@tonic-gate vattr_t va; 5797c478bd9Sstevel@tonic-gate 5807c478bd9Sstevel@tonic-gate vap = NULL; 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate vp = nfs3_fhtovp(&args->fh, exi); 5837c478bd9Sstevel@tonic-gate if (vp == NULL) { 5847c478bd9Sstevel@tonic-gate error = ESTALE; 5857c478bd9Sstevel@tonic-gate goto out1; 5867c478bd9Sstevel@tonic-gate } 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate (void) VOP_RWLOCK(vp, V_WRITELOCK_TRUE, NULL); 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate #ifdef DEBUG 5917c478bd9Sstevel@tonic-gate if (rfs3_do_post_op_attr) { 5927c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 5937c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 5947c478bd9Sstevel@tonic-gate } else 5957c478bd9Sstevel@tonic-gate vap = NULL; 5967c478bd9Sstevel@tonic-gate #else 5977c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 5987c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 5997c478bd9Sstevel@tonic-gate #endif 6007c478bd9Sstevel@tonic-gate 6017c478bd9Sstevel@tonic-gate if (rdonly(exi, req) || vn_is_readonly(vp)) { 6027c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_ROFS; 6037c478bd9Sstevel@tonic-gate goto out1; 6047c478bd9Sstevel@tonic-gate } 6057c478bd9Sstevel@tonic-gate 606*da6c28aaSamw error = VOP_SETSECATTR(vp, &args->acl, 0, cr, NULL); 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate #ifdef DEBUG 6097c478bd9Sstevel@tonic-gate if (rfs3_do_post_op_attr) { 6107c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 6117c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 6127c478bd9Sstevel@tonic-gate } else 6137c478bd9Sstevel@tonic-gate vap = NULL; 6147c478bd9Sstevel@tonic-gate #else 6157c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 6167c478bd9Sstevel@tonic-gate vap = rfs4_delegated_getattr(vp, &va, 0, cr) ? NULL : &va; 6177c478bd9Sstevel@tonic-gate #endif 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate if (error) 6207c478bd9Sstevel@tonic-gate goto out; 6217c478bd9Sstevel@tonic-gate 6227c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL); 6237c478bd9Sstevel@tonic-gate VN_RELE(vp); 6247c478bd9Sstevel@tonic-gate 6257c478bd9Sstevel@tonic-gate resp->status = NFS3_OK; 6267c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resok.attr); 6277c478bd9Sstevel@tonic-gate return; 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate out: 6307c478bd9Sstevel@tonic-gate if (curthread->t_flag & T_WOULDBLOCK) { 6317c478bd9Sstevel@tonic-gate curthread->t_flag &= ~T_WOULDBLOCK; 6327c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_JUKEBOX; 6337c478bd9Sstevel@tonic-gate } else 6347c478bd9Sstevel@tonic-gate resp->status = puterrno3(error); 6357c478bd9Sstevel@tonic-gate out1: 6367c478bd9Sstevel@tonic-gate if (vp != NULL) { 6377c478bd9Sstevel@tonic-gate VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL); 6387c478bd9Sstevel@tonic-gate VN_RELE(vp); 6397c478bd9Sstevel@tonic-gate } 6407c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(vap, &resp->resfail.attr); 6417c478bd9Sstevel@tonic-gate } 6427c478bd9Sstevel@tonic-gate 64327242a7cSthurlow void * 6447c478bd9Sstevel@tonic-gate acl3_setacl_getfh(SETACL3args *args) 6457c478bd9Sstevel@tonic-gate { 6467c478bd9Sstevel@tonic-gate 64727242a7cSthurlow return (&args->fh); 6487c478bd9Sstevel@tonic-gate } 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate /* ARGSUSED */ 6517c478bd9Sstevel@tonic-gate void 6527c478bd9Sstevel@tonic-gate acl3_getxattrdir(GETXATTRDIR3args *args, GETXATTRDIR3res *resp, 6537c478bd9Sstevel@tonic-gate struct exportinfo *exi, struct svc_req *req, cred_t *cr) 6547c478bd9Sstevel@tonic-gate { 6557c478bd9Sstevel@tonic-gate int error; 6567c478bd9Sstevel@tonic-gate int flags; 6577c478bd9Sstevel@tonic-gate vnode_t *vp, *avp; 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate vp = nfs3_fhtovp(&args->fh, exi); 6607c478bd9Sstevel@tonic-gate if (vp == NULL) { 6617c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_STALE; 6627c478bd9Sstevel@tonic-gate return; 6637c478bd9Sstevel@tonic-gate } 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate flags = LOOKUP_XATTR; 6667c478bd9Sstevel@tonic-gate if (args->create) 6677c478bd9Sstevel@tonic-gate flags |= CREATE_XATTR_DIR; 6687c478bd9Sstevel@tonic-gate else { 6697c478bd9Sstevel@tonic-gate ulong_t val = 0; 670*da6c28aaSamw error = VOP_PATHCONF(vp, _PC_XATTR_EXISTS, &val, cr, NULL); 6717c478bd9Sstevel@tonic-gate if (!error && val == 0) { 6727c478bd9Sstevel@tonic-gate VN_RELE(vp); 6737c478bd9Sstevel@tonic-gate resp->status = NFS3ERR_NOENT; 6747c478bd9Sstevel@tonic-gate return; 6757c478bd9Sstevel@tonic-gate } 6767c478bd9Sstevel@tonic-gate } 6777c478bd9Sstevel@tonic-gate 678*da6c28aaSamw error = VOP_LOOKUP(vp, "", &avp, NULL, flags, NULL, cr, 679*da6c28aaSamw NULL, NULL, NULL); 6807c478bd9Sstevel@tonic-gate if (!error && avp == vp) { /* lookup of "" on old FS? */ 6817c478bd9Sstevel@tonic-gate error = EINVAL; 6827c478bd9Sstevel@tonic-gate VN_RELE(avp); 6837c478bd9Sstevel@tonic-gate } 6847c478bd9Sstevel@tonic-gate if (!error) { 6857c478bd9Sstevel@tonic-gate struct vattr va; 6867c478bd9Sstevel@tonic-gate va.va_mask = AT_ALL; 6877c478bd9Sstevel@tonic-gate error = rfs4_delegated_getattr(avp, &va, 0, cr); 6887c478bd9Sstevel@tonic-gate if (!error) { 6897c478bd9Sstevel@tonic-gate vattr_to_post_op_attr(&va, &resp->resok.attr); 6907c478bd9Sstevel@tonic-gate error = makefh3(&resp->resok.fh, avp, exi); 6917c478bd9Sstevel@tonic-gate } 6927c478bd9Sstevel@tonic-gate VN_RELE(avp); 6937c478bd9Sstevel@tonic-gate } 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate VN_RELE(vp); 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate if (error) { 6987c478bd9Sstevel@tonic-gate resp->status = puterrno3(error); 6997c478bd9Sstevel@tonic-gate return; 7007c478bd9Sstevel@tonic-gate } 7017c478bd9Sstevel@tonic-gate resp->status = NFS3_OK; 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate 70427242a7cSthurlow void * 7057c478bd9Sstevel@tonic-gate acl3_getxattrdir_getfh(GETXATTRDIR3args *args) 7067c478bd9Sstevel@tonic-gate { 70727242a7cSthurlow return (&args->fh); 7087c478bd9Sstevel@tonic-gate } 709