]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/nfs_subs.c
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / nfs / nfs_subs.c
index 3b29e0670a8afcbe1f987e2fb8d4e251314896d9..12fd4deaa25a0b4d9a09a4d0dcea833be229252c 100644 (file)
@@ -1,23 +1,31 @@
 /*
- * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * 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.
+ * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
  * 
- * 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 OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * 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.  The rights granted to you under the 
+ * License may not be used to create, or enable the creation or 
+ * redistribution of, unlawful or unlicensed copies of an Apple operating 
+ * system, or to circumvent, violate, or enable the circumvention or 
+ * violation of, any terms of an Apple operating system software license 
+ * agreement.
+ *
+ * Please obtain a copy of the License at 
+ * http://www.opensource.apple.com/apsl/ 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 
+ * 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.
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
  */
 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
 /*
@@ -1214,6 +1222,7 @@ nfs_init(struct vfsconf *vfsp)
        }
        /* init nfsiod mutex */
        nfs_iod_lck_grp_attr = lck_grp_attr_alloc_init();
+       lck_grp_attr_setstat(nfs_iod_lck_grp_attr);
        nfs_iod_lck_grp = lck_grp_alloc_init("nfs_iod", nfs_iod_lck_grp_attr);
        nfs_iod_lck_attr = lck_attr_alloc_init();
        nfs_iod_mutex = lck_mtx_alloc_init(nfs_iod_lck_grp, nfs_iod_lck_attr);
@@ -1225,6 +1234,7 @@ nfs_init(struct vfsconf *vfsp)
 #ifndef NFS_NOSERVER
        /* init nfsd mutex */
        nfsd_lck_grp_attr = lck_grp_attr_alloc_init();
+       lck_grp_attr_setstat(nfsd_lck_grp_attr);
        nfsd_lck_grp = lck_grp_alloc_init("nfsd", nfsd_lck_grp_attr);
        nfsd_lck_attr = lck_attr_alloc_init();
        nfsd_mutex = lck_mtx_alloc_init(nfsd_lck_grp, nfsd_lck_attr);
@@ -2534,9 +2544,9 @@ nfsrv_export(struct user_nfs_export_args *unxa, struct vfs_context *ctx)
                        }
 
                        /* grab file handle */
-                       nx->nx_fh.nfh_xh.nxh_version = htonl(NFS_FH_VERSION);
-                       nx->nx_fh.nfh_xh.nxh_fsid = htonl(nx->nx_fs->nxfs_id);
-                       nx->nx_fh.nfh_xh.nxh_expid = htonl(nx->nx_id);
+                       nx->nx_fh.nfh_xh.nxh_version = NFS_FH_VERSION;
+                       nx->nx_fh.nfh_xh.nxh_fsid = nx->nx_fs->nxfs_id;
+                       nx->nx_fh.nfh_xh.nxh_expid = nx->nx_id;
                        nx->nx_fh.nfh_xh.nxh_flags = 0;
                        nx->nx_fh.nfh_xh.nxh_reserved = 0;
                        nx->nx_fh.nfh_len = NFS_MAX_FID_SIZE;
@@ -2648,15 +2658,11 @@ static struct nfs_export *
 nfsrv_fhtoexport(struct nfs_filehandle *nfhp)
 {
        struct nfs_export *nx;
-       uint32_t fsid, expid;
-
-       fsid = ntohl(nfhp->nfh_xh.nxh_fsid);
-       expid = ntohl(nfhp->nfh_xh.nxh_expid);
-       nx = NFSEXPHASH(fsid, expid)->lh_first;
+       nx = NFSEXPHASH(nfhp->nfh_xh.nxh_fsid, nfhp->nfh_xh.nxh_expid)->lh_first;
        for (; nx; nx = LIST_NEXT(nx, nx_hash)) {
-               if (nx->nx_fs->nxfs_id != fsid)
+               if (nx->nx_fs->nxfs_id != nfhp->nfh_xh.nxh_fsid)
                        continue;
-               if (nx->nx_id != expid)
+               if (nx->nx_id != nfhp->nfh_xh.nxh_expid)
                        continue;
                break;
        }
@@ -2677,14 +2683,12 @@ nfsrv_fhtovp(
 {
        int error;
        struct mount *mp;
-       uint32_t v;
 
        *vpp = NULL;
        *nxp = NULL;
        *nxop = NULL;
 
-       v = ntohl(nfhp->nfh_xh.nxh_version);
-       if (v != NFS_FH_VERSION) {
+       if (nfhp->nfh_xh.nxh_version != NFS_FH_VERSION) {
                /* file handle format not supported */
                return (ESTALE);
        }
@@ -2692,8 +2696,7 @@ nfsrv_fhtovp(
                return (EBADRPC);
        if (nfhp->nfh_len < (int)sizeof(nfhp->nfh_xh))
                return (ESTALE);
-       v = ntohs(nfhp->nfh_xh.nxh_flags);
-       if (v & NXHF_INVALIDFH)
+       if (nfhp->nfh_xh.nxh_flags & NXHF_INVALIDFH)
                return (ESTALE);
 
 /* XXX Revisit when enabling WebNFS */
@@ -2789,9 +2792,9 @@ nfsrv_vptofh(
 {
        int error;
 
-       nfhp->nfh_xh.nxh_version = htonl(NFS_FH_VERSION);
-       nfhp->nfh_xh.nxh_fsid = htonl(nx->nx_fs->nxfs_id);
-       nfhp->nfh_xh.nxh_expid = htonl(nx->nx_id);
+       nfhp->nfh_xh.nxh_version = NFS_FH_VERSION;
+       nfhp->nfh_xh.nxh_fsid = nx->nx_fs->nxfs_id;
+       nfhp->nfh_xh.nxh_expid = nx->nx_id;
        nfhp->nfh_xh.nxh_flags = 0;
        nfhp->nfh_xh.nxh_reserved = 0;
 
@@ -2802,7 +2805,7 @@ nfsrv_vptofh(
        if (dnfhp && nfsrv_fhmatch(dnfhp, &nx->nx_fh)) {
                nfhp->nfh_len = v2 ? NFSX_V2FH : sizeof(nfhp->nfh_xh);
                nfhp->nfh_xh.nxh_fidlen = 0;
-               nfhp->nfh_xh.nxh_flags = htons(NXHF_INVALIDFH);
+               nfhp->nfh_xh.nxh_flags = NXHF_INVALIDFH;
                return (0);
        }