X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/ff6e181ae92fc6f1e89841290f461d1f2f9badd9..0c530ab8987f0ae6a1a3d9284f40182b88852816:/bsd/nfs/nfs_vfsops.c?ds=sidebyside diff --git a/bsd/nfs/nfs_vfsops.c b/bsd/nfs/nfs_vfsops.c index 65e8f579c..d8e5cb69d 100644 --- a/bsd/nfs/nfs_vfsops.c +++ b/bsd/nfs/nfs_vfsops.c @@ -3,20 +3,19 @@ * * @APPLE_LICENSE_HEADER_START@ * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -126,7 +125,7 @@ static int nfs_tprintf_delay = NFS_TPRINTF_DELAY; SYSCTL_INT(_vfs_generic_nfs_client, NFS_TPRINTF_DELAY, nextdowndelay, CTLFLAG_RW, &nfs_tprintf_delay, 0, ""); -static int nfs_iosize(struct nfsmount *nmp); +static int nfs_biosize(struct nfsmount *); static int mountnfs(struct user_nfs_args *,mount_t,mbuf_t,proc_t,vnode_t *); static int nfs_mount(mount_t mp, vnode_t vp, user_addr_t data, vfs_context_t context); static int nfs_start(mount_t mp, int flags, vfs_context_t context); @@ -167,8 +166,8 @@ static int nfs_mount_diskless_private(struct nfs_dlmount *, const char *, int, vnode_t *, mount_t *); #endif /* NO_MOUNT_PRIVATE */ -static int nfs_iosize(nmp) - struct nfsmount* nmp; +static int +nfs_biosize(struct nfsmount *nmp) { int iosize; @@ -222,7 +221,7 @@ nfs_statfs(mount_t mp, struct vfsstatfs *sbp, vfs_context_t context) nfs_fsinfo(nmp, vp, cred, p); nfsm_reqhead(NFSX_FH(v3)); if (error) { - kauth_cred_rele(cred); + kauth_cred_unref(&cred); vnode_put(vp); return (error); } @@ -234,7 +233,7 @@ nfs_statfs(mount_t mp, struct vfsstatfs *sbp, vfs_context_t context) nfsm_dissect(sfp, struct nfs_statfs *, NFSX_STATFS(v3)); sbp->f_flags = nmp->nm_flag; - sbp->f_iosize = nfs_iosize(nmp); + sbp->f_iosize = NFS_IOSIZE; if (v3) { /* * Adjust block size to get total block count to fit in a long. @@ -279,7 +278,7 @@ nfs_statfs(mount_t mp, struct vfsstatfs *sbp, vfs_context_t context) sbp->f_ffree = 0; } nfsm_reqdone; - kauth_cred_rele(cred); + kauth_cred_unref(&cred); vnode_put(vp); return (error); } @@ -1029,6 +1028,9 @@ mountnfs( struct vfs_context context; /* XXX get from caller? */ u_int64_t xid; + /* up front because of reference */ + context.vc_ucred = kauth_cred_proc_ref(p); + /* * Silently clear NFSMNT_NOCONN if it's a TCP mount, it makes * no sense in that context. @@ -1040,12 +1042,14 @@ mountnfs( nmp = VFSTONFS(mp); /* update paths, file handles, etc, here XXX */ mbuf_freem(nam); + kauth_cred_unref(&context.vc_ucred); return (0); } else { MALLOC_ZONE(nmp, struct nfsmount *, sizeof (struct nfsmount), M_NFSMNT, M_WAITOK); if (!nmp) { mbuf_freem(nam); + kauth_cred_unref(&context.vc_ucred); return (ENOMEM); } bzero((caddr_t)nmp, sizeof (struct nfsmount)); @@ -1115,8 +1119,8 @@ mountnfs( } if (nmp->nm_wsize > maxio) nmp->nm_wsize = maxio; - if (nmp->nm_wsize > MAXBSIZE) - nmp->nm_wsize = MAXBSIZE; + if (nmp->nm_wsize > NFS_MAXBSIZE) + nmp->nm_wsize = NFS_MAXBSIZE; if ((argp->flags & NFSMNT_RSIZE) && argp->rsize > 0) { nmp->nm_rsize = argp->rsize; @@ -1127,8 +1131,8 @@ mountnfs( } if (nmp->nm_rsize > maxio) nmp->nm_rsize = maxio; - if (nmp->nm_rsize > MAXBSIZE) - nmp->nm_rsize = MAXBSIZE; + if (nmp->nm_rsize > NFS_MAXBSIZE) + nmp->nm_rsize = NFS_MAXBSIZE; if ((argp->flags & NFSMNT_READDIRSIZE) && argp->readdirsize > 0) { nmp->nm_readdirsize = argp->readdirsize; @@ -1182,7 +1186,7 @@ mountnfs( */ // LP64todo - fix CAST_DOWN of argp->fh error = nfs_getattr_no_vnode(mp, CAST_DOWN(caddr_t, argp->fh), argp->fhsize, - proc_ucred(p), p, &nvattrs, &xid); + context.vc_ucred, p, &nvattrs, &xid); if (error) { /* * we got problems... we couldn't get the attributes @@ -1224,8 +1228,9 @@ mountnfs( * the server about what its preferred I/O sizes are. */ if (nmp->nm_flag & NFSMNT_NFSV3) - nfs_fsinfo(nmp, *vpp, proc_ucred(p), p); - vfs_statfs(mp)->f_iosize = nfs_iosize(nmp); + nfs_fsinfo(nmp, *vpp, context.vc_ucred, p); + nmp->nm_biosize = nfs_biosize(nmp); + vfs_statfs(mp)->f_iosize = NFS_IOSIZE; /* * V3 mounts give us a (relatively) reliable remote access(2) @@ -1241,17 +1246,18 @@ mountnfs( * Do statfs to ensure static info gets set to reasonable values. */ context.vc_proc = p; - context.vc_ucred = proc_ucred(p); nfs_statfs(mp, vfs_statfs(mp), &context); if (nmp->nm_flag & NFSMNT_RESVPORT) nfs_resv_mounts++; nmp->nm_state |= NFSSTA_MOUNTED; + kauth_cred_unref(&context.vc_ucred); return (0); bad: nfs_disconnect(nmp); FREE_ZONE((caddr_t)nmp, sizeof (struct nfsmount), M_NFSMNT); mbuf_freem(nam); + kauth_cred_unref(&context.vc_ucred); return (error); }