| File: | bsd/nfs/nfs_vfsops.c |
| Warning: | line 5565, column 14 Copies out a struct with a partially unsanitized field |
| 1 | /* | |||
| 2 | * Copyright (c) 2000-2014 Apple Inc. All rights reserved. | |||
| 3 | * | |||
| 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |||
| 5 | * | |||
| 6 | * This file contains Original Code and/or Modifications of Original Code | |||
| 7 | * as defined in and that are subject to the Apple Public Source License | |||
| 8 | * Version 2.0 (the 'License'). You may not use this file except in | |||
| 9 | * compliance with the License. The rights granted to you under the License | |||
| 10 | * may not be used to create, or enable the creation or redistribution of, | |||
| 11 | * unlawful or unlicensed copies of an Apple operating system, or to | |||
| 12 | * circumvent, violate, or enable the circumvention or violation of, any | |||
| 13 | * terms of an Apple operating system software license agreement. | |||
| 14 | * | |||
| 15 | * Please obtain a copy of the License at | |||
| 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |||
| 17 | * | |||
| 18 | * The Original Code and all software distributed under the License are | |||
| 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |||
| 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |||
| 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |||
| 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |||
| 23 | * Please see the License for the specific language governing rights and | |||
| 24 | * limitations under the License. | |||
| 25 | * | |||
| 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |||
| 27 | */ | |||
| 28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |||
| 29 | /* | |||
| 30 | * Copyright (c) 1989, 1993, 1995 | |||
| 31 | * The Regents of the University of California. All rights reserved. | |||
| 32 | * | |||
| 33 | * This code is derived from software contributed to Berkeley by | |||
| 34 | * Rick Macklem at The University of Guelph. | |||
| 35 | * | |||
| 36 | * Redistribution and use in source and binary forms, with or without | |||
| 37 | * modification, are permitted provided that the following conditions | |||
| 38 | * are met: | |||
| 39 | * 1. Redistributions of source code must retain the above copyright | |||
| 40 | * notice, this list of conditions and the following disclaimer. | |||
| 41 | * 2. Redistributions in binary form must reproduce the above copyright | |||
| 42 | * notice, this list of conditions and the following disclaimer in the | |||
| 43 | * documentation and/or other materials provided with the distribution. | |||
| 44 | * 3. All advertising materials mentioning features or use of this software | |||
| 45 | * must display the following acknowledgement: | |||
| 46 | * This product includes software developed by the University of | |||
| 47 | * California, Berkeley and its contributors. | |||
| 48 | * 4. Neither the name of the University nor the names of its contributors | |||
| 49 | * may be used to endorse or promote products derived from this software | |||
| 50 | * without specific prior written permission. | |||
| 51 | * | |||
| 52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |||
| 53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||
| 54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||
| 55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |||
| 56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||
| 57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||
| 58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||
| 59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||
| 60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||
| 61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| 62 | * SUCH DAMAGE. | |||
| 63 | * | |||
| 64 | * @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95 | |||
| 65 | * FreeBSD-Id: nfs_vfsops.c,v 1.52 1997/11/12 05:42:21 julian Exp $ | |||
| 66 | */ | |||
| 67 | /* | |||
| 68 | * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce | |||
| 69 | * support for mandatory and extensible security protections. This notice | |||
| 70 | * is included in support of clause 2.2 (b) of the Apple Public License, | |||
| 71 | * Version 2.0. | |||
| 72 | */ | |||
| 73 | ||||
| 74 | #include <sys/param.h> | |||
| 75 | #include <sys/systm.h> | |||
| 76 | #include <sys/conf.h> | |||
| 77 | #include <sys/ioctl.h> | |||
| 78 | #include <sys/signal.h> | |||
| 79 | #include <sys/proc_internal.h> /* for fs rooting to update rootdir in fdp */ | |||
| 80 | #include <sys/kauth.h> | |||
| 81 | #include <sys/vnode_internal.h> | |||
| 82 | #include <sys/malloc.h> | |||
| 83 | #include <sys/kernel.h> | |||
| 84 | #include <sys/sysctl.h> | |||
| 85 | #include <sys/mount_internal.h> | |||
| 86 | #include <sys/kpi_mbuf.h> | |||
| 87 | #include <sys/socket.h> | |||
| 88 | #include <sys/socketvar.h> | |||
| 89 | #include <sys/fcntl.h> | |||
| 90 | #include <sys/quota.h> | |||
| 91 | #include <sys/priv.h> | |||
| 92 | #include <libkern/OSAtomic.h> | |||
| 93 | ||||
| 94 | #include <sys/vm.h> | |||
| 95 | #include <sys/vmparam.h> | |||
| 96 | ||||
| 97 | #if !defined(NO_MOUNT_PRIVATE) | |||
| 98 | #include <sys/filedesc.h> | |||
| 99 | #endif /* NO_MOUNT_PRIVATE */ | |||
| 100 | ||||
| 101 | #include <net/if.h> | |||
| 102 | #include <net/route.h> | |||
| 103 | #include <netinet/in.h> | |||
| 104 | ||||
| 105 | #include <nfs/rpcv2.h> | |||
| 106 | #include <nfs/krpc.h> | |||
| 107 | #include <nfs/nfsproto.h> | |||
| 108 | #include <nfs/nfs.h> | |||
| 109 | #include <nfs/nfsnode.h> | |||
| 110 | #include <nfs/nfs_gss.h> | |||
| 111 | #include <nfs/nfsmount.h> | |||
| 112 | #include <nfs/xdr_subs.h> | |||
| 113 | #include <nfs/nfsm_subs.h> | |||
| 114 | #include <nfs/nfsdiskless.h> | |||
| 115 | #include <nfs/nfs_lock.h> | |||
| 116 | #if CONFIG_MACF1 | |||
| 117 | #include <security/mac_framework.h> | |||
| 118 | #endif | |||
| 119 | ||||
| 120 | #include <pexpert/pexpert.h> | |||
| 121 | ||||
| 122 | #define NFS_VFS_DBG(...)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " ..., __func__, 122) NFS_DBG(NFS_FAC_VFS, 7, ## __VA_ARGS__)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " ## __VA_ARGS__, __func__, 122) | |||
| 123 | ||||
| 124 | /* | |||
| 125 | * NFS client globals | |||
| 126 | */ | |||
| 127 | ||||
| 128 | int nfs_ticks; | |||
| 129 | static lck_grp_t *nfs_global_grp, *nfs_mount_grp; | |||
| 130 | lck_mtx_t *nfs_global_mutex; | |||
| 131 | uint32_t nfs_fs_attr_bitmap[NFS_ATTR_BITMAP_LEN2]; | |||
| 132 | uint32_t nfs_object_attr_bitmap[NFS_ATTR_BITMAP_LEN2]; | |||
| 133 | uint32_t nfs_getattr_bitmap[NFS_ATTR_BITMAP_LEN2]; | |||
| 134 | struct nfsclientidlist nfsclientids; | |||
| 135 | ||||
| 136 | /* NFS requests */ | |||
| 137 | struct nfs_reqqhead nfs_reqq; | |||
| 138 | lck_grp_t *nfs_request_grp; | |||
| 139 | lck_mtx_t *nfs_request_mutex; | |||
| 140 | thread_call_t nfs_request_timer_call; | |||
| 141 | int nfs_request_timer_on; | |||
| 142 | u_int32_t nfs_xid = 0; | |||
| 143 | u_int32_t nfs_xidwrap = 0; /* to build a (non-wrapping) 64 bit xid */ | |||
| 144 | ||||
| 145 | thread_call_t nfs_buf_timer_call; | |||
| 146 | ||||
| 147 | /* NFSv4 */ | |||
| 148 | lck_grp_t *nfs_open_grp; | |||
| 149 | uint32_t nfs_open_owner_seqnum = 0; | |||
| 150 | uint32_t nfs_lock_owner_seqnum = 0; | |||
| 151 | thread_call_t nfs4_callback_timer_call; | |||
| 152 | int nfs4_callback_timer_on = 0; | |||
| 153 | char nfs4_domain[MAXPATHLEN1024]; | |||
| 154 | ||||
| 155 | /* nfsiod */ | |||
| 156 | lck_grp_t *nfsiod_lck_grp; | |||
| 157 | lck_mtx_t *nfsiod_mutex; | |||
| 158 | struct nfsiodlist nfsiodfree, nfsiodwork; | |||
| 159 | struct nfsiodmountlist nfsiodmounts; | |||
| 160 | int nfsiod_thread_count = 0; | |||
| 161 | int nfsiod_thread_max = NFS_DEFASYNCTHREAD16; | |||
| 162 | int nfs_max_async_writes = NFS_DEFMAXASYNCWRITES128; | |||
| 163 | ||||
| 164 | int nfs_iosize = NFS_IOSIZE(1024 * 1024); | |||
| 165 | int nfs_access_cache_timeout = NFS_MAXATTRTIMO60; | |||
| 166 | int nfs_access_delete = 1; /* too many servers get this wrong - workaround on by default */ | |||
| 167 | int nfs_access_dotzfs = 1; | |||
| 168 | int nfs_access_for_getattr = 0; | |||
| 169 | int nfs_allow_async = 0; | |||
| 170 | int nfs_statfs_rate_limit = NFS_DEFSTATFSRATELIMIT10; | |||
| 171 | int nfs_lockd_mounts = 0; | |||
| 172 | int nfs_lockd_request_sent = 0; | |||
| 173 | int nfs_idmap_ctrl = NFS_IDMAP_CTRL_USE_IDMAP_SERVICE0x00000001; | |||
| 174 | int nfs_callback_port = 0; | |||
| 175 | ||||
| 176 | int nfs_tprintf_initial_delay = NFS_TPRINTF_INITIAL_DELAY12; | |||
| 177 | int nfs_tprintf_delay = NFS_TPRINTF_DELAY30; | |||
| 178 | ||||
| 179 | ||||
| 180 | int mountnfs(char *, mount_t, vfs_context_t, vnode_t *); | |||
| 181 | static int nfs_mount_diskless(struct nfs_dlmount *, const char *, int, vnode_t *, mount_t *, vfs_context_t); | |||
| 182 | #if !defined(NO_MOUNT_PRIVATE) | |||
| 183 | static int nfs_mount_diskless_private(struct nfs_dlmount *, const char *, int, vnode_t *, mount_t *, vfs_context_t); | |||
| 184 | #endif /* NO_MOUNT_PRIVATE */ | |||
| 185 | int nfs_mount_connect(struct nfsmount *); | |||
| 186 | void nfs_mount_drain_and_cleanup(struct nfsmount *); | |||
| 187 | void nfs_mount_cleanup(struct nfsmount *); | |||
| 188 | int nfs_mountinfo_assemble(struct nfsmount *, struct xdrbuf *); | |||
| 189 | int nfs4_mount_update_path_with_symlink(struct nfsmount *, struct nfs_fs_path *, uint32_t, fhandle_t *, int *, fhandle_t *, vfs_context_t); | |||
| 190 | ||||
| 191 | /* | |||
| 192 | * NFS VFS operations. | |||
| 193 | */ | |||
| 194 | int nfs_vfs_mount(mount_t, vnode_t, user_addr_t, vfs_context_t); | |||
| 195 | int nfs_vfs_start(mount_t, int, vfs_context_t); | |||
| 196 | int nfs_vfs_unmount(mount_t, int, vfs_context_t); | |||
| 197 | int nfs_vfs_root(mount_t, vnode_t *, vfs_context_t); | |||
| 198 | int nfs_vfs_quotactl(mount_t, int, uid_t, caddr_t, vfs_context_t); | |||
| 199 | int nfs_vfs_getattr(mount_t, struct vfs_attr *, vfs_context_t); | |||
| 200 | int nfs_vfs_sync(mount_t, int, vfs_context_t); | |||
| 201 | int nfs_vfs_vget(mount_t, ino64_t, vnode_t *, vfs_context_t); | |||
| 202 | int nfs_vfs_vptofh(vnode_t, int *, unsigned char *, vfs_context_t); | |||
| 203 | int nfs_vfs_fhtovp(mount_t, int, unsigned char *, vnode_t *, vfs_context_t); | |||
| 204 | int nfs_vfs_init(struct vfsconf *); | |||
| 205 | int nfs_vfs_sysctl(int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t); | |||
| 206 | ||||
| 207 | struct vfsops nfs_vfsops = { | |||
| 208 | .vfs_mount = nfs_vfs_mount, | |||
| 209 | .vfs_start = nfs_vfs_start, | |||
| 210 | .vfs_unmount = nfs_vfs_unmount, | |||
| 211 | .vfs_root = nfs_vfs_root, | |||
| 212 | .vfs_quotactl = nfs_vfs_quotactl, | |||
| 213 | .vfs_getattr = nfs_vfs_getattr, | |||
| 214 | .vfs_sync = nfs_vfs_sync, | |||
| 215 | .vfs_vget = nfs_vfs_vget, | |||
| 216 | .vfs_fhtovp = nfs_vfs_fhtovp, | |||
| 217 | .vfs_vptofh = nfs_vfs_vptofh, | |||
| 218 | .vfs_init = nfs_vfs_init, | |||
| 219 | .vfs_sysctl = nfs_vfs_sysctl, | |||
| 220 | // We do not support the remaining VFS ops | |||
| 221 | }; | |||
| 222 | ||||
| 223 | ||||
| 224 | /* | |||
| 225 | * version-specific NFS functions | |||
| 226 | */ | |||
| 227 | int nfs3_mount(struct nfsmount *, vfs_context_t, nfsnode_t *); | |||
| 228 | int nfs4_mount(struct nfsmount *, vfs_context_t, nfsnode_t *); | |||
| 229 | int nfs3_fsinfo(struct nfsmount *, nfsnode_t, vfs_context_t); | |||
| 230 | int nfs3_update_statfs(struct nfsmount *, vfs_context_t); | |||
| 231 | int nfs4_update_statfs(struct nfsmount *, vfs_context_t); | |||
| 232 | #if !QUOTA1 | |||
| 233 | #define nfs3_getquota NULL((void *)0) | |||
| 234 | #define nfs4_getquota NULL((void *)0) | |||
| 235 | #else | |||
| 236 | int nfs3_getquota(struct nfsmount *, vfs_context_t, uid_t, int, struct dqblk *); | |||
| 237 | int nfs4_getquota(struct nfsmount *, vfs_context_t, uid_t, int, struct dqblk *); | |||
| 238 | #endif | |||
| 239 | ||||
| 240 | struct nfs_funcs nfs3_funcs = { | |||
| 241 | nfs3_mount, | |||
| 242 | nfs3_update_statfs, | |||
| 243 | nfs3_getquota, | |||
| 244 | nfs3_access_rpc, | |||
| 245 | nfs3_getattr_rpc, | |||
| 246 | nfs3_setattr_rpc, | |||
| 247 | nfs3_read_rpc_async, | |||
| 248 | nfs3_read_rpc_async_finish, | |||
| 249 | nfs3_readlink_rpc, | |||
| 250 | nfs3_write_rpc_async, | |||
| 251 | nfs3_write_rpc_async_finish, | |||
| 252 | nfs3_commit_rpc, | |||
| 253 | nfs3_lookup_rpc_async, | |||
| 254 | nfs3_lookup_rpc_async_finish, | |||
| 255 | nfs3_remove_rpc, | |||
| 256 | nfs3_rename_rpc, | |||
| 257 | nfs3_setlock_rpc, | |||
| 258 | nfs3_unlock_rpc, | |||
| 259 | nfs3_getlock_rpc | |||
| 260 | }; | |||
| 261 | struct nfs_funcs nfs4_funcs = { | |||
| 262 | nfs4_mount, | |||
| 263 | nfs4_update_statfs, | |||
| 264 | nfs4_getquota, | |||
| 265 | nfs4_access_rpc, | |||
| 266 | nfs4_getattr_rpc, | |||
| 267 | nfs4_setattr_rpc, | |||
| 268 | nfs4_read_rpc_async, | |||
| 269 | nfs4_read_rpc_async_finish, | |||
| 270 | nfs4_readlink_rpc, | |||
| 271 | nfs4_write_rpc_async, | |||
| 272 | nfs4_write_rpc_async_finish, | |||
| 273 | nfs4_commit_rpc, | |||
| 274 | nfs4_lookup_rpc_async, | |||
| 275 | nfs4_lookup_rpc_async_finish, | |||
| 276 | nfs4_remove_rpc, | |||
| 277 | nfs4_rename_rpc, | |||
| 278 | nfs4_setlock_rpc, | |||
| 279 | nfs4_unlock_rpc, | |||
| 280 | nfs4_getlock_rpc | |||
| 281 | }; | |||
| 282 | ||||
| 283 | /* | |||
| 284 | * Called once to initialize data structures... | |||
| 285 | */ | |||
| 286 | int | |||
| 287 | nfs_vfs_init(__unused__attribute__((unused)) struct vfsconf *vfsp) | |||
| 288 | { | |||
| 289 | int i; | |||
| 290 | ||||
| 291 | /* | |||
| 292 | * Check to see if major data structures haven't bloated. | |||
| 293 | */ | |||
| 294 | if (sizeof (struct nfsnode) > NFS_NODEALLOC1024) { | |||
| 295 | printf("struct nfsnode bloated (> %dbytes)\n", NFS_NODEALLOC1024); | |||
| 296 | printf("Try reducing NFS_SMALLFH\n"); | |||
| 297 | } | |||
| 298 | if (sizeof (struct nfsmount) > NFS_MNTALLOC1024) | |||
| 299 | printf("struct nfsmount bloated (> %dbytes)\n", NFS_MNTALLOC1024); | |||
| 300 | ||||
| 301 | nfs_ticks = (hz * NFS_TICKINTVL5 + 500) / 1000; | |||
| 302 | if (nfs_ticks < 1) | |||
| 303 | nfs_ticks = 1; | |||
| 304 | ||||
| 305 | /* init async I/O thread pool state */ | |||
| 306 | TAILQ_INIT(&nfsiodfree)do { (((&nfsiodfree))->tqh_first) = ((void *)0); (& nfsiodfree)->tqh_last = &(((&nfsiodfree))->tqh_first ); ; } while (0); | |||
| 307 | TAILQ_INIT(&nfsiodwork)do { (((&nfsiodwork))->tqh_first) = ((void *)0); (& nfsiodwork)->tqh_last = &(((&nfsiodwork))->tqh_first ); ; } while (0); | |||
| 308 | TAILQ_INIT(&nfsiodmounts)do { (((&nfsiodmounts))->tqh_first) = ((void *)0); (& nfsiodmounts)->tqh_last = &(((&nfsiodmounts))-> tqh_first); ; } while (0); | |||
| 309 | nfsiod_lck_grp = lck_grp_alloc_init("nfsiod", LCK_GRP_ATTR_NULL(lck_grp_attr_t *)0); | |||
| 310 | nfsiod_mutex = lck_mtx_alloc_init(nfsiod_lck_grp, LCK_ATTR_NULL(lck_attr_t *)0); | |||
| 311 | ||||
| 312 | /* init lock groups, etc. */ | |||
| 313 | nfs_mount_grp = lck_grp_alloc_init("nfs_mount", LCK_GRP_ATTR_NULL(lck_grp_attr_t *)0); | |||
| 314 | nfs_open_grp = lck_grp_alloc_init("nfs_open", LCK_GRP_ATTR_NULL(lck_grp_attr_t *)0); | |||
| 315 | nfs_global_grp = lck_grp_alloc_init("nfs_global", LCK_GRP_ATTR_NULL(lck_grp_attr_t *)0); | |||
| 316 | ||||
| 317 | nfs_global_mutex = lck_mtx_alloc_init(nfs_global_grp, LCK_ATTR_NULL(lck_attr_t *)0); | |||
| 318 | ||||
| 319 | /* init request list mutex */ | |||
| 320 | nfs_request_grp = lck_grp_alloc_init("nfs_request", LCK_GRP_ATTR_NULL(lck_grp_attr_t *)0); | |||
| 321 | nfs_request_mutex = lck_mtx_alloc_init(nfs_request_grp, LCK_ATTR_NULL(lck_attr_t *)0); | |||
| 322 | ||||
| 323 | /* initialize NFS request list */ | |||
| 324 | TAILQ_INIT(&nfs_reqq)do { (((&nfs_reqq))->tqh_first) = ((void *)0); (&nfs_reqq )->tqh_last = &(((&nfs_reqq))->tqh_first); ; } while (0); | |||
| 325 | ||||
| 326 | nfs_nbinit(); /* Init the nfsbuf table */ | |||
| 327 | nfs_nhinit(); /* Init the nfsnode table */ | |||
| 328 | nfs_lockinit(); /* Init the nfs lock state */ | |||
| 329 | nfs_gss_init(); /* Init RPCSEC_GSS security */ | |||
| 330 | ||||
| 331 | /* NFSv4 stuff */ | |||
| 332 | NFS4_PER_FS_ATTRIBUTES(nfs_fs_attr_bitmap)do { (((uint32_t *)((nfs_fs_attr_bitmap)))[(0)/32] |= 1<< ((0)%32)); (((uint32_t *)((nfs_fs_attr_bitmap)))[(2)/32] |= 1 <<((2)%32)); (((uint32_t *)((nfs_fs_attr_bitmap)))[(5)/ 32] |= 1<<((5)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(6)/32] |= 1<<((6)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(9)/32] |= 1<<((9)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(10)/32] |= 1<<((10)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(13)/32] |= 1<<((13)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(15)/32] |= 1<<((15)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(16)/32] |= 1<<((16)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(17)/32] |= 1<<((17)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(18)/32] |= 1<<((18)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(21)/32] |= 1<<((21)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(22)/32] |= 1<<((22)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(23)/32] |= 1<<((23)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(24)/32] |= 1<<((24)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(26)/32] |= 1<<((26)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(27)/32] |= 1<<((27)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(29)/32] |= 1<<((29)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(30)/32] |= 1<<((30)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(31)/32] |= 1<<((31)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(34)/32] |= 1<<((34)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(42)/32] |= 1<<((42)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(43)/32] |= 1<<((43)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(44)/32] |= 1<<((44)%32)); (((uint32_t *)((nfs_fs_attr_bitmap )))[(51)/32] |= 1<<((51)%32)); } while (0); | |||
| 333 | NFS4_PER_OBJECT_ATTRIBUTES(nfs_object_attr_bitmap)do { (((uint32_t *)((nfs_object_attr_bitmap)))[(1)/32] |= 1<< ((1)%32)); (((uint32_t *)((nfs_object_attr_bitmap)))[(3)/32] |= 1<<((3)%32)); (((uint32_t *)((nfs_object_attr_bitmap)) )[(4)/32] |= 1<<((4)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(7)/32] |= 1<<((7)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(8)/32] |= 1<<((8)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(11)/32] |= 1<<((11)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(19)/32] |= 1<<((19)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(12)/32] |= 1<<((12)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(14)/32] |= 1<<((14)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(20)/32] |= 1<<((20)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(25)/32] |= 1<<((25)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(28)/32] |= 1<<((28)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(32)/32] |= 1<<((32)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(33)/32] |= 1<<((33)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(35)/32] |= 1<<((35)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(36)/32] |= 1<<((36)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(37)/32] |= 1<<((37)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(41)/32] |= 1<<((41)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(45)/32] |= 1<<((45)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(46)/32] |= 1<<((46)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(47)/32] |= 1<<((47)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(49)/32] |= 1<<((49)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(50)/32] |= 1<<((50)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(52)/32] |= 1<<((52)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(53)/32] |= 1<<((53)%32)); (((uint32_t *)((nfs_object_attr_bitmap )))[(55)/32] |= 1<<((55)%32)); } while (0); | |||
| 334 | NFS4_DEFAULT_ATTRIBUTES(nfs_getattr_bitmap)do { (((uint32_t *)((nfs_getattr_bitmap)))[(0)/32] |= 1<< ((0)%32)); (((uint32_t *)((nfs_getattr_bitmap)))[(1)/32] |= 1 <<((1)%32)); (((uint32_t *)((nfs_getattr_bitmap)))[(2)/ 32] |= 1<<((2)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(3)/32] |= 1<<((3)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(4)/32] |= 1<<((4)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(5)/32] |= 1<<((5)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(6)/32] |= 1<<((6)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(7)/32] |= 1<<((7)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(8)/32] |= 1<<((8)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(9)/32] |= 1<<((9)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(10)/32] |= 1<<((10)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(13)/32] |= 1<<((13)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(14)/32] |= 1<<((14)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(16)/32] |= 1<<((16)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(17)/32] |= 1<<((17)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(18)/32] |= 1<<((18)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(20)/32] |= 1<<((20)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(21)/32] |= 1<<((21)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(22)/32] |= 1<<((22)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(23)/32] |= 1<<((23)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(25)/32] |= 1<<((25)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(26)/32] |= 1<<((26)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(27)/32] |= 1<<((27)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(28)/32] |= 1<<((28)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(29)/32] |= 1<<((29)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(30)/32] |= 1<<((30)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(31)/32] |= 1<<((31)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(33)/32] |= 1<<((33)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(34)/32] |= 1<<((34)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(35)/32] |= 1<<((35)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(36)/32] |= 1<<((36)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(37)/32] |= 1<<((37)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(41)/32] |= 1<<((41)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(42)/32] |= 1<<((42)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(43)/32] |= 1<<((43)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(44)/32] |= 1<<((44)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(45)/32] |= 1<<((45)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(47)/32] |= 1<<((47)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(49)/32] |= 1<<((49)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(50)/32] |= 1<<((50)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(52)/32] |= 1<<((52)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(53)/32] |= 1<<((53)%32)); (((uint32_t *)((nfs_getattr_bitmap )))[(55)/32] |= 1<<((55)%32)); } while (0); | |||
| 335 | for (i=0; i < NFS_ATTR_BITMAP_LEN2; i++) | |||
| 336 | nfs_getattr_bitmap[i] &= nfs_object_attr_bitmap[i]; | |||
| 337 | TAILQ_INIT(&nfsclientids)do { (((&nfsclientids))->tqh_first) = ((void *)0); (& nfsclientids)->tqh_last = &(((&nfsclientids))-> tqh_first); ; } while (0); | |||
| 338 | ||||
| 339 | /* initialize NFS timer callouts */ | |||
| 340 | nfs_request_timer_call = thread_call_allocate(nfs_request_timer, NULL((void *)0)); | |||
| 341 | nfs_buf_timer_call = thread_call_allocate(nfs_buf_timer, NULL((void *)0)); | |||
| 342 | nfs4_callback_timer_call = thread_call_allocate(nfs4_callback_timer, NULL((void *)0)); | |||
| 343 | ||||
| 344 | return (0); | |||
| 345 | } | |||
| 346 | ||||
| 347 | /* | |||
| 348 | * nfs statfs call | |||
| 349 | */ | |||
| 350 | int | |||
| 351 | nfs3_update_statfs(struct nfsmount *nmp, vfs_context_t ctx) | |||
| 352 | { | |||
| 353 | nfsnode_t np; | |||
| 354 | int error = 0, lockerror, status, nfsvers; | |||
| 355 | u_int64_t xid; | |||
| 356 | struct nfsm_chain nmreq, nmrep; | |||
| 357 | uint32_t val = 0; | |||
| 358 | ||||
| 359 | nfsvers = nmp->nm_vers; | |||
| 360 | np = nmp->nm_dnp; | |||
| 361 | if (!np) | |||
| 362 | return (ENXIO6); | |||
| 363 | if ((error = vnode_get(NFSTOV(np)((np)->n_vnode)))) | |||
| 364 | return (error); | |||
| 365 | ||||
| 366 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 367 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 368 | ||||
| 369 | nfsm_chain_build_alloc_init(error, &nmreq, NFSX_FH(nfsvers))do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )(((((nfsvers) == 2) ? 32 : (4 + (((nfsvers) == 3) ? 64 : 128 ))))) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget(MBUF_WAITOK , MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK , MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break ; do { ((&nmreq))->nmc_mhead = (ncbimb); ((&nmreq) )->nmc_mcur = ((&nmreq))->nmc_mhead; ((&nmreq)) ->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur); ((& nmreq))->nmc_left = mbuf_trailingspace(((&nmreq))-> nmc_mcur); ((&nmreq))->nmc_flags = 0; } while (0); } while (0); | |||
| 370 | nfsm_chain_add_fh(error, &nmreq, nfsvers, np->n_fhp, np->n_fhsize)do { if (error) break; if ((nfsvers) != 2) do { do { if (((error ))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error ))) = nfsm_chain_new_mbuf((((&nmreq))), (4)); if (!(((error ))) && ((((&nmreq)))->nmc_left < (4))) (((error ))) = 12; } } while (0); if ((error)) break; *((uint32_t*)((& nmreq))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((np-> n_fhsize))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((np-> n_fhsize))) & 0xff000000) >> 24) | (((__uint32_t)(( uint32_t)((np->n_fhsize))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(( np->n_fhsize))))); ((&nmreq))->nmc_ptr += 4; ((& nmreq))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((np->n_fhsize))+3)&(~0x3)); if ((error)) break; if (((&nmreq))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f (((&nmreq)), (const u_char*)((np->n_fhp)), ((np->n_fhsize ))); break; } *(((uint32_t*)(((&nmreq))->nmc_ptr))+((( ((((np->n_fhsize)))+3)&(~0x3))>>2)-1)) = 0; bcopy (((np->n_fhp)), ((&nmreq))->nmc_ptr, ((np->n_fhsize ))); ((&nmreq))->nmc_ptr += rndlen; ((&nmreq))-> nmc_left -= rndlen; } while (0); } while (0); | |||
| 371 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 372 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 373 | error = nfs_request2(np, NULL((void *)0), &nmreq, NFSPROC_FSSTAT18, vfs_context_thread(ctx), | |||
| 374 | vfs_context_ucred(ctx), NULL((void *)0), R_SOFT0x00010000, &nmrep, &xid, &status); | |||
| 375 | if (error == ETIMEDOUT60) | |||
| 376 | goto nfsmout; | |||
| 377 | if ((lockerror = nfs_node_lock(np))) | |||
| 378 | error = lockerror; | |||
| 379 | if (nfsvers == NFS_VER33) | |||
| 380 | nfsm_chain_postop_attr_update(error, &nmrep, np, &xid)do { int __dummy_flag = 0; do { struct nfs_vattr ttvattr; do { ((__dummy_flag)) = 0; if ((((error))) || !(((&nmrep)))-> nmc_mhead) break; do { uint32_t __tmp32, *__tmpptr; if ((((error )))) break; if (((((&nmrep))))->nmc_left >= 4) { __tmpptr = (uint32_t*)((((&nmrep))))->nmc_ptr; ((((&nmrep) )))->nmc_left -= 4; ((((&nmrep))))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((((error)))) = nfsm_chain_get_opaque_f (((((&nmrep)))), 4, (u_char*)__tmpptr); if ((((error)))) break ; } (((__dummy_flag))) = ((uint32_t)(__builtin_constant_p((uint32_t )(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); if ((((error))) || !( (__dummy_flag))) break; if (((((error))) = nfs_parsefattr(((( &nmrep))), 3, (&ttvattr)))) ((__dummy_flag)) = 0; } while (0); if (((error)) || !(__dummy_flag)) break; if ((((error)) = nfs_loadattrcache(((np)), &ttvattr, ((&xid)), 1))) { (__dummy_flag) = 0; break; } if (*((&xid)) == 0) (__dummy_flag ) = 0; } while (0); } while (0); | |||
| 381 | if (!lockerror) | |||
| 382 | nfs_node_unlock(np); | |||
| 383 | if (!error) | |||
| 384 | error = status; | |||
| 385 | nfsm_assert(error, NFSTONMP(np), ENXIO)do { if (error) break; if (!(((vnode_mount(((np)->n_vnode) )) ? ((struct nfsmount *)vfs_fsprivate(vnode_mount(((np)-> n_vnode)))) : ((void *)0)))) (error) = (6); } while (0); | |||
| 386 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 387 | lck_mtx_lock(&nmp->nm_lock); | |||
| 388 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_TOTAL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(44)/32] |= 1<< ((44)%32)); | |||
| 389 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_FREE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(43)/32] |= 1<< ((43)%32)); | |||
| 390 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_AVAIL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(42)/32] |= 1<< ((42)%32)); | |||
| 391 | if (nfsvers == NFS_VER33) { | |||
| 392 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_AVAIL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(21)/32] |= 1<< ((21)%32)); | |||
| 393 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_TOTAL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(23)/32] |= 1<< ((23)%32)); | |||
| 394 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_FREE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(22)/32] |= 1<< ((22)%32)); | |||
| 395 | nmp->nm_fsattr.nfsa_bsize = NFS_FABLKSIZE512; | |||
| 396 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_space_total)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_space_total)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_space_total )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 397 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_space_free)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_space_free)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_space_free )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 398 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_space_avail)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_space_avail)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_space_avail )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 399 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_files_total)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_files_total)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_files_total )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 400 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_files_free)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_files_free)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_files_free )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 401 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_files_avail)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_files_avail)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_files_avail )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 402 | // skip invarsec | |||
| 403 | } else { | |||
| 404 | nfsm_chain_adv(error, &nmrep, NFSX_UNSIGNED)do { if (error) break; if ((&nmrep)->nmc_left >= (uint32_t )(4)) { (&nmrep)->nmc_left -= (4); (&nmrep)->nmc_ptr += (4); } else { (error) = nfsm_chain_advance((&nmrep), ( 4)); } } while (0); // skip tsize? | |||
| 405 | nfsm_chain_get_32(error, &nmrep, nmp->nm_fsattr.nfsa_bsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (nmp ->nm_fsattr.nfsa_bsize) = ((uint32_t)(__builtin_constant_p ((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t) ((uint32_t)(*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 406 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 407 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 408 | if (nmp->nm_fsattr.nfsa_bsize <= 0) | |||
| 409 | nmp->nm_fsattr.nfsa_bsize = NFS_FABLKSIZE512; | |||
| 410 | nmp->nm_fsattr.nfsa_space_total = (uint64_t)val * nmp->nm_fsattr.nfsa_bsize; | |||
| 411 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 412 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 413 | nmp->nm_fsattr.nfsa_space_free = (uint64_t)val * nmp->nm_fsattr.nfsa_bsize; | |||
| 414 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 415 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 416 | nmp->nm_fsattr.nfsa_space_avail = (uint64_t)val * nmp->nm_fsattr.nfsa_bsize; | |||
| 417 | } | |||
| 418 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 419 | nfsmout: | |||
| 420 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 421 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 422 | vnode_put(NFSTOV(np)((np)->n_vnode)); | |||
| 423 | return (error); | |||
| 424 | } | |||
| 425 | ||||
| 426 | int | |||
| 427 | nfs4_update_statfs(struct nfsmount *nmp, vfs_context_t ctx) | |||
| 428 | { | |||
| 429 | nfsnode_t np; | |||
| 430 | int error = 0, lockerror, status, nfsvers, numops; | |||
| 431 | u_int64_t xid; | |||
| 432 | struct nfsm_chain nmreq, nmrep; | |||
| 433 | uint32_t bitmap[NFS_ATTR_BITMAP_LEN2]; | |||
| 434 | struct nfs_vattr nvattr; | |||
| 435 | struct nfsreq_secinfo_args si; | |||
| 436 | ||||
| 437 | nfsvers = nmp->nm_vers; | |||
| 438 | np = nmp->nm_dnp; | |||
| 439 | if (!np) | |||
| 440 | return (ENXIO6); | |||
| 441 | if ((error = vnode_get(NFSTOV(np)((np)->n_vnode)))) | |||
| 442 | return (error); | |||
| 443 | ||||
| 444 | NFSREQ_SECINFO_SET(&si, np, NULL, 0, NULL, 0)do { (&si)->rsia_np = (np); (&si)->rsia_fh = (( (void *)0)); (&si)->rsia_fhsize = (0); (&si)->rsia_name = (((void *)0)); (&si)->rsia_namelen = (0); } while ( 0); | |||
| 445 | NVATTR_INIT(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); (& nvattr)->nva_flags = 0; (&nvattr)->nva_acl = ((void *)0); } while (0); | |||
| 446 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 447 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 448 | ||||
| 449 | // PUTFH + GETATTR | |||
| 450 | numops = 2; | |||
| 451 | nfsm_chain_build_alloc_init(error, &nmreq, 15 * NFSX_UNSIGNED)do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((15 * 4)) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget (MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 452 | nfsm_chain_add_compound_header(error, &nmreq, "statfs", nmp->nm_minor_vers, numops)do { if (("statfs") && strlen("statfs")) { char __nfstag [12 +1]; snprintf(__nfstag, sizeof(__nfstag), "%-*s", 12, ("statfs" )); do { do { if (((error))) break; if ((((&nmreq)))-> nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((& nmreq))), (4)); if (!(((error))) && ((((&nmreq))) ->nmc_left < (4))) (((error))) = 12; } } while (0); if ( (error)) break; *((uint32_t*)((&nmreq))->nmc_ptr) = (( __builtin_constant_p((uint32_t)(12)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(12)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(12)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(12)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(12)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(12)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq ))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((( 12)+3)&(~0x3)); if ((error)) break; if (((&nmreq))-> nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(( (&nmreq)), (const u_char*)(__nfstag), (12)); break; } *(( (uint32_t*)(((&nmreq))->nmc_ptr))+((((((12))+3)&(~ 0x3))>>2)-1)) = 0; bcopy((__nfstag), ((&nmreq))-> nmc_ptr, (12)); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } else { do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), ( 4)); if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break ; *((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); } do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((nmp->nm_minor_vers) )) ? ((__uint32_t)((((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((nmp->nm_minor_vers))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((nmp->nm_minor_vers))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((nmp->nm_minor_vers))))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((numops))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((numops))) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)((numops))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((numops))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numops))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numops))))); ((&nmreq))->nmc_ptr += 4; (( &nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 453 | numops--; | |||
| 454 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(22)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(22)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(22)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(22)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(22)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(22)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 455 | nfsm_chain_add_fh(error, &nmreq, nfsvers, np->n_fhp, np->n_fhsize)do { if (error) break; if ((nfsvers) != 2) do { do { if (((error ))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error ))) = nfsm_chain_new_mbuf((((&nmreq))), (4)); if (!(((error ))) && ((((&nmreq)))->nmc_left < (4))) (((error ))) = 12; } } while (0); if ((error)) break; *((uint32_t*)((& nmreq))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((np-> n_fhsize))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((np-> n_fhsize))) & 0xff000000) >> 24) | (((__uint32_t)(( uint32_t)((np->n_fhsize))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(( np->n_fhsize))))); ((&nmreq))->nmc_ptr += 4; ((& nmreq))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((np->n_fhsize))+3)&(~0x3)); if ((error)) break; if (((&nmreq))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f (((&nmreq)), (const u_char*)((np->n_fhp)), ((np->n_fhsize ))); break; } *(((uint32_t*)(((&nmreq))->nmc_ptr))+((( ((((np->n_fhsize)))+3)&(~0x3))>>2)-1)) = 0; bcopy (((np->n_fhp)), ((&nmreq))->nmc_ptr, ((np->n_fhsize ))); ((&nmreq))->nmc_ptr += rndlen; ((&nmreq))-> nmc_left -= rndlen; } while (0); } while (0); | |||
| 456 | numops--; | |||
| 457 | nfsm_chain_add_32(error, &nmreq, NFS_OP_GETATTR)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(9)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(9)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(9)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(9)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(9)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(9)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 458 | NFS_COPY_ATTRIBUTES(nfs_getattr_bitmap, bitmap)do { int __i; for (__i=0; __i < 2; __i++) ((uint32_t*)(bitmap ))[__i] = ((uint32_t*)(nfs_getattr_bitmap))[__i]; } while (0); | |||
| 459 | NFS4_STATFS_ATTRIBUTES(bitmap)do { (((uint32_t *)((bitmap)))[(21)/32] |= 1<<((21)%32) ); (((uint32_t *)((bitmap)))[(22)/32] |= 1<<((22)%32)); (((uint32_t *)((bitmap)))[(23)/32] |= 1<<((23)%32)); ( ((uint32_t *)((bitmap)))[(42)/32] |= 1<<((42)%32)); ((( uint32_t *)((bitmap)))[(43)/32] |= 1<<((43)%32)); (((uint32_t *)((bitmap)))[(44)/32] |= 1<<((44)%32)); } while (0); | |||
| 460 | nfsm_chain_add_bitmap_supported(error, &nmreq, bitmap, nmp, np)do { uint32_t __bitmap[2], *__bmp = (bitmap); int __nonamedattr = 0, __noacl = 0, __nomode = 0; if (!((nmp)->nm_fsattr.nfsa_flags & 0x00000400) || ((np) && (((nfsnode_t)(np))-> n_flag & (0x04000|0x08000)))) __nonamedattr = 1; if (!((nmp )->nm_fsattr.nfsa_flags & 0x00000008)) __noacl = 1; if ((((uint32_t *)(((nmp))->nm_flags))[(13)/32] & (1<< ((13)%32)))) __nomode = 1; if (__nonamedattr || __noacl || __nomode ) { int __ii; do { int __i; for (__i=0; __i < (2); __i++) ( (uint32_t*)((__bitmap)))[__i] = 0; } while (0); for (__ii=0; __ii < 2; __ii++) __bitmap[__ii] = (bitmap)[__ii]; if (__nonamedattr ) (((uint32_t *)(__bitmap))[(7)/32] &= ~(1<<((7)%32 ))); if (__noacl) (((uint32_t *)(__bitmap))[(12)/32] &= ~ (1<<((12)%32))); if (__nomode) (((uint32_t *)(__bitmap) )[(33)/32] &= ~(1<<((33)%32))); __bmp = __bitmap; } do { int __i; do { do { if ((((error)))) break; if (((((& nmreq))))->nmc_left < (4)) { ((((error)))) = nfsm_chain_new_mbuf (((((&nmreq)))), (4)); if (!((((error)))) && (((( (&nmreq))))->nmc_left < (4))) ((((error)))) = 12; } } while (0); if (((error))) break; *((uint32_t*)(((&nmreq )))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((2))) ? ( (__uint32_t)((((__uint32_t)((uint32_t)((2))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((2))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((2))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((2))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((2))))); (((&nmreq )))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4; } while (0); for (__i=0; __i < (2); __i++) do { do { if ((((error )))) break; if (((((&nmreq))))->nmc_left < (4)) { ( (((error)))) = nfsm_chain_new_mbuf(((((&nmreq)))), (4)); if (!((((error)))) && (((((&nmreq))))->nmc_left < (4))) ((((error)))) = 12; } } while (0); if (((error))) break ; *((uint32_t*)(((&nmreq)))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(((__bmp)[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr )[__i]))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(((__bmp)[ __i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i]))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((__bmp )[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i]))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((__bmp) [__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i]))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((__bmp) [__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i]))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((__bmp )[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i]))))); ( ((&nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4; } while (0); } while (0); } while (0); | |||
| 461 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 462 | nfsm_assert(error, (numops == 0), EPROTO)do { if (error) break; if (!((numops == 0))) (error) = (100); } while (0); | |||
| 463 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 464 | error = nfs_request2(np, NULL((void *)0), &nmreq, NFSPROC4_COMPOUND1, | |||
| 465 | vfs_context_thread(ctx), vfs_context_ucred(ctx), | |||
| 466 | NULL((void *)0), R_SOFT0x00010000, &nmrep, &xid, &status); | |||
| 467 | nfsm_chain_skip_tag(error, &nmrep)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (((&nmrep))->nmc_left >= (uint32_t)((((__val)+3)&(~0x3)))) { ((&nmrep)) ->nmc_left -= ((((__val)+3)&(~0x3))); ((&nmrep))-> nmc_ptr += ((((__val)+3)&(~0x3))); } else { ((error)) = nfsm_chain_advance (((&nmrep)), ((((__val)+3)&(~0x3)))); } } while (0); } while (0); | |||
| 468 | nfsm_chain_get_32(error, &nmrep, numops)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (numops ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 469 | nfsm_chain_op_check(error, &nmrep, NFS_OP_PUTFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (22)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 470 | nfsm_chain_op_check(error, &nmrep, NFS_OP_GETATTR)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (9)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 471 | nfsm_assert(error, NFSTONMP(np), ENXIO)do { if (error) break; if (!(((vnode_mount(((np)->n_vnode) )) ? ((struct nfsmount *)vfs_fsprivate(vnode_mount(((np)-> n_vnode)))) : ((void *)0)))) (error) = (6); } while (0); | |||
| 472 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 473 | lck_mtx_lock(&nmp->nm_lock); | |||
| 474 | error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, NULL((void *)0), NULL((void *)0), NULL((void *)0)); | |||
| 475 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 476 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 477 | if ((lockerror = nfs_node_lock(np))) | |||
| 478 | error = lockerror; | |||
| 479 | if (!error) | |||
| 480 | nfs_loadattrcache(np, &nvattr, &xid, 0); | |||
| 481 | if (!lockerror) | |||
| 482 | nfs_node_unlock(np); | |||
| 483 | nfsm_assert(error, NFSTONMP(np), ENXIO)do { if (error) break; if (!(((vnode_mount(((np)->n_vnode) )) ? ((struct nfsmount *)vfs_fsprivate(vnode_mount(((np)-> n_vnode)))) : ((void *)0)))) (error) = (6); } while (0); | |||
| 484 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 485 | nmp->nm_fsattr.nfsa_bsize = NFS_FABLKSIZE512; | |||
| 486 | nfsmout: | |||
| 487 | NVATTR_CLEANUP(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); if ((&nvattr)->nva_acl) { kauth_acl_free((&nvattr)-> nva_acl); (&nvattr)->nva_acl = ((void *)0); } } while ( 0); | |||
| 488 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 489 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 490 | vnode_put(NFSTOV(np)((np)->n_vnode)); | |||
| 491 | return (error); | |||
| 492 | } | |||
| 493 | ||||
| 494 | ||||
| 495 | /* | |||
| 496 | * The NFS VFS_GETATTR function: "statfs"-type information is retrieved | |||
| 497 | * using the nf_update_statfs() function, and other attributes are cobbled | |||
| 498 | * together from whatever sources we can (getattr, fsinfo, pathconf). | |||
| 499 | */ | |||
| 500 | int | |||
| 501 | nfs_vfs_getattr(mount_t mp, struct vfs_attr *fsap, vfs_context_t ctx) | |||
| 502 | { | |||
| 503 | struct nfsmount *nmp; | |||
| 504 | uint32_t bsize; | |||
| 505 | int error = 0, nfsvers; | |||
| 506 | ||||
| 507 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 508 | if (nfs_mount_gone(nmp)) | |||
| 509 | return (ENXIO6); | |||
| 510 | nfsvers = nmp->nm_vers; | |||
| 511 | ||||
| 512 | if (VFSATTR_IS_ACTIVE(fsap, f_bsize)((fsap)->f_active & (1LL<< 4)) || | |||
| 513 | VFSATTR_IS_ACTIVE(fsap, f_iosize)((fsap)->f_active & (1LL<< 5)) || | |||
| 514 | VFSATTR_IS_ACTIVE(fsap, f_blocks)((fsap)->f_active & (1LL<< 6)) || | |||
| 515 | VFSATTR_IS_ACTIVE(fsap, f_bfree)((fsap)->f_active & (1LL<< 7)) || | |||
| 516 | VFSATTR_IS_ACTIVE(fsap, f_bavail)((fsap)->f_active & (1LL<< 8)) || | |||
| 517 | VFSATTR_IS_ACTIVE(fsap, f_bused)((fsap)->f_active & (1LL<< 9)) || | |||
| 518 | VFSATTR_IS_ACTIVE(fsap, f_files)((fsap)->f_active & (1LL<< 10)) || | |||
| 519 | VFSATTR_IS_ACTIVE(fsap, f_ffree)((fsap)->f_active & (1LL<< 11))) { | |||
| 520 | int statfsrate = nfs_statfs_rate_limit; | |||
| 521 | int refresh = 1; | |||
| 522 | ||||
| 523 | /* | |||
| 524 | * Are we rate-limiting statfs RPCs? | |||
| 525 | * (Treat values less than 1 or greater than 1,000,000 as no limit.) | |||
| 526 | */ | |||
| 527 | if ((statfsrate > 0) && (statfsrate < 1000000)) { | |||
| 528 | struct timeval now; | |||
| 529 | uint32_t stamp; | |||
| 530 | ||||
| 531 | microuptime(&now); | |||
| 532 | lck_mtx_lock(&nmp->nm_lock); | |||
| 533 | stamp = (now.tv_sec * statfsrate) + (now.tv_usec / (1000000/statfsrate)); | |||
| 534 | if (stamp != nmp->nm_fsattrstamp) { | |||
| 535 | refresh = 1; | |||
| 536 | nmp->nm_fsattrstamp = stamp; | |||
| 537 | } else { | |||
| 538 | refresh = 0; | |||
| 539 | } | |||
| 540 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 541 | } | |||
| 542 | ||||
| 543 | if (refresh && !nfs_use_cache(nmp)) | |||
| 544 | error = nmp->nm_funcs->nf_update_statfs(nmp, ctx); | |||
| 545 | if ((error == ESTALE70) || (error == ETIMEDOUT60)) | |||
| 546 | error = 0; | |||
| 547 | if (error) | |||
| 548 | return (error); | |||
| 549 | ||||
| 550 | lck_mtx_lock(&nmp->nm_lock); | |||
| 551 | VFSATTR_RETURN(fsap, f_iosize, nfs_iosize)do { (fsap)-> f_iosize = (nfs_iosize); ((fsap)->f_supported |= (1LL<< 5));} while(0); | |||
| 552 | VFSATTR_RETURN(fsap, f_bsize, nmp->nm_fsattr.nfsa_bsize)do { (fsap)-> f_bsize = (nmp->nm_fsattr.nfsa_bsize); (( fsap)->f_supported |= (1LL<< 4));} while(0); | |||
| 553 | bsize = nmp->nm_fsattr.nfsa_bsize; | |||
| 554 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_TOTAL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(44)/32] & (1<<((44)%32)))) | |||
| 555 | VFSATTR_RETURN(fsap, f_blocks, nmp->nm_fsattr.nfsa_space_total / bsize)do { (fsap)-> f_blocks = (nmp->nm_fsattr.nfsa_space_total / bsize); ((fsap)->f_supported |= (1LL<< 6));} while (0); | |||
| 556 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_FREE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(43)/32] & (1<<((43)%32)))) | |||
| 557 | VFSATTR_RETURN(fsap, f_bfree, nmp->nm_fsattr.nfsa_space_free / bsize)do { (fsap)-> f_bfree = (nmp->nm_fsattr.nfsa_space_free / bsize); ((fsap)->f_supported |= (1LL<< 7));} while (0); | |||
| 558 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_AVAIL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(42)/32] & (1<<((42)%32)))) | |||
| 559 | VFSATTR_RETURN(fsap, f_bavail, nmp->nm_fsattr.nfsa_space_avail / bsize)do { (fsap)-> f_bavail = (nmp->nm_fsattr.nfsa_space_avail / bsize); ((fsap)->f_supported |= (1LL<< 8));} while (0); | |||
| 560 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_TOTAL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(44)/32] & (1<<((44)%32))) && | |||
| 561 | NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_FREE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(43)/32] & (1<<((43)%32)))) | |||
| 562 | VFSATTR_RETURN(fsap, f_bused,do { (fsap)-> f_bused = ((nmp->nm_fsattr.nfsa_space_total / bsize) - (nmp->nm_fsattr.nfsa_space_free / bsize)); ((fsap )->f_supported |= (1LL<< 9));} while(0) | |||
| 563 | (nmp->nm_fsattr.nfsa_space_total / bsize) -do { (fsap)-> f_bused = ((nmp->nm_fsattr.nfsa_space_total / bsize) - (nmp->nm_fsattr.nfsa_space_free / bsize)); ((fsap )->f_supported |= (1LL<< 9));} while(0) | |||
| 564 | (nmp->nm_fsattr.nfsa_space_free / bsize))do { (fsap)-> f_bused = ((nmp->nm_fsattr.nfsa_space_total / bsize) - (nmp->nm_fsattr.nfsa_space_free / bsize)); ((fsap )->f_supported |= (1LL<< 9));} while(0); | |||
| 565 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_TOTAL)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(23)/32] & (1<<((23)%32)))) | |||
| 566 | VFSATTR_RETURN(fsap, f_files, nmp->nm_fsattr.nfsa_files_total)do { (fsap)-> f_files = (nmp->nm_fsattr.nfsa_files_total ); ((fsap)->f_supported |= (1LL<< 10));} while(0); | |||
| 567 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_FREE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(22)/32] & (1<<((22)%32)))) | |||
| 568 | VFSATTR_RETURN(fsap, f_ffree, nmp->nm_fsattr.nfsa_files_free)do { (fsap)-> f_ffree = (nmp->nm_fsattr.nfsa_files_free ); ((fsap)->f_supported |= (1LL<< 11));} while(0); | |||
| 569 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 570 | } | |||
| 571 | ||||
| 572 | if (VFSATTR_IS_ACTIVE(fsap, f_capabilities)((fsap)->f_active & (1LL<< 14))) { | |||
| 573 | u_int32_t caps, valid; | |||
| 574 | nfsnode_t np = nmp->nm_dnp; | |||
| 575 | ||||
| 576 | nfsm_assert(error, VFSTONFS(mp) && np, ENXIO)do { if (error) break; if (!(((mp) ? ((struct nfsmount *)vfs_fsprivate (mp)) : ((void *)0)) && np)) (error) = (6); } while ( 0); | |||
| 577 | if (error) | |||
| 578 | return (error); | |||
| 579 | lck_mtx_lock(&nmp->nm_lock); | |||
| 580 | ||||
| 581 | /* | |||
| 582 | * The capabilities[] array defines what this volume supports. | |||
| 583 | * | |||
| 584 | * The valid[] array defines which bits this code understands | |||
| 585 | * the meaning of (whether the volume has that capability or not). | |||
| 586 | * Any zero bits here means "I don't know what you're asking about" | |||
| 587 | * and the caller cannot tell whether that capability is | |||
| 588 | * present or not. | |||
| 589 | */ | |||
| 590 | caps = valid = 0; | |||
| 591 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SYMLINK_SUPPORT)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(6)/32] & ( 1<<((6)%32)))) { | |||
| 592 | valid |= VOL_CAP_FMT_SYMBOLICLINKS0x00000002; | |||
| 593 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_SYMLINK0x00000002) | |||
| 594 | caps |= VOL_CAP_FMT_SYMBOLICLINKS0x00000002; | |||
| 595 | } | |||
| 596 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_LINK_SUPPORT)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(5)/32] & ( 1<<((5)%32)))) { | |||
| 597 | valid |= VOL_CAP_FMT_HARDLINKS0x00000004; | |||
| 598 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_LINK0x00000001) | |||
| 599 | caps |= VOL_CAP_FMT_HARDLINKS0x00000004; | |||
| 600 | } | |||
| 601 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_CASE_INSENSITIVE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(16)/32] & (1<<((16)%32)))) { | |||
| 602 | valid |= VOL_CAP_FMT_CASE_SENSITIVE0x00000100; | |||
| 603 | if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_CASE_INSENSITIVE0x00000020)) | |||
| 604 | caps |= VOL_CAP_FMT_CASE_SENSITIVE0x00000100; | |||
| 605 | } | |||
| 606 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_CASE_PRESERVING)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(17)/32] & (1<<((17)%32)))) { | |||
| 607 | valid |= VOL_CAP_FMT_CASE_PRESERVING0x00000200; | |||
| 608 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_CASE_PRESERVING0x00000040) | |||
| 609 | caps |= VOL_CAP_FMT_CASE_PRESERVING0x00000200; | |||
| 610 | } | |||
| 611 | /* Note: VOL_CAP_FMT_2TB_FILESIZE is actually used to test for "large file support" */ | |||
| 612 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXFILESIZE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(27)/32] & (1<<((27)%32)))) { | |||
| 613 | /* Is server's max file size at least 4GB? */ | |||
| 614 | if (nmp->nm_fsattr.nfsa_maxfilesize >= 0x100000000ULL) | |||
| 615 | caps |= VOL_CAP_FMT_2TB_FILESIZE0x00000800; | |||
| 616 | } else if (nfsvers >= NFS_VER33) { | |||
| 617 | /* | |||
| 618 | * NFSv3 and up supports 64 bits of file size. | |||
| 619 | * So, we'll just assume maxfilesize >= 4GB | |||
| 620 | */ | |||
| 621 | caps |= VOL_CAP_FMT_2TB_FILESIZE0x00000800; | |||
| 622 | } | |||
| 623 | if (nfsvers >= NFS_VER44) { | |||
| 624 | caps |= VOL_CAP_FMT_HIDDEN_FILES0x00002000; | |||
| 625 | valid |= VOL_CAP_FMT_HIDDEN_FILES0x00002000; | |||
| 626 | // VOL_CAP_FMT_OPENDENYMODES | |||
| 627 | // caps |= VOL_CAP_FMT_OPENDENYMODES; | |||
| 628 | // valid |= VOL_CAP_FMT_OPENDENYMODES; | |||
| 629 | } | |||
| 630 | fsap->f_capabilities.capabilities[VOL_CAPABILITIES_FORMAT0] = | |||
| 631 | // VOL_CAP_FMT_PERSISTENTOBJECTIDS | | |||
| 632 | // VOL_CAP_FMT_SYMBOLICLINKS | | |||
| 633 | // VOL_CAP_FMT_HARDLINKS | | |||
| 634 | // VOL_CAP_FMT_JOURNAL | | |||
| 635 | // VOL_CAP_FMT_JOURNAL_ACTIVE | | |||
| 636 | // VOL_CAP_FMT_NO_ROOT_TIMES | | |||
| 637 | // VOL_CAP_FMT_SPARSE_FILES | | |||
| 638 | // VOL_CAP_FMT_ZERO_RUNS | | |||
| 639 | // VOL_CAP_FMT_CASE_SENSITIVE | | |||
| 640 | // VOL_CAP_FMT_CASE_PRESERVING | | |||
| 641 | // VOL_CAP_FMT_FAST_STATFS | | |||
| 642 | // VOL_CAP_FMT_2TB_FILESIZE | | |||
| 643 | // VOL_CAP_FMT_OPENDENYMODES | | |||
| 644 | // VOL_CAP_FMT_HIDDEN_FILES | | |||
| 645 | caps; | |||
| 646 | fsap->f_capabilities.valid[VOL_CAPABILITIES_FORMAT0] = | |||
| 647 | VOL_CAP_FMT_PERSISTENTOBJECTIDS0x00000001 | | |||
| 648 | // VOL_CAP_FMT_SYMBOLICLINKS | | |||
| 649 | // VOL_CAP_FMT_HARDLINKS | | |||
| 650 | // VOL_CAP_FMT_JOURNAL | | |||
| 651 | // VOL_CAP_FMT_JOURNAL_ACTIVE | | |||
| 652 | // VOL_CAP_FMT_NO_ROOT_TIMES | | |||
| 653 | // VOL_CAP_FMT_SPARSE_FILES | | |||
| 654 | // VOL_CAP_FMT_ZERO_RUNS | | |||
| 655 | // VOL_CAP_FMT_CASE_SENSITIVE | | |||
| 656 | // VOL_CAP_FMT_CASE_PRESERVING | | |||
| 657 | VOL_CAP_FMT_FAST_STATFS0x00000400 | | |||
| 658 | VOL_CAP_FMT_2TB_FILESIZE0x00000800 | | |||
| 659 | // VOL_CAP_FMT_OPENDENYMODES | | |||
| 660 | // VOL_CAP_FMT_HIDDEN_FILES | | |||
| 661 | valid; | |||
| 662 | ||||
| 663 | /* | |||
| 664 | * We don't support most of the interfaces. | |||
| 665 | * | |||
| 666 | * We MAY support locking, but we don't have any easy way of probing. | |||
| 667 | * We can tell if there's no lockd running or if locks have been | |||
| 668 | * disabled for a mount, so we can definitely answer NO in that case. | |||
| 669 | * Any attempt to send a request to lockd to test for locking support | |||
| 670 | * may cause the lazily-launched locking daemons to be started | |||
| 671 | * unnecessarily. So we avoid that. However, we do record if we ever | |||
| 672 | * successfully perform a lock operation on a mount point, so if it | |||
| 673 | * looks like lock ops have worked, we do report that we support them. | |||
| 674 | */ | |||
| 675 | caps = valid = 0; | |||
| 676 | if (nfsvers >= NFS_VER44) { | |||
| 677 | caps = VOL_CAP_INT_ADVLOCK0x00000100 | VOL_CAP_INT_FLOCK0x00000200; | |||
| 678 | valid = VOL_CAP_INT_ADVLOCK0x00000100 | VOL_CAP_INT_FLOCK0x00000200; | |||
| 679 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL0x00000008) | |||
| 680 | caps |= VOL_CAP_INT_EXTENDED_SECURITY0x00000400; | |||
| 681 | valid |= VOL_CAP_INT_EXTENDED_SECURITY0x00000400; | |||
| 682 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR0x00000400) | |||
| 683 | caps |= VOL_CAP_INT_EXTENDED_ATTR0x00004000; | |||
| 684 | valid |= VOL_CAP_INT_EXTENDED_ATTR0x00004000; | |||
| 685 | #if NAMEDSTREAMS1 | |||
| 686 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR0x00000400) | |||
| 687 | caps |= VOL_CAP_INT_NAMEDSTREAMS0x00002000; | |||
| 688 | valid |= VOL_CAP_INT_NAMEDSTREAMS0x00002000; | |||
| 689 | #endif | |||
| 690 | } else if (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED1) { | |||
| 691 | /* locks disabled on this mount, so they definitely won't work */ | |||
| 692 | valid = VOL_CAP_INT_ADVLOCK0x00000100 | VOL_CAP_INT_FLOCK0x00000200; | |||
| 693 | } else if (nmp->nm_state & NFSSTA_LOCKSWORK0x00008000) { | |||
| 694 | caps = VOL_CAP_INT_ADVLOCK0x00000100 | VOL_CAP_INT_FLOCK0x00000200; | |||
| 695 | valid = VOL_CAP_INT_ADVLOCK0x00000100 | VOL_CAP_INT_FLOCK0x00000200; | |||
| 696 | } | |||
| 697 | fsap->f_capabilities.capabilities[VOL_CAPABILITIES_INTERFACES1] = | |||
| 698 | // VOL_CAP_INT_SEARCHFS | | |||
| 699 | // VOL_CAP_INT_ATTRLIST | | |||
| 700 | // VOL_CAP_INT_NFSEXPORT | | |||
| 701 | // VOL_CAP_INT_READDIRATTR | | |||
| 702 | // VOL_CAP_INT_EXCHANGEDATA | | |||
| 703 | // VOL_CAP_INT_COPYFILE | | |||
| 704 | // VOL_CAP_INT_ALLOCATE | | |||
| 705 | // VOL_CAP_INT_VOL_RENAME | | |||
| 706 | // VOL_CAP_INT_ADVLOCK | | |||
| 707 | // VOL_CAP_INT_FLOCK | | |||
| 708 | // VOL_CAP_INT_EXTENDED_SECURITY | | |||
| 709 | // VOL_CAP_INT_USERACCESS | | |||
| 710 | // VOL_CAP_INT_MANLOCK | | |||
| 711 | // VOL_CAP_INT_NAMEDSTREAMS | | |||
| 712 | // VOL_CAP_INT_EXTENDED_ATTR | | |||
| 713 | VOL_CAP_INT_REMOTE_EVENT0x00008000 | | |||
| 714 | caps; | |||
| 715 | fsap->f_capabilities.valid[VOL_CAPABILITIES_INTERFACES1] = | |||
| 716 | VOL_CAP_INT_SEARCHFS0x00000001 | | |||
| 717 | VOL_CAP_INT_ATTRLIST0x00000002 | | |||
| 718 | VOL_CAP_INT_NFSEXPORT0x00000004 | | |||
| 719 | VOL_CAP_INT_READDIRATTR0x00000008 | | |||
| 720 | VOL_CAP_INT_EXCHANGEDATA0x00000010 | | |||
| 721 | VOL_CAP_INT_COPYFILE0x00000020 | | |||
| 722 | VOL_CAP_INT_ALLOCATE0x00000040 | | |||
| 723 | VOL_CAP_INT_VOL_RENAME0x00000080 | | |||
| 724 | // VOL_CAP_INT_ADVLOCK | | |||
| 725 | // VOL_CAP_INT_FLOCK | | |||
| 726 | // VOL_CAP_INT_EXTENDED_SECURITY | | |||
| 727 | // VOL_CAP_INT_USERACCESS | | |||
| 728 | // VOL_CAP_INT_MANLOCK | | |||
| 729 | // VOL_CAP_INT_NAMEDSTREAMS | | |||
| 730 | // VOL_CAP_INT_EXTENDED_ATTR | | |||
| 731 | VOL_CAP_INT_REMOTE_EVENT0x00008000 | | |||
| 732 | valid; | |||
| 733 | ||||
| 734 | fsap->f_capabilities.capabilities[VOL_CAPABILITIES_RESERVED12] = 0; | |||
| 735 | fsap->f_capabilities.valid[VOL_CAPABILITIES_RESERVED12] = 0; | |||
| 736 | ||||
| 737 | fsap->f_capabilities.capabilities[VOL_CAPABILITIES_RESERVED23] = 0; | |||
| 738 | fsap->f_capabilities.valid[VOL_CAPABILITIES_RESERVED23] = 0; | |||
| 739 | ||||
| 740 | VFSATTR_SET_SUPPORTED(fsap, f_capabilities)((fsap)->f_supported |= (1LL<< 14)); | |||
| 741 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 742 | } | |||
| 743 | ||||
| 744 | if (VFSATTR_IS_ACTIVE(fsap, f_attributes)((fsap)->f_active & (1LL<< 15))) { | |||
| 745 | fsap->f_attributes.validattr.commonattr = 0; | |||
| 746 | fsap->f_attributes.validattr.volattr = | |||
| 747 | ATTR_VOL_CAPABILITIES0x00020000 | ATTR_VOL_ATTRIBUTES0x40000000; | |||
| 748 | fsap->f_attributes.validattr.dirattr = 0; | |||
| 749 | fsap->f_attributes.validattr.fileattr = 0; | |||
| 750 | fsap->f_attributes.validattr.forkattr = 0; | |||
| 751 | ||||
| 752 | fsap->f_attributes.nativeattr.commonattr = 0; | |||
| 753 | fsap->f_attributes.nativeattr.volattr = | |||
| 754 | ATTR_VOL_CAPABILITIES0x00020000 | ATTR_VOL_ATTRIBUTES0x40000000; | |||
| 755 | fsap->f_attributes.nativeattr.dirattr = 0; | |||
| 756 | fsap->f_attributes.nativeattr.fileattr = 0; | |||
| 757 | fsap->f_attributes.nativeattr.forkattr = 0; | |||
| 758 | ||||
| 759 | VFSATTR_SET_SUPPORTED(fsap, f_attributes)((fsap)->f_supported |= (1LL<< 15)); | |||
| 760 | } | |||
| 761 | ||||
| 762 | return (error); | |||
| 763 | } | |||
| 764 | ||||
| 765 | /* | |||
| 766 | * nfs version 3 fsinfo rpc call | |||
| 767 | */ | |||
| 768 | int | |||
| 769 | nfs3_fsinfo(struct nfsmount *nmp, nfsnode_t np, vfs_context_t ctx) | |||
| 770 | { | |||
| 771 | int error = 0, lockerror, status, nmlocked = 0; | |||
| 772 | u_int64_t xid; | |||
| 773 | uint32_t val, prefsize, maxsize; | |||
| 774 | struct nfsm_chain nmreq, nmrep; | |||
| 775 | ||||
| 776 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 777 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 778 | ||||
| 779 | nfsm_chain_build_alloc_init(error, &nmreq, NFSX_FH(nmp->nm_vers))do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )(((((nmp->nm_vers) == 2) ? 32 : (4 + (((nmp->nm_vers) == 3) ? 64 : 128))))) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget (MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 780 | nfsm_chain_add_fh(error, &nmreq, nmp->nm_vers, np->n_fhp, np->n_fhsize)do { if (error) break; if ((nmp->nm_vers) != 2) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((np->n_fhsize))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((np->n_fhsize))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((np ->n_fhsize))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((np->n_fhsize))))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((np->n_fhsize))+3)&(~0x3)); if ((error)) break ; if (((&nmreq))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f (((&nmreq)), (const u_char*)((np->n_fhp)), ((np->n_fhsize ))); break; } *(((uint32_t*)(((&nmreq))->nmc_ptr))+((( ((((np->n_fhsize)))+3)&(~0x3))>>2)-1)) = 0; bcopy (((np->n_fhp)), ((&nmreq))->nmc_ptr, ((np->n_fhsize ))); ((&nmreq))->nmc_ptr += rndlen; ((&nmreq))-> nmc_left -= rndlen; } while (0); } while (0); | |||
| 781 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 782 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 783 | error = nfs_request(np, NULL((void *)0), &nmreq, NFSPROC_FSINFO19, ctx, NULL((void *)0), &nmrep, &xid, &status); | |||
| 784 | if ((lockerror = nfs_node_lock(np))) | |||
| 785 | error = lockerror; | |||
| 786 | nfsm_chain_postop_attr_update(error, &nmrep, np, &xid)do { int __dummy_flag = 0; do { struct nfs_vattr ttvattr; do { ((__dummy_flag)) = 0; if ((((error))) || !(((&nmrep)))-> nmc_mhead) break; do { uint32_t __tmp32, *__tmpptr; if ((((error )))) break; if (((((&nmrep))))->nmc_left >= 4) { __tmpptr = (uint32_t*)((((&nmrep))))->nmc_ptr; ((((&nmrep) )))->nmc_left -= 4; ((((&nmrep))))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((((error)))) = nfsm_chain_get_opaque_f (((((&nmrep)))), 4, (u_char*)__tmpptr); if ((((error)))) break ; } (((__dummy_flag))) = ((uint32_t)(__builtin_constant_p((uint32_t )(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); if ((((error))) || !( (__dummy_flag))) break; if (((((error))) = nfs_parsefattr(((( &nmrep))), 3, (&ttvattr)))) ((__dummy_flag)) = 0; } while (0); if (((error)) || !(__dummy_flag)) break; if ((((error)) = nfs_loadattrcache(((np)), &ttvattr, ((&xid)), 1))) { (__dummy_flag) = 0; break; } if (*((&xid)) == 0) (__dummy_flag ) = 0; } while (0); } while (0); | |||
| 787 | if (!lockerror) | |||
| 788 | nfs_node_unlock(np); | |||
| 789 | if (!error) | |||
| 790 | error = status; | |||
| 791 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 792 | ||||
| 793 | lck_mtx_lock(&nmp->nm_lock); | |||
| 794 | nmlocked = 1; | |||
| 795 | ||||
| 796 | nfsm_chain_get_32(error, &nmrep, maxsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (maxsize ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 797 | nfsm_chain_get_32(error, &nmrep, prefsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (prefsize ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 798 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 799 | nmp->nm_fsattr.nfsa_maxread = maxsize; | |||
| 800 | if (prefsize < nmp->nm_rsize) | |||
| 801 | nmp->nm_rsize = (prefsize + NFS_FABLKSIZE512 - 1) & | |||
| 802 | ~(NFS_FABLKSIZE512 - 1); | |||
| 803 | if ((maxsize > 0) && (maxsize < nmp->nm_rsize)) { | |||
| 804 | nmp->nm_rsize = maxsize & ~(NFS_FABLKSIZE512 - 1); | |||
| 805 | if (nmp->nm_rsize == 0) | |||
| 806 | nmp->nm_rsize = maxsize; | |||
| 807 | } | |||
| 808 | nfsm_chain_adv(error, &nmrep, NFSX_UNSIGNED)do { if (error) break; if ((&nmrep)->nmc_left >= (uint32_t )(4)) { (&nmrep)->nmc_left -= (4); (&nmrep)->nmc_ptr += (4); } else { (error) = nfsm_chain_advance((&nmrep), ( 4)); } } while (0); // skip rtmult | |||
| 809 | ||||
| 810 | nfsm_chain_get_32(error, &nmrep, maxsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (maxsize ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 811 | nfsm_chain_get_32(error, &nmrep, prefsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (prefsize ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 812 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 813 | nmp->nm_fsattr.nfsa_maxwrite = maxsize; | |||
| 814 | if (prefsize < nmp->nm_wsize) | |||
| 815 | nmp->nm_wsize = (prefsize + NFS_FABLKSIZE512 - 1) & | |||
| 816 | ~(NFS_FABLKSIZE512 - 1); | |||
| 817 | if ((maxsize > 0) && (maxsize < nmp->nm_wsize)) { | |||
| 818 | nmp->nm_wsize = maxsize & ~(NFS_FABLKSIZE512 - 1); | |||
| 819 | if (nmp->nm_wsize == 0) | |||
| 820 | nmp->nm_wsize = maxsize; | |||
| 821 | } | |||
| 822 | nfsm_chain_adv(error, &nmrep, NFSX_UNSIGNED)do { if (error) break; if ((&nmrep)->nmc_left >= (uint32_t )(4)) { (&nmrep)->nmc_left -= (4); (&nmrep)->nmc_ptr += (4); } else { (error) = nfsm_chain_advance((&nmrep), ( 4)); } } while (0); // skip wtmult | |||
| 823 | ||||
| 824 | nfsm_chain_get_32(error, &nmrep, prefsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (prefsize ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 825 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 826 | if ((prefsize > 0) && (prefsize < nmp->nm_readdirsize)) | |||
| 827 | nmp->nm_readdirsize = prefsize; | |||
| 828 | if ((nmp->nm_fsattr.nfsa_maxread > 0) && | |||
| 829 | (nmp->nm_fsattr.nfsa_maxread < nmp->nm_readdirsize)) | |||
| 830 | nmp->nm_readdirsize = nmp->nm_fsattr.nfsa_maxread; | |||
| 831 | ||||
| 832 | nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_maxfilesize)do { uint64_t __tmp64, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 2 * 4) { __tmpptr = (uint64_t*)(& nmrep)->nmc_ptr; (&nmrep)->nmc_left -= 2 * 4; (& nmrep)->nmc_ptr += 2 * 4; } else { __tmpptr = &__tmp64 ; (error) = nfsm_chain_get_opaque_f((&nmrep), 2 * 4, (u_char *)__tmpptr); if (error) break; } { ((uint32_t *)(&(nmp-> nm_fsattr.nfsa_maxfilesize)))[1] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[0]) ? ((__uint32_t)((((__uint32_t)(((uint32_t * )(__tmpptr))[0]) & 0xff000000) >> 24) | (((__uint32_t )(((uint32_t *)(__tmpptr))[0]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x0000ff00 ) << 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[0]) & 0x000000ff) << 24))) : _OSSwapInt32(((uint32_t *)(__tmpptr ))[0])); ((uint32_t *)(&(nmp->nm_fsattr.nfsa_maxfilesize )))[0] = (__builtin_constant_p(((uint32_t *)(__tmpptr))[1]) ? ((__uint32_t)((((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0xff000000) >> 24) | (((__uint32_t)(((uint32_t *)(__tmpptr ))[1]) & 0x00ff0000) >> 8) | (((__uint32_t)(((uint32_t *)(__tmpptr))[1]) & 0x0000ff00) << 8) | (((__uint32_t )(((uint32_t *)(__tmpptr))[1]) & 0x000000ff) << 24) )) : _OSSwapInt32(((uint32_t *)(__tmpptr))[1])); }; } while ( 0); | |||
| 833 | ||||
| 834 | nfsm_chain_adv(error, &nmrep, 2 * NFSX_UNSIGNED)do { if (error) break; if ((&nmrep)->nmc_left >= (uint32_t )(2 * 4)) { (&nmrep)->nmc_left -= (2 * 4); (&nmrep )->nmc_ptr += (2 * 4); } else { (error) = nfsm_chain_advance ((&nmrep), (2 * 4)); } } while (0); // skip time_delta | |||
| 835 | ||||
| 836 | /* convert FS properties to our own flags */ | |||
| 837 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 838 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 839 | if (val & NFSV3FSINFO_LINK0x01) | |||
| 840 | nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_LINK0x00000001; | |||
| 841 | if (val & NFSV3FSINFO_SYMLINK0x02) | |||
| 842 | nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_SYMLINK0x00000002; | |||
| 843 | if (val & NFSV3FSINFO_HOMOGENEOUS0x08) | |||
| 844 | nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_HOMOGENEOUS0x00000100; | |||
| 845 | if (val & NFSV3FSINFO_CANSETTIME0x10) | |||
| 846 | nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_SET_TIME0x00000010; | |||
| 847 | nmp->nm_state |= NFSSTA_GOTFSINFO0x00100000; | |||
| 848 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXREAD)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(30)/32] |= 1<< ((30)%32)); | |||
| 849 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXWRITE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(31)/32] |= 1<< ((31)%32)); | |||
| 850 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXFILESIZE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(27)/32] |= 1<< ((27)%32)); | |||
| 851 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_LINK_SUPPORT)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(5)/32] |= 1<< ((5)%32)); | |||
| 852 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SYMLINK_SUPPORT)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(6)/32] |= 1<< ((6)%32)); | |||
| 853 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_HOMOGENEOUS)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(26)/32] |= 1<< ((26)%32)); | |||
| 854 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_CANSETTIME)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(15)/32] |= 1<< ((15)%32)); | |||
| 855 | nfsmout: | |||
| 856 | if (nmlocked) | |||
| 857 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 858 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 859 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 860 | return (error); | |||
| 861 | } | |||
| 862 | ||||
| 863 | /* | |||
| 864 | * Mount a remote root fs via. nfs. This depends on the info in the | |||
| 865 | * nfs_diskless structure that has been filled in properly by some primary | |||
| 866 | * bootstrap. | |||
| 867 | * It goes something like this: | |||
| 868 | * - do enough of "ifconfig" by calling ifioctl() so that the system | |||
| 869 | * can talk to the server | |||
| 870 | * - If nfs_diskless.mygateway is filled in, use that address as | |||
| 871 | * a default gateway. | |||
| 872 | * - hand craft the swap nfs vnode hanging off a fake mount point | |||
| 873 | * if swdevt[0].sw_dev == NODEV | |||
| 874 | * - build the rootfs mount point and call mountnfs() to do the rest. | |||
| 875 | */ | |||
| 876 | int | |||
| 877 | nfs_mountroot(void) | |||
| 878 | { | |||
| 879 | struct nfs_diskless nd; | |||
| 880 | mount_t mp = NULL((void *)0); | |||
| 881 | vnode_t vp = NULL((void *)0); | |||
| 882 | vfs_context_t ctx; | |||
| 883 | int error; | |||
| 884 | #if !defined(NO_MOUNT_PRIVATE) | |||
| 885 | mount_t mppriv = NULL((void *)0); | |||
| 886 | vnode_t vppriv = NULL((void *)0); | |||
| 887 | #endif /* NO_MOUNT_PRIVATE */ | |||
| 888 | int v3, sotype; | |||
| 889 | ||||
| 890 | /* | |||
| 891 | * Call nfs_boot_init() to fill in the nfs_diskless struct. | |||
| 892 | * Note: networking must already have been configured before | |||
| 893 | * we're called. | |||
| 894 | */ | |||
| 895 | bzero((caddr_t) &nd, sizeof(nd)); | |||
| 896 | error = nfs_boot_init(&nd); | |||
| 897 | if (error) | |||
| 898 | panic("nfs_boot_init: unable to initialize NFS root system information, "(panic)("\"nfs_boot_init: unable to initialize NFS root system information, \" \"error %d, check configuration: %s\\n\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "899", error, PE_boot_args()) | |||
| 899 | "error %d, check configuration: %s\n", error, PE_boot_args())(panic)("\"nfs_boot_init: unable to initialize NFS root system information, \" \"error %d, check configuration: %s\\n\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "899", error, PE_boot_args()); | |||
| 900 | ||||
| 901 | /* | |||
| 902 | * Try NFSv3 first, then fallback to NFSv2. | |||
| 903 | * Likewise, try TCP first, then fall back to UDP. | |||
| 904 | */ | |||
| 905 | v3 = 1; | |||
| 906 | sotype = SOCK_STREAM1; | |||
| 907 | ||||
| 908 | tryagain: | |||
| 909 | error = nfs_boot_getfh(&nd, v3, sotype); | |||
| 910 | if (error) { | |||
| 911 | if (error == EHOSTDOWN64 || error == EHOSTUNREACH65) { | |||
| 912 | if (nd.nd_root.ndm_mntfrom) | |||
| 913 | FREE_ZONE(nd.nd_root.ndm_mntfrom,_FREE_ZONE((void *)nd.nd_root.ndm_mntfrom, 1024, 12) | |||
| 914 | MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_root.ndm_mntfrom, 1024, 12); | |||
| 915 | if (nd.nd_root.ndm_path) | |||
| 916 | FREE_ZONE(nd.nd_root.ndm_path,_FREE_ZONE((void *)nd.nd_root.ndm_path, 1024, 12) | |||
| 917 | MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_root.ndm_path, 1024, 12); | |||
| 918 | if (nd.nd_private.ndm_mntfrom) | |||
| 919 | FREE_ZONE(nd.nd_private.ndm_mntfrom,_FREE_ZONE((void *)nd.nd_private.ndm_mntfrom, 1024, 12) | |||
| 920 | MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_private.ndm_mntfrom, 1024, 12); | |||
| 921 | if (nd.nd_private.ndm_path) | |||
| 922 | FREE_ZONE(nd.nd_private.ndm_path,_FREE_ZONE((void *)nd.nd_private.ndm_path, 1024, 12) | |||
| 923 | MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_private.ndm_path, 1024, 12); | |||
| 924 | return (error); | |||
| 925 | } | |||
| 926 | if (v3) { | |||
| 927 | if (sotype == SOCK_STREAM1) { | |||
| 928 | printf("NFS mount (v3,TCP) failed with error %d, trying UDP...\n", error); | |||
| 929 | sotype = SOCK_DGRAM2; | |||
| 930 | goto tryagain; | |||
| 931 | } | |||
| 932 | printf("NFS mount (v3,UDP) failed with error %d, trying v2...\n", error); | |||
| 933 | v3 = 0; | |||
| 934 | sotype = SOCK_STREAM1; | |||
| 935 | goto tryagain; | |||
| 936 | } else if (sotype == SOCK_STREAM1) { | |||
| 937 | printf("NFS mount (v2,TCP) failed with error %d, trying UDP...\n", error); | |||
| 938 | sotype = SOCK_DGRAM2; | |||
| 939 | goto tryagain; | |||
| 940 | } else { | |||
| 941 | printf("NFS mount (v2,UDP) failed with error %d, giving up...\n", error); | |||
| 942 | } | |||
| 943 | switch(error) { | |||
| 944 | case EPROGUNAVAIL74: | |||
| 945 | panic("NFS mount failed: NFS server mountd not responding, check server configuration: %s", PE_boot_args())(panic)("\"NFS mount failed: NFS server mountd not responding, check server configuration: %s\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "945", PE_boot_args()); | |||
| 946 | case EACCES13: | |||
| 947 | case EPERM1: | |||
| 948 | panic("NFS mount failed: NFS server refused mount, check server configuration: %s", PE_boot_args())(panic)("\"NFS mount failed: NFS server refused mount, check server configuration: %s\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "948", PE_boot_args()); | |||
| 949 | default: | |||
| 950 | panic("NFS mount failed with error %d, check configuration: %s", error, PE_boot_args())(panic)("\"NFS mount failed with error %d, check configuration: %s\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "950", error, PE_boot_args()); | |||
| 951 | } | |||
| 952 | } | |||
| 953 | ||||
| 954 | ctx = vfs_context_kernel(); | |||
| 955 | ||||
| 956 | /* | |||
| 957 | * Create the root mount point. | |||
| 958 | */ | |||
| 959 | #if !defined(NO_MOUNT_PRIVATE) | |||
| 960 | { | |||
| 961 | //PWC hack until we have a real "mount" tool to remount root rw | |||
| 962 | int rw_root=0; | |||
| 963 | int flags = MNT_ROOTFS0x00004000|MNT_RDONLY0x00000001; | |||
| 964 | PE_parse_boot_argn("-rwroot_hack", &rw_root, sizeof (rw_root)); | |||
| 965 | if(rw_root) | |||
| 966 | { | |||
| 967 | flags = MNT_ROOTFS0x00004000; | |||
| 968 | kprintf("-rwroot_hack in effect: mounting root fs read/write\n"); | |||
| 969 | } | |||
| 970 | ||||
| 971 | if ((error = nfs_mount_diskless(&nd.nd_root, "/", flags, &vp, &mp, ctx))) | |||
| 972 | #else | |||
| 973 | if ((error = nfs_mount_diskless(&nd.nd_root, "/", MNT_ROOTFS0x00004000, &vp, &mp, ctx))) | |||
| 974 | #endif /* NO_MOUNT_PRIVATE */ | |||
| 975 | { | |||
| 976 | if (v3) { | |||
| 977 | if (sotype == SOCK_STREAM1) { | |||
| 978 | printf("NFS root mount (v3,TCP) failed with %d, trying UDP...\n", error); | |||
| 979 | sotype = SOCK_DGRAM2; | |||
| 980 | goto tryagain; | |||
| 981 | } | |||
| 982 | printf("NFS root mount (v3,UDP) failed with %d, trying v2...\n", error); | |||
| 983 | v3 = 0; | |||
| 984 | sotype = SOCK_STREAM1; | |||
| 985 | goto tryagain; | |||
| 986 | } else if (sotype == SOCK_STREAM1) { | |||
| 987 | printf("NFS root mount (v2,TCP) failed with %d, trying UDP...\n", error); | |||
| 988 | sotype = SOCK_DGRAM2; | |||
| 989 | goto tryagain; | |||
| 990 | } else { | |||
| 991 | printf("NFS root mount (v2,UDP) failed with error %d, giving up...\n", error); | |||
| 992 | } | |||
| 993 | panic("NFS root mount failed with error %d, check configuration: %s\n", error, PE_boot_args())(panic)("\"NFS root mount failed with error %d, check configuration: %s\\n\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "993", error, PE_boot_args()); | |||
| 994 | } | |||
| 995 | } | |||
| 996 | printf("root on %s\n", nd.nd_root.ndm_mntfrom); | |||
| 997 | ||||
| 998 | vfs_unbusy(mp); | |||
| 999 | mount_list_add(mp); | |||
| 1000 | rootvp = vp; | |||
| 1001 | ||||
| 1002 | #if !defined(NO_MOUNT_PRIVATE) | |||
| 1003 | if (nd.nd_private.ndm_saddr.sin_addr.s_addr) { | |||
| 1004 | error = nfs_mount_diskless_private(&nd.nd_private, "/private", | |||
| 1005 | 0, &vppriv, &mppriv, ctx); | |||
| 1006 | if (error) | |||
| 1007 | panic("NFS /private mount failed with error %d, check configuration: %s\n", error, PE_boot_args())(panic)("\"NFS /private mount failed with error %d, check configuration: %s\\n\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "1007", error, PE_boot_args()); | |||
| 1008 | printf("private on %s\n", nd.nd_private.ndm_mntfrom); | |||
| 1009 | ||||
| 1010 | vfs_unbusy(mppriv); | |||
| 1011 | mount_list_add(mppriv); | |||
| 1012 | } | |||
| 1013 | ||||
| 1014 | #endif /* NO_MOUNT_PRIVATE */ | |||
| 1015 | ||||
| 1016 | if (nd.nd_root.ndm_mntfrom) | |||
| 1017 | FREE_ZONE(nd.nd_root.ndm_mntfrom, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_root.ndm_mntfrom, 1024, 12); | |||
| 1018 | if (nd.nd_root.ndm_path) | |||
| 1019 | FREE_ZONE(nd.nd_root.ndm_path, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_root.ndm_path, 1024, 12); | |||
| 1020 | if (nd.nd_private.ndm_mntfrom) | |||
| 1021 | FREE_ZONE(nd.nd_private.ndm_mntfrom, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_private.ndm_mntfrom, 1024, 12); | |||
| 1022 | if (nd.nd_private.ndm_path) | |||
| 1023 | FREE_ZONE(nd.nd_private.ndm_path, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)nd.nd_private.ndm_path, 1024, 12); | |||
| 1024 | ||||
| 1025 | /* Get root attributes (for the time). */ | |||
| 1026 | error = nfs_getattr(VTONFS(vp)((nfsnode_t)vnode_fsnode(vp)), NULL((void *)0), ctx, NGA_UNCACHED0x0002); | |||
| 1027 | if (error) | |||
| 1028 | panic("NFS mount: failed to get attributes for root directory, error %d, check server", error)(panic)("\"NFS mount: failed to get attributes for root directory, error %d, check server\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "1028", error); | |||
| 1029 | return (0); | |||
| 1030 | } | |||
| 1031 | ||||
| 1032 | /* | |||
| 1033 | * Internal version of mount system call for diskless setup. | |||
| 1034 | */ | |||
| 1035 | static int | |||
| 1036 | nfs_mount_diskless( | |||
| 1037 | struct nfs_dlmount *ndmntp, | |||
| 1038 | const char *mntname, | |||
| 1039 | int mntflag, | |||
| 1040 | vnode_t *vpp, | |||
| 1041 | mount_t *mpp, | |||
| 1042 | vfs_context_t ctx) | |||
| 1043 | { | |||
| 1044 | mount_t mp; | |||
| 1045 | int error, numcomps; | |||
| 1046 | char *xdrbuf, *p, *cp, *frompath, *endserverp; | |||
| 1047 | char uaddr[MAX_IPv4_STR_LEN16]; | |||
| 1048 | struct xdrbuf xb; | |||
| 1049 | uint32_t mattrs[NFS_MATTR_BITMAP_LEN1]; | |||
| 1050 | uint32_t mflags_mask[NFS_MFLAG_BITMAP_LEN1]; | |||
| 1051 | uint32_t mflags[NFS_MFLAG_BITMAP_LEN1]; | |||
| 1052 | uint32_t argslength_offset, attrslength_offset, end_offset; | |||
| 1053 | ||||
| 1054 | if ((error = vfs_rootmountalloc("nfs", ndmntp->ndm_mntfrom, &mp))) { | |||
| 1055 | printf("nfs_mount_diskless: NFS not configured\n"); | |||
| 1056 | return (error); | |||
| 1057 | } | |||
| 1058 | ||||
| 1059 | mp->mnt_flag |= mntflag; | |||
| 1060 | if (!(mntflag & MNT_RDONLY0x00000001)) | |||
| 1061 | mp->mnt_flag &= ~MNT_RDONLY0x00000001; | |||
| 1062 | ||||
| 1063 | /* find the server-side path being mounted */ | |||
| 1064 | frompath = ndmntp->ndm_mntfrom; | |||
| 1065 | if (*frompath == '[') { /* skip IPv6 literal address */ | |||
| 1066 | while (*frompath && (*frompath != ']')) | |||
| 1067 | frompath++; | |||
| 1068 | if (*frompath == ']') | |||
| 1069 | frompath++; | |||
| 1070 | } | |||
| 1071 | while (*frompath && (*frompath != ':')) | |||
| 1072 | frompath++; | |||
| 1073 | endserverp = frompath; | |||
| 1074 | while (*frompath && (*frompath == ':')) | |||
| 1075 | frompath++; | |||
| 1076 | /* count fs location path components */ | |||
| 1077 | p = frompath; | |||
| 1078 | while (*p && (*p == '/')) | |||
| 1079 | p++; | |||
| 1080 | numcomps = 0; | |||
| 1081 | while (*p) { | |||
| 1082 | numcomps++; | |||
| 1083 | while (*p && (*p != '/')) | |||
| 1084 | p++; | |||
| 1085 | while (*p && (*p == '/')) | |||
| 1086 | p++; | |||
| 1087 | } | |||
| 1088 | ||||
| 1089 | /* convert address to universal address string */ | |||
| 1090 | if (inet_ntop(AF_INET2, &ndmntp->ndm_saddr.sin_addr, uaddr, sizeof(uaddr)) != uaddr) { | |||
| 1091 | printf("nfs_mount_diskless: bad address\n"); | |||
| 1092 | return (EINVAL22); | |||
| 1093 | } | |||
| 1094 | ||||
| 1095 | /* prepare mount attributes */ | |||
| 1096 | NFS_BITMAP_ZERO(mattrs, NFS_MATTR_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mattrs ))[__i] = 0; } while (0); | |||
| 1097 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] |= 1<<((1)%32)); | |||
| 1098 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] |= 1<<((14)%32)); | |||
| 1099 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] |= 1<<((15)%32)); | |||
| 1100 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] |= 1<<((20)%32)); | |||
| 1101 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] |= 1<<((21)%32)); | |||
| 1102 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] |= 1<<((22)%32)); | |||
| 1103 | ||||
| 1104 | /* prepare mount flags */ | |||
| 1105 | NFS_BITMAP_ZERO(mflags_mask, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags_mask ))[__i] = 0; } while (0); | |||
| 1106 | NFS_BITMAP_ZERO(mflags, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags ))[__i] = 0; } while (0); | |||
| 1107 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags_mask))[(2)/32] |= 1<<((2)%32)); | |||
| 1108 | NFS_BITMAP_SET(mflags, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags))[(2)/32] |= 1<<((2)%32)); | |||
| 1109 | ||||
| 1110 | /* build xdr buffer */ | |||
| 1111 | xb_init_buffer(&xb, NULL((void *)0), 0); | |||
| 1112 | xb_add_32(error, &xb, NFS_ARGSVERSION_XDR)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(88)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(88 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (88)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(88)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(88)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(88)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1113 | argslength_offset = xb_offset(&xb); | |||
| 1114 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); // args length | |||
| 1115 | xb_add_32(error, &xb, NFS_XDRARGS_VERSION_0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1116 | xb_add_bitmap(error, &xb, mattrs, NFS_MATTR_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xb))), (void*)&__tmp, 4, 0); } while (0); for (__i =0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp; if ( ((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(( (mattrs))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t)((( mattrs))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((mattrs))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((mattrs ))[__i])))); (((error))) = xb_add_bytes((((&xb))), (void* )&__tmp, 4, 0); } while (0); } while (0); | |||
| 1117 | attrslength_offset = xb_offset(&xb); | |||
| 1118 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); // attrs length | |||
| 1119 | xb_add_32(error, &xb, ndmntp->ndm_nfsv3 ? 3 : 2)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) ? ((__uint32_t)((( (__uint32_t)((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0x0000ff00) << 8 ) | (((__uint32_t)((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(ndmntp-> ndm_nfsv3 ? 3 : 2)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); // NFS version | |||
| 1120 | xb_add_string(error, &xb, ((ndmntp->ndm_sotype == SOCK_DGRAM) ? "udp" : "tcp"), 3)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((3))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(( 3))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((3))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((3))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((3))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((3))))); ((error)) = xb_add_bytes(((&xb)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xb), (const char*)(((ndmntp->ndm_sotype == 2) ? "udp" : "tcp")), (3), 0); } while (0); | |||
| 1121 | xb_add_32(error, &xb, ntohs(ndmntp->ndm_saddr.sin_port))do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr .sin_port) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp-> ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (ndmntp->ndm_saddr.sin_port))))) ? ((__uint32_t)((((__uint32_t )((uint32_t)(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr .sin_port) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp-> ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (ndmntp->ndm_saddr.sin_port))))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((__uint16_t)(__builtin_constant_p (ndmntp->ndm_saddr.sin_port) ? ((__uint16_t)((((__uint16_t )(ndmntp->ndm_saddr.sin_port) & 0xff00) >> 8) | ( ((__uint16_t)(ndmntp->ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16(ndmntp->ndm_saddr.sin_port))))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((__uint16_t )(__builtin_constant_p(ndmntp->ndm_saddr.sin_port) ? ((__uint16_t )((((__uint16_t)(ndmntp->ndm_saddr.sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp->ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16(ndmntp->ndm_saddr.sin_port ))))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr.sin_port ) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr.sin_port ) & 0xff00) >> 8) | (((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0x00ff) << 8))) : _OSSwapInt16(ndmntp-> ndm_saddr.sin_port))))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr .sin_port) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp-> ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (ndmntp->ndm_saddr.sin_port))))))); (error) = xb_add_bytes ((&xb), (void*)&__tmp, 4, 0); } while (0); // NFS port | |||
| 1122 | xb_add_fh(error, &xb, &ndmntp->ndm_fh[0], ndmntp->ndm_fhlen)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((ndmntp->ndm_fhlen))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((ndmntp->ndm_fhlen))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((ndmntp->ndm_fhlen))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((ndmntp-> ndm_fhlen))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((ndmntp->ndm_fhlen))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((ndmntp->ndm_fhlen))))); ( (error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0) ; } while (0); if (error) break; (error) = xb_add_bytes((& xb), (char*)(&ndmntp->ndm_fh[0]), (ndmntp->ndm_fhlen ), 0); } while (0); | |||
| 1123 | /* fs location */ | |||
| 1124 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* fs location count */ | |||
| 1125 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* server count */ | |||
| 1126 | xb_add_string(error, &xb, ndmntp->ndm_mntfrom, (endserverp - ndmntp->ndm_mntfrom))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((endserverp - ndmntp->ndm_mntfrom)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((endserverp - ndmntp->ndm_mntfrom )))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(((endserverp - ndmntp->ndm_mntfrom)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((endserverp - ndmntp ->ndm_mntfrom)))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(((endserverp - ndmntp->ndm_mntfrom)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((endserverp - ndmntp ->ndm_mntfrom)))))); ((error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error ) = xb_add_bytes((&xb), (const char*)(ndmntp->ndm_mntfrom ), ((endserverp - ndmntp->ndm_mntfrom)), 0); } while (0); /* server name */ | |||
| 1127 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* address count */ | |||
| 1128 | xb_add_string(error, &xb, uaddr, strlen(uaddr))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(uaddr)))) ? ((__uint32_t)((((__uint32_t)( (uint32_t)((strlen(uaddr)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(uaddr)))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((strlen(uaddr)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( uaddr)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((strlen(uaddr)))))); ((error)) = xb_add_bytes(((&xb)), ( void*)&__tmp, 4, 0); } while (0); if (error) break; (error ) = xb_add_bytes((&xb), (const char*)(uaddr), (strlen(uaddr )), 0); } while (0); /* address */ | |||
| 1129 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* empty server info */ | |||
| 1130 | xb_add_32(error, &xb, numcomps)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(numcomps)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(numcomps)) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)(numcomps)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(numcomps)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(numcomps)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(numcomps)))); (error) = xb_add_bytes((&xb), ( void*)&__tmp, 4, 0); } while (0); /* pathname component count */ | |||
| 1131 | p = frompath; | |||
| 1132 | while (*p && (*p == '/')) | |||
| 1133 | p++; | |||
| 1134 | while (*p) { | |||
| 1135 | cp = p; | |||
| 1136 | while (*p && (*p != '/')) | |||
| 1137 | p++; | |||
| 1138 | xb_add_string(error, &xb, cp, (p - cp))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((p - cp)))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((p - cp)))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((p - cp)))) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(((p - cp)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((p - cp)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((p - cp)))))); (( error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((& xb), (const char*)(cp), ((p - cp)), 0); } while (0); /* component */ | |||
| 1139 | if (error) | |||
| 1140 | break; | |||
| 1141 | while (*p && (*p == '/')) | |||
| 1142 | p++; | |||
| 1143 | } | |||
| 1144 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* empty fsl info */ | |||
| 1145 | xb_add_32(error, &xb, mntflag)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(mntflag)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(mntflag)) & 0xff000000) >> 24) | (((__uint32_t)(( uint32_t)(mntflag)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(mntflag)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(mntflag)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(mntflag)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); /* MNT flags */ | |||
| 1146 | xb_build_done(error, &xb)do { if (error) break; xb_set_cur_buf_len(&xb); } while ( 0); | |||
| 1147 | ||||
| 1148 | /* update opaque counts */ | |||
| 1149 | end_offset = xb_offset(&xb); | |||
| 1150 | if (!error) { | |||
| 1151 | error = xb_seek(&xb, argslength_offset); | |||
| 1152 | xb_add_32(error, &xb, end_offset - argslength_offset + XDRWORD/*version*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - argslength_offset + 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - argslength_offset + 4 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (end_offset - argslength_offset + 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - argslength_offset + 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - argslength_offset + 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - argslength_offset + 4)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1153 | } | |||
| 1154 | if (!error) { | |||
| 1155 | error = xb_seek(&xb, attrslength_offset); | |||
| 1156 | xb_add_32(error, &xb, end_offset - attrslength_offset - XDRWORD/*don't include length field*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - attrslength_offset - 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - attrslength_offset - 4)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1157 | } | |||
| 1158 | if (error) { | |||
| 1159 | printf("nfs_mount_diskless: error %d assembling mount args\n", error); | |||
| 1160 | xb_cleanup(&xb); | |||
| 1161 | return (error); | |||
| 1162 | } | |||
| 1163 | /* grab the assembled buffer */ | |||
| 1164 | xdrbuf = xb_buffer_base(&xb); | |||
| 1165 | xb.xb_flags &= ~XB_CLEANUP0x0001; | |||
| 1166 | ||||
| 1167 | /* do the mount */ | |||
| 1168 | if ((error = mountnfs(xdrbuf, mp, ctx, vpp))) { | |||
| 1169 | printf("nfs_mountroot: mount %s failed: %d\n", mntname, error); | |||
| 1170 | // XXX vfs_rootmountfailed(mp); | |||
| 1171 | mount_list_lock(); | |||
| 1172 | mp->mnt_vtable->vfc_refcount--; | |||
| 1173 | mount_list_unlock(); | |||
| 1174 | vfs_unbusy(mp); | |||
| 1175 | mount_lock_destroy(mp); | |||
| 1176 | #if CONFIG_MACF1 | |||
| 1177 | mac_mount_label_destroy(mp); | |||
| 1178 | #endif | |||
| 1179 | FREE_ZONE(mp, sizeof(struct mount), M_MOUNT)_FREE_ZONE((void *)mp, sizeof(struct mount), 20); | |||
| 1180 | } else { | |||
| 1181 | *mpp = mp; | |||
| 1182 | } | |||
| 1183 | xb_cleanup(&xb); | |||
| 1184 | return (error); | |||
| 1185 | } | |||
| 1186 | ||||
| 1187 | #if !defined(NO_MOUNT_PRIVATE) | |||
| 1188 | /* | |||
| 1189 | * Internal version of mount system call to mount "/private" | |||
| 1190 | * separately in diskless setup | |||
| 1191 | */ | |||
| 1192 | static int | |||
| 1193 | nfs_mount_diskless_private( | |||
| 1194 | struct nfs_dlmount *ndmntp, | |||
| 1195 | const char *mntname, | |||
| 1196 | int mntflag, | |||
| 1197 | vnode_t *vpp, | |||
| 1198 | mount_t *mpp, | |||
| 1199 | vfs_context_t ctx) | |||
| 1200 | { | |||
| 1201 | mount_t mp; | |||
| 1202 | int error, numcomps; | |||
| 1203 | proc_t procp; | |||
| 1204 | struct vfstable *vfsp; | |||
| 1205 | struct nameidata nd; | |||
| 1206 | vnode_t vp; | |||
| 1207 | char *xdrbuf = NULL((void *)0), *p, *cp, *frompath, *endserverp; | |||
| 1208 | char uaddr[MAX_IPv4_STR_LEN16]; | |||
| 1209 | struct xdrbuf xb; | |||
| 1210 | uint32_t mattrs[NFS_MATTR_BITMAP_LEN1]; | |||
| 1211 | uint32_t mflags_mask[NFS_MFLAG_BITMAP_LEN1], mflags[NFS_MFLAG_BITMAP_LEN1]; | |||
| 1212 | uint32_t argslength_offset, attrslength_offset, end_offset; | |||
| 1213 | ||||
| 1214 | procp = current_proc(); /* XXX */ | |||
| 1215 | xb_init(&xb, 0); | |||
| 1216 | ||||
| 1217 | { | |||
| 1218 | /* | |||
| 1219 | * mimic main()!. Temporarily set up rootvnode and other stuff so | |||
| 1220 | * that namei works. Need to undo this because main() does it, too | |||
| 1221 | */ | |||
| 1222 | struct filedesc *fdp; /* pointer to file descriptor state */ | |||
| 1223 | fdp = procp->p_fd; | |||
| 1224 | mountlist.tqh_first->mnt_flag |= MNT_ROOTFS0x00004000; | |||
| 1225 | ||||
| 1226 | /* Get the vnode for '/'. Set fdp->fd_cdir to reference it. */ | |||
| 1227 | if (VFS_ROOT(mountlist.tqh_first, &rootvnode, NULL((void *)0))) | |||
| 1228 | panic("cannot find root vnode")(panic)("\"cannot find root vnode\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "1228"); | |||
| 1229 | error = vnode_ref(rootvnode); | |||
| 1230 | if (error) { | |||
| 1231 | printf("nfs_mountroot: vnode_ref() failed on root vnode!\n"); | |||
| 1232 | goto out; | |||
| 1233 | } | |||
| 1234 | fdp->fd_cdir = rootvnode; | |||
| 1235 | fdp->fd_rdir = NULL((void *)0); | |||
| 1236 | } | |||
| 1237 | ||||
| 1238 | /* | |||
| 1239 | * Get vnode to be covered | |||
| 1240 | */ | |||
| 1241 | NDINIT(&nd, LOOKUP, OP_LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,{ (&nd)->ni_cnd.cn_nameiop = 0; (&nd)->ni_op = OP_LOOKUP ; (&nd)->ni_cnd.cn_flags = 0x00000040 | 0x0004; if ((UIO_SYSSPACE ) == UIO_USERSPACE) { (&nd)->ni_segflg = ((IS_64BIT_PROCESS (vfs_context_proc(ctx))) ? UIO_USERSPACE64 : UIO_USERSPACE32) ; } else { (&nd)->ni_segflg = UIO_SYSSPACE; } (&nd )->ni_dirp = ((user_addr_t)((uintptr_t)(mntname))); (& nd)->ni_cnd.cn_context = ctx; (&nd)->ni_flag = 0; ( &nd)->ni_cnd.cn_ndp = (&nd); } | |||
| 1242 | CAST_USER_ADDR_T(mntname), ctx){ (&nd)->ni_cnd.cn_nameiop = 0; (&nd)->ni_op = OP_LOOKUP ; (&nd)->ni_cnd.cn_flags = 0x00000040 | 0x0004; if ((UIO_SYSSPACE ) == UIO_USERSPACE) { (&nd)->ni_segflg = ((IS_64BIT_PROCESS (vfs_context_proc(ctx))) ? UIO_USERSPACE64 : UIO_USERSPACE32) ; } else { (&nd)->ni_segflg = UIO_SYSSPACE; } (&nd )->ni_dirp = ((user_addr_t)((uintptr_t)(mntname))); (& nd)->ni_cnd.cn_context = ctx; (&nd)->ni_flag = 0; ( &nd)->ni_cnd.cn_ndp = (&nd); }; | |||
| 1243 | if ((error = namei(&nd))) { | |||
| 1244 | printf("nfs_mountroot: private namei failed!\n"); | |||
| 1245 | goto out; | |||
| 1246 | } | |||
| 1247 | { | |||
| 1248 | /* undo vnode_ref() in mimic main()! */ | |||
| 1249 | vnode_rele(rootvnode); | |||
| 1250 | } | |||
| 1251 | nameidone(&nd); | |||
| 1252 | vp = nd.ni_vp; | |||
| 1253 | ||||
| 1254 | if ((error = VNOP_FSYNC(vp, MNT_WAIT1, ctx)) || | |||
| 1255 | (error = buf_invalidateblks(vp, BUF_WRITE_DATA0x0001, 0, 0))) { | |||
| 1256 | vnode_put(vp); | |||
| 1257 | goto out; | |||
| 1258 | } | |||
| 1259 | if (vnode_vtype(vp) != VDIR) { | |||
| 1260 | vnode_put(vp); | |||
| 1261 | error = ENOTDIR20; | |||
| 1262 | goto out; | |||
| 1263 | } | |||
| 1264 | for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) | |||
| 1265 | if (!strncmp(vfsp->vfc_name, "nfs", sizeof(vfsp->vfc_name))) | |||
| 1266 | break; | |||
| 1267 | if (vfsp == NULL((void *)0)) { | |||
| 1268 | printf("nfs_mountroot: private NFS not configured\n"); | |||
| 1269 | vnode_put(vp); | |||
| 1270 | error = ENODEV19; | |||
| 1271 | goto out; | |||
| 1272 | } | |||
| 1273 | if (vnode_mountedhere(vp) != NULL((void *)0)) { | |||
| 1274 | vnode_put(vp); | |||
| 1275 | error = EBUSY16; | |||
| 1276 | goto out; | |||
| 1277 | } | |||
| 1278 | ||||
| 1279 | /* | |||
| 1280 | * Allocate and initialize the filesystem. | |||
| 1281 | */ | |||
| 1282 | mp = _MALLOC_ZONE((u_int32_t)sizeof(struct mount), M_MOUNT, M_WAITOK)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); __MALLOC_ZONE((u_int32_t)sizeof(struct mount), 20, 0x0000 , &site); }); | |||
| 1283 | if (!mp) { | |||
| 1284 | printf("nfs_mountroot: unable to allocate mount structure\n"); | |||
| 1285 | vnode_put(vp); | |||
| 1286 | error = ENOMEM12; | |||
| 1287 | goto out; | |||
| 1288 | } | |||
| 1289 | bzero((char *)mp, sizeof(struct mount)); | |||
| 1290 | ||||
| 1291 | /* Initialize the default IO constraints */ | |||
| 1292 | mp->mnt_maxreadcnt = mp->mnt_maxwritecnt = MAXPHYS(128 * 1024); | |||
| 1293 | mp->mnt_segreadcnt = mp->mnt_segwritecnt = 32; | |||
| 1294 | mp->mnt_ioflags = 0; | |||
| 1295 | mp->mnt_realrootvp = NULLVP((struct vnode *)((void *)0)); | |||
| 1296 | mp->mnt_authcache_ttl = CACHED_LOOKUP_RIGHT_TTL2; | |||
| 1297 | ||||
| 1298 | mount_lock_init(mp); | |||
| 1299 | TAILQ_INIT(&mp->mnt_vnodelist)do { (((&mp->mnt_vnodelist))->tqh_first) = ((void * )0); (&mp->mnt_vnodelist)->tqh_last = &(((& mp->mnt_vnodelist))->tqh_first); ; } while (0); | |||
| 1300 | TAILQ_INIT(&mp->mnt_workerqueue)do { (((&mp->mnt_workerqueue))->tqh_first) = ((void *)0); (&mp->mnt_workerqueue)->tqh_last = &(((& mp->mnt_workerqueue))->tqh_first); ; } while (0); | |||
| 1301 | TAILQ_INIT(&mp->mnt_newvnodes)do { (((&mp->mnt_newvnodes))->tqh_first) = ((void * )0); (&mp->mnt_newvnodes)->tqh_last = &(((& mp->mnt_newvnodes))->tqh_first); ; } while (0); | |||
| 1302 | (void)vfs_busy(mp, LK_NOWAIT1); | |||
| 1303 | TAILQ_INIT(&mp->mnt_vnodelist)do { (((&mp->mnt_vnodelist))->tqh_first) = ((void * )0); (&mp->mnt_vnodelist)->tqh_last = &(((& mp->mnt_vnodelist))->tqh_first); ; } while (0); | |||
| 1304 | mount_list_lock(); | |||
| 1305 | vfsp->vfc_refcount++; | |||
| 1306 | mount_list_unlock(); | |||
| 1307 | mp->mnt_vtable = vfsp; | |||
| 1308 | mp->mnt_op = vfsp->vfc_vfsops; | |||
| 1309 | // mp->mnt_stat.f_type = vfsp->vfc_typenum; | |||
| 1310 | mp->mnt_flag = mntflag; | |||
| 1311 | mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK(0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080); | |||
| 1312 | strncpy(mp->mnt_vfsstat.f_fstypename, vfsp->vfc_name, MFSNAMELEN15-1); | |||
| 1313 | vp->v_mountedherev_un.vu_mountedhere = mp; | |||
| 1314 | mp->mnt_vnodecovered = vp; | |||
| 1315 | vp = NULLVP((struct vnode *)((void *)0)); | |||
| 1316 | mp->mnt_vfsstat.f_owner = kauth_cred_getuid(kauth_cred_get()); | |||
| 1317 | (void) copystr(mntname, mp->mnt_vfsstat.f_mntonname, MAXPATHLEN1024 - 1, 0); | |||
| 1318 | (void) copystr(ndmntp->ndm_mntfrom, mp->mnt_vfsstat.f_mntfromname, MAXPATHLEN1024 - 1, 0); | |||
| 1319 | #if CONFIG_MACF1 | |||
| 1320 | mac_mount_label_init(mp); | |||
| 1321 | mac_mount_label_associate(ctx, mp); | |||
| 1322 | #endif | |||
| 1323 | ||||
| 1324 | /* find the server-side path being mounted */ | |||
| 1325 | frompath = ndmntp->ndm_mntfrom; | |||
| 1326 | if (*frompath == '[') { /* skip IPv6 literal address */ | |||
| 1327 | while (*frompath && (*frompath != ']')) | |||
| 1328 | frompath++; | |||
| 1329 | if (*frompath == ']') | |||
| 1330 | frompath++; | |||
| 1331 | } | |||
| 1332 | while (*frompath && (*frompath != ':')) | |||
| 1333 | frompath++; | |||
| 1334 | endserverp = frompath; | |||
| 1335 | while (*frompath && (*frompath == ':')) | |||
| 1336 | frompath++; | |||
| 1337 | /* count fs location path components */ | |||
| 1338 | p = frompath; | |||
| 1339 | while (*p && (*p == '/')) | |||
| 1340 | p++; | |||
| 1341 | numcomps = 0; | |||
| 1342 | while (*p) { | |||
| 1343 | numcomps++; | |||
| 1344 | while (*p && (*p != '/')) | |||
| 1345 | p++; | |||
| 1346 | while (*p && (*p == '/')) | |||
| 1347 | p++; | |||
| 1348 | } | |||
| 1349 | ||||
| 1350 | /* convert address to universal address string */ | |||
| 1351 | if (inet_ntop(AF_INET2, &ndmntp->ndm_saddr.sin_addr, uaddr, sizeof(uaddr)) != uaddr) { | |||
| 1352 | printf("nfs_mountroot: bad address\n"); | |||
| 1353 | error = EINVAL22; | |||
| 1354 | goto out; | |||
| 1355 | } | |||
| 1356 | ||||
| 1357 | /* prepare mount attributes */ | |||
| 1358 | NFS_BITMAP_ZERO(mattrs, NFS_MATTR_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mattrs ))[__i] = 0; } while (0); | |||
| 1359 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] |= 1<<((1)%32)); | |||
| 1360 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] |= 1<<((14)%32)); | |||
| 1361 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] |= 1<<((15)%32)); | |||
| 1362 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] |= 1<<((20)%32)); | |||
| 1363 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] |= 1<<((21)%32)); | |||
| 1364 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] |= 1<<((22)%32)); | |||
| 1365 | ||||
| 1366 | /* prepare mount flags */ | |||
| 1367 | NFS_BITMAP_ZERO(mflags_mask, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags_mask ))[__i] = 0; } while (0); | |||
| 1368 | NFS_BITMAP_ZERO(mflags, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags ))[__i] = 0; } while (0); | |||
| 1369 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags_mask))[(2)/32] |= 1<<((2)%32)); | |||
| 1370 | NFS_BITMAP_SET(mflags, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags))[(2)/32] |= 1<<((2)%32)); | |||
| 1371 | ||||
| 1372 | /* build xdr buffer */ | |||
| 1373 | xb_init_buffer(&xb, NULL((void *)0), 0); | |||
| 1374 | xb_add_32(error, &xb, NFS_ARGSVERSION_XDR)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(88)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(88 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (88)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(88)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(88)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(88)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1375 | argslength_offset = xb_offset(&xb); | |||
| 1376 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); // args length | |||
| 1377 | xb_add_32(error, &xb, NFS_XDRARGS_VERSION_0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1378 | xb_add_bitmap(error, &xb, mattrs, NFS_MATTR_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xb))), (void*)&__tmp, 4, 0); } while (0); for (__i =0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp; if ( ((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(( (mattrs))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t)((( mattrs))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((mattrs))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((mattrs ))[__i])))); (((error))) = xb_add_bytes((((&xb))), (void* )&__tmp, 4, 0); } while (0); } while (0); | |||
| 1379 | attrslength_offset = xb_offset(&xb); | |||
| 1380 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); // attrs length | |||
| 1381 | xb_add_32(error, &xb, ndmntp->ndm_nfsv3 ? 3 : 2)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) ? ((__uint32_t)((( (__uint32_t)((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0x0000ff00) << 8 ) | (((__uint32_t)((uint32_t)(ndmntp->ndm_nfsv3 ? 3 : 2)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(ndmntp-> ndm_nfsv3 ? 3 : 2)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); // NFS version | |||
| 1382 | xb_add_string(error, &xb, ((ndmntp->ndm_sotype == SOCK_DGRAM) ? "udp" : "tcp"), 3)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((3))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(( 3))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((3))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((3))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((3))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((3))))); ((error)) = xb_add_bytes(((&xb)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xb), (const char*)(((ndmntp->ndm_sotype == 2) ? "udp" : "tcp")), (3), 0); } while (0); | |||
| 1383 | xb_add_32(error, &xb, ntohs(ndmntp->ndm_saddr.sin_port))do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr .sin_port) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp-> ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (ndmntp->ndm_saddr.sin_port))))) ? ((__uint32_t)((((__uint32_t )((uint32_t)(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr .sin_port) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp-> ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (ndmntp->ndm_saddr.sin_port))))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((__uint16_t)(__builtin_constant_p (ndmntp->ndm_saddr.sin_port) ? ((__uint16_t)((((__uint16_t )(ndmntp->ndm_saddr.sin_port) & 0xff00) >> 8) | ( ((__uint16_t)(ndmntp->ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16(ndmntp->ndm_saddr.sin_port))))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((__uint16_t )(__builtin_constant_p(ndmntp->ndm_saddr.sin_port) ? ((__uint16_t )((((__uint16_t)(ndmntp->ndm_saddr.sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp->ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16(ndmntp->ndm_saddr.sin_port ))))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr.sin_port ) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr.sin_port ) & 0xff00) >> 8) | (((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0x00ff) << 8))) : _OSSwapInt16(ndmntp-> ndm_saddr.sin_port))))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((__uint16_t)(__builtin_constant_p(ndmntp->ndm_saddr .sin_port) ? ((__uint16_t)((((__uint16_t)(ndmntp->ndm_saddr .sin_port) & 0xff00) >> 8) | (((__uint16_t)(ndmntp-> ndm_saddr.sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (ndmntp->ndm_saddr.sin_port))))))); (error) = xb_add_bytes ((&xb), (void*)&__tmp, 4, 0); } while (0); // NFS port | |||
| 1384 | xb_add_fh(error, &xb, &ndmntp->ndm_fh[0], ndmntp->ndm_fhlen)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((ndmntp->ndm_fhlen))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((ndmntp->ndm_fhlen))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((ndmntp->ndm_fhlen))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((ndmntp-> ndm_fhlen))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((ndmntp->ndm_fhlen))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((ndmntp->ndm_fhlen))))); ( (error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0) ; } while (0); if (error) break; (error) = xb_add_bytes((& xb), (char*)(&ndmntp->ndm_fh[0]), (ndmntp->ndm_fhlen ), 0); } while (0); | |||
| 1385 | /* fs location */ | |||
| 1386 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* fs location count */ | |||
| 1387 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* server count */ | |||
| 1388 | xb_add_string(error, &xb, ndmntp->ndm_mntfrom, (endserverp - ndmntp->ndm_mntfrom))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((endserverp - ndmntp->ndm_mntfrom)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((endserverp - ndmntp->ndm_mntfrom )))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(((endserverp - ndmntp->ndm_mntfrom)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((endserverp - ndmntp ->ndm_mntfrom)))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(((endserverp - ndmntp->ndm_mntfrom)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((endserverp - ndmntp ->ndm_mntfrom)))))); ((error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error ) = xb_add_bytes((&xb), (const char*)(ndmntp->ndm_mntfrom ), ((endserverp - ndmntp->ndm_mntfrom)), 0); } while (0); /* server name */ | |||
| 1389 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* address count */ | |||
| 1390 | xb_add_string(error, &xb, uaddr, strlen(uaddr))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(uaddr)))) ? ((__uint32_t)((((__uint32_t)( (uint32_t)((strlen(uaddr)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(uaddr)))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((strlen(uaddr)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( uaddr)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((strlen(uaddr)))))); ((error)) = xb_add_bytes(((&xb)), ( void*)&__tmp, 4, 0); } while (0); if (error) break; (error ) = xb_add_bytes((&xb), (const char*)(uaddr), (strlen(uaddr )), 0); } while (0); /* address */ | |||
| 1391 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* empty server info */ | |||
| 1392 | xb_add_32(error, &xb, numcomps)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(numcomps)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(numcomps)) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)(numcomps)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(numcomps)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(numcomps)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(numcomps)))); (error) = xb_add_bytes((&xb), ( void*)&__tmp, 4, 0); } while (0); /* pathname component count */ | |||
| 1393 | p = frompath; | |||
| 1394 | while (*p && (*p == '/')) | |||
| 1395 | p++; | |||
| 1396 | while (*p) { | |||
| 1397 | cp = p; | |||
| 1398 | while (*p && (*p != '/')) | |||
| 1399 | p++; | |||
| 1400 | xb_add_string(error, &xb, cp, (p - cp))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((p - cp)))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((p - cp)))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((p - cp)))) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(((p - cp)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((p - cp)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((p - cp)))))); (( error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((& xb), (const char*)(cp), ((p - cp)), 0); } while (0); /* component */ | |||
| 1401 | if (error) | |||
| 1402 | break; | |||
| 1403 | while (*p && (*p == '/')) | |||
| 1404 | p++; | |||
| 1405 | } | |||
| 1406 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* empty fsl info */ | |||
| 1407 | xb_add_32(error, &xb, mntflag)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(mntflag)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(mntflag)) & 0xff000000) >> 24) | (((__uint32_t)(( uint32_t)(mntflag)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(mntflag)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(mntflag)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(mntflag)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); /* MNT flags */ | |||
| 1408 | xb_build_done(error, &xb)do { if (error) break; xb_set_cur_buf_len(&xb); } while ( 0); | |||
| 1409 | ||||
| 1410 | /* update opaque counts */ | |||
| 1411 | end_offset = xb_offset(&xb); | |||
| 1412 | if (!error) { | |||
| 1413 | error = xb_seek(&xb, argslength_offset); | |||
| 1414 | xb_add_32(error, &xb, end_offset - argslength_offset + XDRWORD/*version*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - argslength_offset + 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - argslength_offset + 4 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (end_offset - argslength_offset + 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - argslength_offset + 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - argslength_offset + 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - argslength_offset + 4)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1415 | } | |||
| 1416 | if (!error) { | |||
| 1417 | error = xb_seek(&xb, attrslength_offset); | |||
| 1418 | xb_add_32(error, &xb, end_offset - attrslength_offset - XDRWORD/*don't include length field*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - attrslength_offset - 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - attrslength_offset - 4)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1419 | } | |||
| 1420 | if (error) { | |||
| 1421 | printf("nfs_mountroot: error %d assembling mount args\n", error); | |||
| 1422 | goto out; | |||
| 1423 | } | |||
| 1424 | /* grab the assembled buffer */ | |||
| 1425 | xdrbuf = xb_buffer_base(&xb); | |||
| 1426 | xb.xb_flags &= ~XB_CLEANUP0x0001; | |||
| 1427 | ||||
| 1428 | /* do the mount */ | |||
| 1429 | if ((error = mountnfs(xdrbuf, mp, ctx, &vp))) { | |||
| 1430 | printf("nfs_mountroot: mount %s failed: %d\n", mntname, error); | |||
| 1431 | vnode_put(mp->mnt_vnodecovered); | |||
| 1432 | mount_list_lock(); | |||
| 1433 | vfsp->vfc_refcount--; | |||
| 1434 | mount_list_unlock(); | |||
| 1435 | vfs_unbusy(mp); | |||
| 1436 | mount_lock_destroy(mp); | |||
| 1437 | #if CONFIG_MACF1 | |||
| 1438 | mac_mount_label_destroy(mp); | |||
| 1439 | #endif | |||
| 1440 | FREE_ZONE(mp, sizeof (struct mount), M_MOUNT)_FREE_ZONE((void *)mp, sizeof (struct mount), 20); | |||
| 1441 | goto out; | |||
| 1442 | } | |||
| 1443 | ||||
| 1444 | *mpp = mp; | |||
| 1445 | *vpp = vp; | |||
| 1446 | out: | |||
| 1447 | xb_cleanup(&xb); | |||
| 1448 | return (error); | |||
| 1449 | } | |||
| 1450 | #endif /* NO_MOUNT_PRIVATE */ | |||
| 1451 | ||||
| 1452 | /* | |||
| 1453 | * Convert old style NFS mount args to XDR. | |||
| 1454 | */ | |||
| 1455 | static int | |||
| 1456 | nfs_convert_old_nfs_args(mount_t mp, user_addr_t data, vfs_context_t ctx, int argsversion, int inkernel, char **xdrbufp) | |||
| 1457 | { | |||
| 1458 | int error = 0, args64bit, argsize, numcomps; | |||
| 1459 | struct user_nfs_args args; | |||
| 1460 | struct nfs_args tempargs; | |||
| 1461 | caddr_t argsp; | |||
| 1462 | size_t len; | |||
| 1463 | u_char nfh[NFS4_FHSIZE128]; | |||
| 1464 | char *mntfrom, *endserverp, *frompath, *p, *cp; | |||
| 1465 | struct sockaddr_storage ss; | |||
| 1466 | void *sinaddr; | |||
| 1467 | char uaddr[MAX_IPv6_STR_LEN64]; | |||
| 1468 | uint32_t mattrs[NFS_MATTR_BITMAP_LEN1]; | |||
| 1469 | uint32_t mflags_mask[NFS_MFLAG_BITMAP_LEN1], mflags[NFS_MFLAG_BITMAP_LEN1]; | |||
| 1470 | uint32_t nfsvers, nfslockmode = 0, argslength_offset, attrslength_offset, end_offset; | |||
| 1471 | struct xdrbuf xb; | |||
| 1472 | ||||
| 1473 | *xdrbufp = NULL((void *)0); | |||
| 1474 | ||||
| 1475 | /* allocate a temporary buffer for mntfrom */ | |||
| 1476 | MALLOC_ZONE(mntfrom, char*, MAXPATHLEN, M_NAMEI, M_WAITOK)(mntfrom) = (char*)({ static vm_allocation_site_t site __attribute__ ((section("__DATA, __data"))); __MALLOC_ZONE(1024, 12, 0x0000 , &site); }); | |||
| 1477 | if (!mntfrom) | |||
| 1478 | return (ENOMEM12); | |||
| 1479 | ||||
| 1480 | args64bit = (inkernel || vfs_context_is64bit(ctx)); | |||
| 1481 | argsp = args64bit ? (void*)&args : (void*)&tempargs; | |||
| 1482 | ||||
| 1483 | argsize = args64bit ? sizeof(args) : sizeof(tempargs); | |||
| 1484 | switch (argsversion) { | |||
| 1485 | case 3: | |||
| 1486 | argsize -= NFS_ARGSVERSION4_INCSIZE(4 * sizeof(int)); | |||
| 1487 | case 4: | |||
| 1488 | argsize -= NFS_ARGSVERSION5_INCSIZE(sizeof(uint32_t)); | |||
| 1489 | case 5: | |||
| 1490 | argsize -= NFS_ARGSVERSION6_INCSIZE(sizeof(uint32_t)); | |||
| 1491 | case 6: | |||
| 1492 | break; | |||
| 1493 | default: | |||
| 1494 | error = EPROGMISMATCH75; | |||
| 1495 | goto nfsmout; | |||
| 1496 | } | |||
| 1497 | ||||
| 1498 | /* read in the structure */ | |||
| 1499 | if (inkernel) | |||
| 1500 | bcopy(CAST_DOWN(void *, data)( ((void *)((uintptr_t) (data)/(sizeof(void *) < sizeof(uintptr_t ) ? 0 : 1))) ), argsp, argsize); | |||
| 1501 | else | |||
| 1502 | error = copyin(data, argsp, argsize); | |||
| 1503 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1504 | ||||
| 1505 | if (!args64bit) { | |||
| 1506 | args.addrlen = tempargs.addrlen; | |||
| 1507 | args.sotype = tempargs.sotype; | |||
| 1508 | args.proto = tempargs.proto; | |||
| 1509 | args.fhsize = tempargs.fhsize; | |||
| 1510 | args.flags = tempargs.flags; | |||
| 1511 | args.wsize = tempargs.wsize; | |||
| 1512 | args.rsize = tempargs.rsize; | |||
| 1513 | args.readdirsize = tempargs.readdirsize; | |||
| 1514 | args.timeo = tempargs.timeo; | |||
| 1515 | args.retrans = tempargs.retrans; | |||
| 1516 | args.maxgrouplist = tempargs.maxgrouplist; | |||
| 1517 | args.readahead = tempargs.readahead; | |||
| 1518 | args.leaseterm = tempargs.leaseterm; | |||
| 1519 | args.deadthresh = tempargs.deadthresh; | |||
| 1520 | args.addr = CAST_USER_ADDR_T(tempargs.addr)((user_addr_t)((uintptr_t)(tempargs.addr))); | |||
| 1521 | args.fh = CAST_USER_ADDR_T(tempargs.fh)((user_addr_t)((uintptr_t)(tempargs.fh))); | |||
| 1522 | args.hostname = CAST_USER_ADDR_T(tempargs.hostname)((user_addr_t)((uintptr_t)(tempargs.hostname))); | |||
| 1523 | if (args.version >= 4) { | |||
| 1524 | args.acregmin = tempargs.acregmin; | |||
| 1525 | args.acregmax = tempargs.acregmax; | |||
| 1526 | args.acdirmin = tempargs.acdirmin; | |||
| 1527 | args.acdirmax = tempargs.acdirmax; | |||
| 1528 | } | |||
| 1529 | if (args.version >= 5) | |||
| 1530 | args.auth = tempargs.auth; | |||
| 1531 | if (args.version >= 6) | |||
| 1532 | args.deadtimeout = tempargs.deadtimeout; | |||
| 1533 | } | |||
| 1534 | ||||
| 1535 | if ((args.fhsize < 0) || (args.fhsize > NFS4_FHSIZE128)) { | |||
| 1536 | error = EINVAL22; | |||
| 1537 | goto nfsmout; | |||
| 1538 | } | |||
| 1539 | if (args.fhsize > 0) { | |||
| 1540 | if (inkernel) | |||
| 1541 | bcopy(CAST_DOWN(void *, args.fh)( ((void *)((uintptr_t) (args.fh)/(sizeof(void *) < sizeof (uintptr_t) ? 0 : 1))) ), (caddr_t)nfh, args.fhsize); | |||
| 1542 | else | |||
| 1543 | error = copyin(args.fh, (caddr_t)nfh, args.fhsize); | |||
| 1544 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1545 | } | |||
| 1546 | ||||
| 1547 | if (inkernel) | |||
| 1548 | error = copystr(CAST_DOWN(void *, args.hostname)( ((void *)((uintptr_t) (args.hostname)/(sizeof(void *) < sizeof (uintptr_t) ? 0 : 1))) ), mntfrom, MAXPATHLEN1024-1, &len); | |||
| 1549 | else | |||
| 1550 | error = copyinstr(args.hostname, mntfrom, MAXPATHLEN1024-1, &len); | |||
| 1551 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1552 | bzero(&mntfrom[len], MAXPATHLEN1024 - len); | |||
| 1553 | ||||
| 1554 | /* find the server-side path being mounted */ | |||
| 1555 | frompath = mntfrom; | |||
| 1556 | if (*frompath == '[') { /* skip IPv6 literal address */ | |||
| 1557 | while (*frompath && (*frompath != ']')) | |||
| 1558 | frompath++; | |||
| 1559 | if (*frompath == ']') | |||
| 1560 | frompath++; | |||
| 1561 | } | |||
| 1562 | while (*frompath && (*frompath != ':')) | |||
| 1563 | frompath++; | |||
| 1564 | endserverp = frompath; | |||
| 1565 | while (*frompath && (*frompath == ':')) | |||
| 1566 | frompath++; | |||
| 1567 | /* count fs location path components */ | |||
| 1568 | p = frompath; | |||
| 1569 | while (*p && (*p == '/')) | |||
| 1570 | p++; | |||
| 1571 | numcomps = 0; | |||
| 1572 | while (*p) { | |||
| 1573 | numcomps++; | |||
| 1574 | while (*p && (*p != '/')) | |||
| 1575 | p++; | |||
| 1576 | while (*p && (*p == '/')) | |||
| 1577 | p++; | |||
| 1578 | } | |||
| 1579 | ||||
| 1580 | /* copy socket address */ | |||
| 1581 | if (inkernel) | |||
| 1582 | bcopy(CAST_DOWN(void *, args.addr)( ((void *)((uintptr_t) (args.addr)/(sizeof(void *) < sizeof (uintptr_t) ? 0 : 1))) ), &ss, args.addrlen); | |||
| 1583 | else { | |||
| 1584 | if ((size_t)args.addrlen > sizeof (struct sockaddr_storage)) | |||
| 1585 | error = EINVAL22; | |||
| 1586 | else | |||
| 1587 | error = copyin(args.addr, &ss, args.addrlen); | |||
| 1588 | } | |||
| 1589 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1590 | ss.ss_len = args.addrlen; | |||
| 1591 | ||||
| 1592 | /* convert address to universal address string */ | |||
| 1593 | if (ss.ss_family == AF_INET2) | |||
| 1594 | sinaddr = &((struct sockaddr_in*)&ss)->sin_addr; | |||
| 1595 | else if (ss.ss_family == AF_INET630) | |||
| 1596 | sinaddr = &((struct sockaddr_in6*)&ss)->sin6_addr; | |||
| 1597 | else | |||
| 1598 | sinaddr = NULL((void *)0); | |||
| 1599 | if (!sinaddr || (inet_ntop(ss.ss_family, sinaddr, uaddr, sizeof(uaddr)) != uaddr)) { | |||
| 1600 | error = EINVAL22; | |||
| 1601 | goto nfsmout; | |||
| 1602 | } | |||
| 1603 | ||||
| 1604 | /* prepare mount flags */ | |||
| 1605 | NFS_BITMAP_ZERO(mflags_mask, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags_mask ))[__i] = 0; } while (0); | |||
| 1606 | NFS_BITMAP_ZERO(mflags, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags ))[__i] = 0; } while (0); | |||
| 1607 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_SOFT)(((uint32_t *)(mflags_mask))[(0)/32] |= 1<<((0)%32)); | |||
| 1608 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_INTR)(((uint32_t *)(mflags_mask))[(1)/32] |= 1<<((1)%32)); | |||
| 1609 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags_mask))[(2)/32] |= 1<<((2)%32)); | |||
| 1610 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NOCONNECT)(((uint32_t *)(mflags_mask))[(3)/32] |= 1<<((3)%32)); | |||
| 1611 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_DUMBTIMER)(((uint32_t *)(mflags_mask))[(4)/32] |= 1<<((4)%32)); | |||
| 1612 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_CALLUMNT)(((uint32_t *)(mflags_mask))[(5)/32] |= 1<<((5)%32)); | |||
| 1613 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_RDIRPLUS)(((uint32_t *)(mflags_mask))[(6)/32] |= 1<<((6)%32)); | |||
| 1614 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NONEGNAMECACHE)(((uint32_t *)(mflags_mask))[(7)/32] |= 1<<((7)%32)); | |||
| 1615 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_MUTEJUKEBOX)(((uint32_t *)(mflags_mask))[(8)/32] |= 1<<((8)%32)); | |||
| 1616 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NOQUOTA)(((uint32_t *)(mflags_mask))[(15)/32] |= 1<<((15)%32)); | |||
| 1617 | if (args.flags & NFSMNT_SOFT0x00000001) | |||
| 1618 | NFS_BITMAP_SET(mflags, NFS_MFLAG_SOFT)(((uint32_t *)(mflags))[(0)/32] |= 1<<((0)%32)); | |||
| 1619 | if (args.flags & NFSMNT_INT0x00000040) | |||
| 1620 | NFS_BITMAP_SET(mflags, NFS_MFLAG_INTR)(((uint32_t *)(mflags))[(1)/32] |= 1<<((1)%32)); | |||
| 1621 | if (args.flags & NFSMNT_RESVPORT0x00008000) | |||
| 1622 | NFS_BITMAP_SET(mflags, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags))[(2)/32] |= 1<<((2)%32)); | |||
| 1623 | if (args.flags & NFSMNT_NOCONN0x00000080) | |||
| 1624 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NOCONNECT)(((uint32_t *)(mflags))[(3)/32] |= 1<<((3)%32)); | |||
| 1625 | if (args.flags & NFSMNT_DUMBTIMR0x00000800) | |||
| 1626 | NFS_BITMAP_SET(mflags, NFS_MFLAG_DUMBTIMER)(((uint32_t *)(mflags))[(4)/32] |= 1<<((4)%32)); | |||
| 1627 | if (args.flags & NFSMNT_CALLUMNT0x00004000) | |||
| 1628 | NFS_BITMAP_SET(mflags, NFS_MFLAG_CALLUMNT)(((uint32_t *)(mflags))[(5)/32] |= 1<<((5)%32)); | |||
| 1629 | if (args.flags & NFSMNT_RDIRPLUS0x00010000) | |||
| 1630 | NFS_BITMAP_SET(mflags, NFS_MFLAG_RDIRPLUS)(((uint32_t *)(mflags))[(6)/32] |= 1<<((6)%32)); | |||
| 1631 | if (args.flags & NFSMNT_NONEGNAMECACHE0x00000100) | |||
| 1632 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NONEGNAMECACHE)(((uint32_t *)(mflags))[(7)/32] |= 1<<((7)%32)); | |||
| 1633 | if (args.flags & NFSMNT_MUTEJUKEBOX0x04000000) | |||
| 1634 | NFS_BITMAP_SET(mflags, NFS_MFLAG_MUTEJUKEBOX)(((uint32_t *)(mflags))[(8)/32] |= 1<<((8)%32)); | |||
| 1635 | if (args.flags & NFSMNT_NOQUOTA0x08000000) | |||
| 1636 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NOQUOTA)(((uint32_t *)(mflags))[(15)/32] |= 1<<((15)%32)); | |||
| 1637 | ||||
| 1638 | /* prepare mount attributes */ | |||
| 1639 | NFS_BITMAP_ZERO(mattrs, NFS_MATTR_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mattrs ))[__i] = 0; } while (0); | |||
| 1640 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FLAGS)(((uint32_t *)(mattrs))[(0)/32] |= 1<<((0)%32)); | |||
| 1641 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] |= 1<<((1)%32)); | |||
| 1642 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] |= 1<<((14)%32)); | |||
| 1643 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] |= 1<<((15)%32)); | |||
| 1644 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] |= 1<<((20)%32)); | |||
| 1645 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] |= 1<<((21)%32)); | |||
| 1646 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] |= 1<<((22)%32)); | |||
| 1647 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MNTFROM)(((uint32_t *)(mattrs))[(23)/32] |= 1<<((23)%32)); | |||
| 1648 | if (args.flags & NFSMNT_NFSV40x00000400) | |||
| 1649 | nfsvers = 4; | |||
| 1650 | else if (args.flags & NFSMNT_NFSV30x00000200) | |||
| 1651 | nfsvers = 3; | |||
| 1652 | else | |||
| 1653 | nfsvers = 2; | |||
| 1654 | if ((args.flags & NFSMNT_RSIZE0x00000004) && (args.rsize > 0)) | |||
| 1655 | NFS_BITMAP_SET(mattrs, NFS_MATTR_READ_SIZE)(((uint32_t *)(mattrs))[(3)/32] |= 1<<((3)%32)); | |||
| 1656 | if ((args.flags & NFSMNT_WSIZE0x00000002) && (args.wsize > 0)) | |||
| 1657 | NFS_BITMAP_SET(mattrs, NFS_MATTR_WRITE_SIZE)(((uint32_t *)(mattrs))[(4)/32] |= 1<<((4)%32)); | |||
| 1658 | if ((args.flags & NFSMNT_TIMEO0x00000008) && (args.timeo > 0)) | |||
| 1659 | NFS_BITMAP_SET(mattrs, NFS_MATTR_REQUEST_TIMEOUT)(((uint32_t *)(mattrs))[(17)/32] |= 1<<((17)%32)); | |||
| 1660 | if ((args.flags & NFSMNT_RETRANS0x00000010) && (args.retrans > 0)) | |||
| 1661 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SOFT_RETRY_COUNT)(((uint32_t *)(mattrs))[(18)/32] |= 1<<((18)%32)); | |||
| 1662 | if ((args.flags & NFSMNT_MAXGRPS0x00000020) && (args.maxgrouplist > 0)) | |||
| 1663 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MAX_GROUP_LIST)(((uint32_t *)(mattrs))[(13)/32] |= 1<<((13)%32)); | |||
| 1664 | if ((args.flags & NFSMNT_READAHEAD0x00002000) && (args.readahead > 0)) | |||
| 1665 | NFS_BITMAP_SET(mattrs, NFS_MATTR_READAHEAD)(((uint32_t *)(mattrs))[(6)/32] |= 1<<((6)%32)); | |||
| 1666 | if ((args.flags & NFSMNT_READDIRSIZE0x00020000) && (args.readdirsize > 0)) | |||
| 1667 | NFS_BITMAP_SET(mattrs, NFS_MATTR_READDIR_SIZE)(((uint32_t *)(mattrs))[(5)/32] |= 1<<((5)%32)); | |||
| 1668 | if ((args.flags & NFSMNT_NOLOCKS0x00040000) || | |||
| 1669 | (args.flags & NFSMNT_LOCALLOCKS0x00080000)) { | |||
| 1670 | NFS_BITMAP_SET(mattrs, NFS_MATTR_LOCK_MODE)(((uint32_t *)(mattrs))[(11)/32] |= 1<<((11)%32)); | |||
| 1671 | if (args.flags & NFSMNT_NOLOCKS0x00040000) | |||
| 1672 | nfslockmode = NFS_LOCK_MODE_DISABLED1; | |||
| 1673 | else if (args.flags & NFSMNT_LOCALLOCKS0x00080000) | |||
| 1674 | nfslockmode = NFS_LOCK_MODE_LOCAL2; | |||
| 1675 | else | |||
| 1676 | nfslockmode = NFS_LOCK_MODE_ENABLED0; | |||
| 1677 | } | |||
| 1678 | if (args.version >= 4) { | |||
| 1679 | if ((args.flags & NFSMNT_ACREGMIN0x00100000) && (args.acregmin > 0)) | |||
| 1680 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_REG_MIN)(((uint32_t *)(mattrs))[(7)/32] |= 1<<((7)%32)); | |||
| 1681 | if ((args.flags & NFSMNT_ACREGMAX0x00200000) && (args.acregmax > 0)) | |||
| 1682 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_REG_MAX)(((uint32_t *)(mattrs))[(8)/32] |= 1<<((8)%32)); | |||
| 1683 | if ((args.flags & NFSMNT_ACDIRMIN0x00400000) && (args.acdirmin > 0)) | |||
| 1684 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MIN)(((uint32_t *)(mattrs))[(9)/32] |= 1<<((9)%32)); | |||
| 1685 | if ((args.flags & NFSMNT_ACDIRMAX0x00800000) && (args.acdirmax > 0)) | |||
| 1686 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MAX)(((uint32_t *)(mattrs))[(10)/32] |= 1<<((10)%32)); | |||
| 1687 | } | |||
| 1688 | if (args.version >= 5) { | |||
| 1689 | if ((args.flags & NFSMNT_SECFLAVOR0x01000000) || (args.flags & NFSMNT_SECSYSOK0x02000000)) | |||
| 1690 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SECURITY)(((uint32_t *)(mattrs))[(12)/32] |= 1<<((12)%32)); | |||
| 1691 | } | |||
| 1692 | if (args.version >= 6) { | |||
| 1693 | if ((args.flags & NFSMNT_DEADTIMEOUT0x00001000) && (args.deadtimeout > 0)) | |||
| 1694 | NFS_BITMAP_SET(mattrs, NFS_MATTR_DEAD_TIMEOUT)(((uint32_t *)(mattrs))[(19)/32] |= 1<<((19)%32)); | |||
| 1695 | } | |||
| 1696 | ||||
| 1697 | /* build xdr buffer */ | |||
| 1698 | xb_init_buffer(&xb, NULL((void *)0), 0); | |||
| 1699 | xb_add_32(error, &xb, args.version)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.version)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.version)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.version)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.version)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.version)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.version)))); ( error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1700 | argslength_offset = xb_offset(&xb); | |||
| 1701 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); // args length | |||
| 1702 | xb_add_32(error, &xb, NFS_XDRARGS_VERSION_0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1703 | xb_add_bitmap(error, &xb, mattrs, NFS_MATTR_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xb))), (void*)&__tmp, 4, 0); } while (0); for (__i =0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp; if ( ((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(( (mattrs))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t)((( mattrs))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((mattrs))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((mattrs ))[__i])))); (((error))) = xb_add_bytes((((&xb))), (void* )&__tmp, 4, 0); } while (0); } while (0); | |||
| 1704 | attrslength_offset = xb_offset(&xb); | |||
| 1705 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); // attrs length | |||
| 1706 | xb_add_bitmap(error, &xb, mflags_mask, NFS_MFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xb))), (void*)&__tmp, 4, 0); } while (0); for (__i =0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp; if ( ((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(( (mflags_mask))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((mflags_mask))[__i])) & 0xff000000) >> 24) | ((( __uint32_t)((uint32_t)(((mflags_mask))[__i])) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(((mflags_mask))[__i ])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (((mflags_mask))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((mflags_mask))[__i])))); (((error))) = xb_add_bytes ((((&xb))), (void*)&__tmp, 4, 0); } while (0); } while (0); /* mask */ | |||
| 1707 | xb_add_bitmap(error, &xb, mflags, NFS_MFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xb))), (void*)&__tmp, 4, 0); } while (0); for (__i =0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp; if ( ((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(( (mflags))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t)((( mflags))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((mflags))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((mflags))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((mflags))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((mflags ))[__i])))); (((error))) = xb_add_bytes((((&xb))), (void* )&__tmp, 4, 0); } while (0); } while (0); /* value */ | |||
| 1708 | xb_add_32(error, &xb, nfsvers)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nfsvers)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(nfsvers)) & 0xff000000) >> 24) | (((__uint32_t)(( uint32_t)(nfsvers)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(nfsvers)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nfsvers)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nfsvers)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); | |||
| 1709 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READ_SIZE)(((uint32_t *)(mattrs))[(3)/32] & (1<<((3)%32)))) | |||
| 1710 | xb_add_32(error, &xb, args.rsize)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.rsize)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.rsize)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.rsize)) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(args.rsize)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.rsize)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.rsize)))); (error ) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1711 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_WRITE_SIZE)(((uint32_t *)(mattrs))[(4)/32] & (1<<((4)%32)))) | |||
| 1712 | xb_add_32(error, &xb, args.wsize)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.wsize)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.wsize)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.wsize)) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(args.wsize)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.wsize)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.wsize)))); (error ) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1713 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READDIR_SIZE)(((uint32_t *)(mattrs))[(5)/32] & (1<<((5)%32)))) | |||
| 1714 | xb_add_32(error, &xb, args.readdirsize)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.readdirsize)) ? ((__uint32_t)((((__uint32_t) ((uint32_t)(args.readdirsize)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(args.readdirsize)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(args.readdirsize)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.readdirsize )) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t) (args.readdirsize)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); | |||
| 1715 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READAHEAD)(((uint32_t *)(mattrs))[(6)/32] & (1<<((6)%32)))) | |||
| 1716 | xb_add_32(error, &xb, args.readahead)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.readahead)) ? ((__uint32_t)((((__uint32_t)(( uint32_t)(args.readahead)) & 0xff000000) >> 24) | ( ((__uint32_t)((uint32_t)(args.readahead)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(args.readahead)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(args.readahead)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(args.readahead )))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1717 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_REG_MIN)(((uint32_t *)(mattrs))[(7)/32] & (1<<((7)%32)))) { | |||
| 1718 | xb_add_32(error, &xb, args.acregmin)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.acregmin)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.acregmin)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.acregmin)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.acregmin)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.acregmin)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.acregmin)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1719 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1720 | } | |||
| 1721 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_REG_MAX)(((uint32_t *)(mattrs))[(8)/32] & (1<<((8)%32)))) { | |||
| 1722 | xb_add_32(error, &xb, args.acregmax)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.acregmax)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.acregmax)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.acregmax)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.acregmax)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.acregmax)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.acregmax)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1723 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1724 | } | |||
| 1725 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MIN)(((uint32_t *)(mattrs))[(9)/32] & (1<<((9)%32)))) { | |||
| 1726 | xb_add_32(error, &xb, args.acdirmin)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.acdirmin)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.acdirmin)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.acdirmin)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.acdirmin)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.acdirmin)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.acdirmin)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1727 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1728 | } | |||
| 1729 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MAX)(((uint32_t *)(mattrs))[(10)/32] & (1<<((10)%32)))) { | |||
| 1730 | xb_add_32(error, &xb, args.acdirmax)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.acdirmax)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.acdirmax)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.acdirmax)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.acdirmax)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.acdirmax)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.acdirmax)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1731 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1732 | } | |||
| 1733 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_LOCK_MODE)(((uint32_t *)(mattrs))[(11)/32] & (1<<((11)%32)))) | |||
| 1734 | xb_add_32(error, &xb, nfslockmode)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nfslockmode)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(nfslockmode)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(nfslockmode)) & 0x00ff0000) >> 8) | (( (__uint32_t)((uint32_t)(nfslockmode)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nfslockmode)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(nfslockmode)))); ( error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1735 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SECURITY)(((uint32_t *)(mattrs))[(12)/32] & (1<<((12)%32)))) { | |||
| 1736 | uint32_t flavors[2], i=0; | |||
| 1737 | if (args.flags & NFSMNT_SECFLAVOR0x01000000) | |||
| 1738 | flavors[i++] = args.auth; | |||
| 1739 | if ((args.flags & NFSMNT_SECSYSOK0x02000000) && ((i == 0) || (flavors[0] != RPCAUTH_SYS1))) | |||
| 1740 | flavors[i++] = RPCAUTH_SYS1; | |||
| 1741 | xb_add_word_array(error, &xb, flavors, i)do { uint32_t __i; do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t)((i))) ? ((__uint32_t)((( (__uint32_t)((uint32_t)((i))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((i))) & 0x00ff0000) >> 8 ) | (((__uint32_t)((uint32_t)((i))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((i))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((i))))); ((error)) = xb_add_bytes (((&xb)), (void*)&__tmp, 4, 0); } while (0); for (__i =0; __i < (uint32_t)(i); __i++) do { uint32_t __tmp; if (( error)) break; __tmp = ((__builtin_constant_p((uint32_t)((flavors )[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t)((flavors)[ __i])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((flavors)[__i])) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((flavors)[__i])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((flavors)[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((flavors)[__i])))); ((error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0 ); } while (0); } while (0); | |||
| 1742 | } | |||
| 1743 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MAX_GROUP_LIST)(((uint32_t *)(mattrs))[(13)/32] & (1<<((13)%32)))) | |||
| 1744 | xb_add_32(error, &xb, args.maxgrouplist)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.maxgrouplist)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(args.maxgrouplist)) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)(args.maxgrouplist)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(args.maxgrouplist)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args .maxgrouplist)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(args.maxgrouplist)))); (error) = xb_add_bytes((& xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1745 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] & (1<<((14)%32)))) | |||
| 1746 | xb_add_string(error, &xb, ((args.sotype == SOCK_DGRAM) ? "udp" : "tcp"), 3)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((3))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(( 3))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((3))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((3))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((3))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((3))))); ((error)) = xb_add_bytes(((&xb)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xb), (const char*)(((args.sotype == 2) ? "udp" : "tcp" )), (3), 0); } while (0); | |||
| 1747 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] & (1<<((15)%32)))) | |||
| 1748 | xb_add_32(error, &xb, ((ss.ss_family == AF_INET) ?do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p(( (struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t)(( ((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0) | |||
| 1749 | ntohs(((struct sockaddr_in*)&ss)->sin_port) :do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p(( (struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t)(( ((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0) | |||
| 1750 | ntohs(((struct sockaddr_in6*)&ss)->sin6_port)))do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p(( (struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t)(( ((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((ss.ss_family == 2) ? ((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)&ss)->sin_port) ? ((__uint16_t) ((((__uint16_t)(((struct sockaddr_in*)&ss)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)& ss)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16( ((struct sockaddr_in*)&ss)->sin_port))) : ((__uint16_t )(__builtin_constant_p(((struct sockaddr_in6*)&ss)->sin6_port ) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6*)& ss)->sin6_port) & 0xff00) >> 8) | (((__uint16_t) (((struct sockaddr_in6*)&ss)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)&ss) ->sin6_port)))))))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); | |||
| 1751 | /* NFS_MATTR_MOUNT_PORT (not available in old args) */ | |||
| 1752 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_REQUEST_TIMEOUT)(((uint32_t *)(mattrs))[(17)/32] & (1<<((17)%32)))) { | |||
| 1753 | /* convert from .1s increments to time */ | |||
| 1754 | xb_add_32(error, &xb, args.timeo/10)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.timeo/10)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.timeo/10)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.timeo/10)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.timeo/10)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.timeo/10)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.timeo/10)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1755 | xb_add_32(error, &xb, (args.timeo%10)*100000000)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)((args.timeo%10)*100000000)) ? ((__uint32_t)((((__uint32_t )((uint32_t)((args.timeo%10)*100000000)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((args.timeo%10)*100000000)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((args.timeo %10)*100000000)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((args.timeo%10)*100000000)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((args.timeo%10)*100000000))) ); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0) ; } while (0); | |||
| 1756 | } | |||
| 1757 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SOFT_RETRY_COUNT)(((uint32_t *)(mattrs))[(18)/32] & (1<<((18)%32)))) | |||
| 1758 | xb_add_32(error, &xb, args.retrans)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.retrans)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(args.retrans)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(args.retrans)) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)(args.retrans)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.retrans)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(args.retrans)))); ( error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1759 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_DEAD_TIMEOUT)(((uint32_t *)(mattrs))[(19)/32] & (1<<((19)%32)))) { | |||
| 1760 | xb_add_32(error, &xb, args.deadtimeout)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(args.deadtimeout)) ? ((__uint32_t)((((__uint32_t) ((uint32_t)(args.deadtimeout)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(args.deadtimeout)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(args.deadtimeout)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(args.deadtimeout )) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t) (args.deadtimeout)))); (error) = xb_add_bytes((&xb), (void *)&__tmp, 4, 0); } while (0); | |||
| 1761 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); | |||
| 1762 | } | |||
| 1763 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] & (1<<((20)%32)))) | |||
| 1764 | xb_add_fh(error, &xb, &nfh[0], args.fhsize)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((args.fhsize))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((args.fhsize))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)((args.fhsize))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((args.fhsize))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((args.fhsize))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((args.fhsize))))); ((error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0 ); } while (0); if (error) break; (error) = xb_add_bytes((& xb), (char*)(&nfh[0]), (args.fhsize), 0); } while (0); | |||
| 1765 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] & (1<<((21)%32)))) { | |||
| 1766 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* fs location count */ | |||
| 1767 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* server count */ | |||
| 1768 | xb_add_string(error, &xb, mntfrom, (endserverp - mntfrom))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((endserverp - mntfrom)))) ? ((__uint32_t)((((__uint32_t )((uint32_t)(((endserverp - mntfrom)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((endserverp - mntfrom)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((endserverp - mntfrom)))) & 0x0000ff00) << 8) | (((__uint32_t) ((uint32_t)(((endserverp - mntfrom)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((endserverp - mntfrom)))))) ; ((error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((& xb), (const char*)(mntfrom), ((endserverp - mntfrom)), 0); } while (0); /* server name */ | |||
| 1769 | xb_add_32(error, &xb, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* address count */ | |||
| 1770 | xb_add_string(error, &xb, uaddr, strlen(uaddr))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(uaddr)))) ? ((__uint32_t)((((__uint32_t)( (uint32_t)((strlen(uaddr)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(uaddr)))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((strlen(uaddr)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( uaddr)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((strlen(uaddr)))))); ((error)) = xb_add_bytes(((&xb)), ( void*)&__tmp, 4, 0); } while (0); if (error) break; (error ) = xb_add_bytes((&xb), (const char*)(uaddr), (strlen(uaddr )), 0); } while (0); /* address */ | |||
| 1771 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* empty server info */ | |||
| 1772 | xb_add_32(error, &xb, numcomps)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(numcomps)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(numcomps)) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)(numcomps)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(numcomps)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(numcomps)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(numcomps)))); (error) = xb_add_bytes((&xb), ( void*)&__tmp, 4, 0); } while (0); /* pathname component count */ | |||
| 1773 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1774 | p = frompath; | |||
| 1775 | while (*p && (*p == '/')) | |||
| 1776 | p++; | |||
| 1777 | while (*p) { | |||
| 1778 | cp = p; | |||
| 1779 | while (*p && (*p != '/')) | |||
| 1780 | p++; | |||
| 1781 | xb_add_string(error, &xb, cp, (p - cp))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((p - cp)))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((p - cp)))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((p - cp)))) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(((p - cp)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((p - cp)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((p - cp)))))); (( error)) = xb_add_bytes(((&xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((& xb), (const char*)(cp), ((p - cp)), 0); } while (0); /* component */ | |||
| 1782 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1783 | while (*p && (*p == '/')) | |||
| 1784 | p++; | |||
| 1785 | } | |||
| 1786 | xb_add_32(error, &xb, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xb), (void*)&__tmp, 4, 0); } while (0); /* empty fsl info */ | |||
| 1787 | } | |||
| 1788 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] & (1<<((22)%32)))) | |||
| 1789 | xb_add_32(error, &xb, (vfs_flags(mp) & MNT_VISFLAGMASK))do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)((vfs_flags(mp) & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080)))) ? (( __uint32_t)((((__uint32_t)((uint32_t)((vfs_flags(mp) & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080)))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)((vfs_flags(mp) & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((vfs_flags (mp) & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((vfs_flags(mp) & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080)))) & 0x000000ff) << 24) )) : _OSSwapInt32((uint32_t)((vfs_flags(mp) & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000100 | 0x00000400 | 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000 | 0x00100000 | 0x00200000 | 0x00400000 | 0x00800000 | 0x01000000 | 0x02000000 | 0x04000000 | 0x10000000 | 0x00000080)))))); (error) = xb_add_bytes((&xb), (void* )&__tmp, 4, 0); } while (0); /* VFS MNT_* flags */ | |||
| 1790 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MNTFROM)(((uint32_t *)(mattrs))[(23)/32] & (1<<((23)%32)))) | |||
| 1791 | xb_add_string(error, &xb, mntfrom, strlen(mntfrom))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(mntfrom)))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((strlen(mntfrom)))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((strlen(mntfrom)))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((strlen(mntfrom)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen (mntfrom)))) & 0x000000ff) << 24))) : _OSSwapInt32( (uint32_t)((strlen(mntfrom)))))); ((error)) = xb_add_bytes((( &xb)), (void*)&__tmp, 4, 0); } while (0); if (error) break ; (error) = xb_add_bytes((&xb), (const char*)(mntfrom), ( strlen(mntfrom)), 0); } while (0); /* fixed f_mntfromname */ | |||
| 1792 | xb_build_done(error, &xb)do { if (error) break; xb_set_cur_buf_len(&xb); } while ( 0); | |||
| 1793 | ||||
| 1794 | /* update opaque counts */ | |||
| 1795 | end_offset = xb_offset(&xb); | |||
| 1796 | error = xb_seek(&xb, argslength_offset); | |||
| 1797 | xb_add_32(error, &xb, end_offset - argslength_offset + XDRWORD/*version*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - argslength_offset + 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - argslength_offset + 4 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (end_offset - argslength_offset + 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - argslength_offset + 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - argslength_offset + 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - argslength_offset + 4)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1798 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1799 | error = xb_seek(&xb, attrslength_offset); | |||
| 1800 | xb_add_32(error, &xb, end_offset - attrslength_offset - XDRWORD/*don't include length field*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - attrslength_offset - 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - attrslength_offset - 4)))); (error) = xb_add_bytes((&xb), (void*)&__tmp , 4, 0); } while (0); | |||
| 1801 | ||||
| 1802 | if (!error) { | |||
| 1803 | /* grab the assembled buffer */ | |||
| 1804 | *xdrbufp = xb_buffer_base(&xb); | |||
| 1805 | xb.xb_flags &= ~XB_CLEANUP0x0001; | |||
| 1806 | } | |||
| 1807 | nfsmout: | |||
| 1808 | xb_cleanup(&xb); | |||
| 1809 | FREE_ZONE(mntfrom, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)mntfrom, 1024, 12); | |||
| 1810 | return (error); | |||
| 1811 | } | |||
| 1812 | ||||
| 1813 | /* | |||
| 1814 | * VFS Operations. | |||
| 1815 | * | |||
| 1816 | * mount system call | |||
| 1817 | */ | |||
| 1818 | int | |||
| 1819 | nfs_vfs_mount(mount_t mp, vnode_t vp, user_addr_t data, vfs_context_t ctx) | |||
| 1820 | { | |||
| 1821 | int error = 0, inkernel = vfs_iskernelmount(mp); | |||
| 1822 | uint32_t argsversion, argslength; | |||
| 1823 | char *xdrbuf = NULL((void *)0); | |||
| 1824 | ||||
| 1825 | /* read in version */ | |||
| 1826 | if (inkernel) | |||
| 1827 | bcopy(CAST_DOWN(void *, data)( ((void *)((uintptr_t) (data)/(sizeof(void *) < sizeof(uintptr_t ) ? 0 : 1))) ), &argsversion, sizeof(argsversion)); | |||
| 1828 | else if ((error = copyin(data, &argsversion, sizeof(argsversion)))) | |||
| 1829 | return (error); | |||
| 1830 | ||||
| 1831 | /* If we have XDR args, then all values in the buffer are in network order */ | |||
| 1832 | if (argsversion == htonl(NFS_ARGSVERSION_XDR)(__builtin_constant_p(88) ? ((__uint32_t)((((__uint32_t)(88) & 0xff000000) >> 24) | (((__uint32_t)(88) & 0x00ff0000 ) >> 8) | (((__uint32_t)(88) & 0x0000ff00) << 8) | (((__uint32_t)(88) & 0x000000ff) << 24))) : _OSSwapInt32 (88))) | |||
| 1833 | argsversion = NFS_ARGSVERSION_XDR88; | |||
| 1834 | ||||
| 1835 | switch (argsversion) { | |||
| 1836 | case 3: | |||
| 1837 | case 4: | |||
| 1838 | case 5: | |||
| 1839 | case 6: | |||
| 1840 | /* convert old-style args to xdr */ | |||
| 1841 | error = nfs_convert_old_nfs_args(mp, data, ctx, argsversion, inkernel, &xdrbuf); | |||
| 1842 | break; | |||
| 1843 | case NFS_ARGSVERSION_XDR88: | |||
| 1844 | /* copy in xdr buffer */ | |||
| 1845 | if (inkernel) | |||
| 1846 | bcopy(CAST_DOWN(void *, (data + XDRWORD))( ((void *)((uintptr_t) ((data + 4))/(sizeof(void *) < sizeof (uintptr_t) ? 0 : 1))) ), &argslength, XDRWORD4); | |||
| 1847 | else | |||
| 1848 | error = copyin((data + XDRWORD4), &argslength, XDRWORD4); | |||
| 1849 | if (error) | |||
| 1850 | break; | |||
| 1851 | argslength = ntohl(argslength)(__builtin_constant_p(argslength) ? ((__uint32_t)((((__uint32_t )(argslength) & 0xff000000) >> 24) | (((__uint32_t) (argslength) & 0x00ff0000) >> 8) | (((__uint32_t)(argslength ) & 0x0000ff00) << 8) | (((__uint32_t)(argslength) & 0x000000ff) << 24))) : _OSSwapInt32(argslength)); | |||
| 1852 | /* put a reasonable limit on the size of the XDR args */ | |||
| 1853 | if (argslength > 16*1024) { | |||
| 1854 | error = E2BIG7; | |||
| 1855 | break; | |||
| 1856 | } | |||
| 1857 | /* allocate xdr buffer */ | |||
| 1858 | xdrbuf = xb_malloc(xdr_rndup(argslength)(((argslength)+3)&(~0x3))); | |||
| 1859 | if (!xdrbuf) { | |||
| 1860 | error = ENOMEM12; | |||
| 1861 | break; | |||
| 1862 | } | |||
| 1863 | if (inkernel) | |||
| 1864 | bcopy(CAST_DOWN(void *, data)( ((void *)((uintptr_t) (data)/(sizeof(void *) < sizeof(uintptr_t ) ? 0 : 1))) ), xdrbuf, argslength); | |||
| 1865 | else | |||
| 1866 | error = copyin(data, xdrbuf, argslength); | |||
| 1867 | break; | |||
| 1868 | default: | |||
| 1869 | error = EPROGMISMATCH75; | |||
| 1870 | } | |||
| 1871 | ||||
| 1872 | if (error) { | |||
| 1873 | if (xdrbuf) | |||
| 1874 | xb_free(xdrbuf); | |||
| 1875 | return (error); | |||
| 1876 | } | |||
| 1877 | error = mountnfs(xdrbuf, mp, ctx, &vp); | |||
| 1878 | return (error); | |||
| 1879 | } | |||
| 1880 | ||||
| 1881 | /* | |||
| 1882 | * Common code for mount and mountroot | |||
| 1883 | */ | |||
| 1884 | ||||
| 1885 | /* Set up an NFSv2/v3 mount */ | |||
| 1886 | int | |||
| 1887 | nfs3_mount( | |||
| 1888 | struct nfsmount *nmp, | |||
| 1889 | vfs_context_t ctx, | |||
| 1890 | nfsnode_t *npp) | |||
| 1891 | { | |||
| 1892 | int error = 0; | |||
| 1893 | struct nfs_vattr nvattr; | |||
| 1894 | u_int64_t xid; | |||
| 1895 | ||||
| 1896 | *npp = NULL((void *)0); | |||
| 1897 | ||||
| 1898 | if (!nmp->nm_fh) | |||
| 1899 | return (EINVAL22); | |||
| 1900 | ||||
| 1901 | /* | |||
| 1902 | * Get file attributes for the mountpoint. These are needed | |||
| 1903 | * in order to properly create the root vnode. | |||
| 1904 | */ | |||
| 1905 | error = nfs3_getattr_rpc(NULL((void *)0), nmp->nm_mountp, nmp->nm_fh->fh_data, nmp->nm_fh->fh_len, 0, | |||
| 1906 | ctx, &nvattr, &xid); | |||
| 1907 | if (error) | |||
| 1908 | goto out; | |||
| 1909 | ||||
| 1910 | error = nfs_nget(nmp->nm_mountp, NULL((void *)0), NULL((void *)0), nmp->nm_fh->fh_data, nmp->nm_fh->fh_len, | |||
| 1911 | &nvattr, &xid, RPCAUTH_UNKNOWN~0U, NG_MARKROOT0x0001, npp); | |||
| 1912 | if (*npp) | |||
| 1913 | nfs_node_unlock(*npp); | |||
| 1914 | if (error) | |||
| 1915 | goto out; | |||
| 1916 | ||||
| 1917 | /* | |||
| 1918 | * Try to make sure we have all the general info from the server. | |||
| 1919 | */ | |||
| 1920 | if (nmp->nm_vers == NFS_VER22) { | |||
| 1921 | NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXNAME)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(29)/32] |= 1<< ((29)%32)); | |||
| 1922 | nmp->nm_fsattr.nfsa_maxname = NFS_MAXNAMLEN255; | |||
| 1923 | } else if (nmp->nm_vers == NFS_VER33) { | |||
| 1924 | /* get the NFSv3 FSINFO */ | |||
| 1925 | error = nfs3_fsinfo(nmp, *npp, ctx); | |||
| 1926 | if (error) | |||
| 1927 | goto out; | |||
| 1928 | /* If the server indicates all pathconf info is */ | |||
| 1929 | /* the same, grab a copy of that info now */ | |||
| 1930 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_HOMOGENEOUS)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(26)/32] & (1<<((26)%32))) && | |||
| 1931 | (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_HOMOGENEOUS0x00000100)) { | |||
| 1932 | struct nfs_fsattr nfsa; | |||
| 1933 | if (!nfs3_pathconf_rpc(*npp, &nfsa, ctx)) { | |||
| 1934 | /* cache a copy of the results */ | |||
| 1935 | lck_mtx_lock(&nmp->nm_lock); | |||
| 1936 | nfs3_pathconf_cache(nmp, &nfsa); | |||
| 1937 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 1938 | } | |||
| 1939 | } | |||
| 1940 | } | |||
| 1941 | out: | |||
| 1942 | if (*npp && error) { | |||
| 1943 | vnode_put(NFSTOV(*npp)((*npp)->n_vnode)); | |||
| 1944 | vnode_recycle(NFSTOV(*npp)((*npp)->n_vnode)); | |||
| 1945 | *npp = NULL((void *)0); | |||
| 1946 | } | |||
| 1947 | return (error); | |||
| 1948 | } | |||
| 1949 | ||||
| 1950 | /* | |||
| 1951 | * Update an NFSv4 mount path with the contents of the symlink. | |||
| 1952 | * | |||
| 1953 | * Read the link for the given file handle. | |||
| 1954 | * Insert the link's components into the path. | |||
| 1955 | */ | |||
| 1956 | int | |||
| 1957 | nfs4_mount_update_path_with_symlink(struct nfsmount *nmp, struct nfs_fs_path *nfsp, uint32_t curcomp, fhandle_t *dirfhp, int *depthp, fhandle_t *fhp, vfs_context_t ctx) | |||
| 1958 | { | |||
| 1959 | int error = 0, status, numops; | |||
| 1960 | uint32_t len = 0, comp, newcomp, linkcompcount; | |||
| 1961 | u_int64_t xid; | |||
| 1962 | struct nfsm_chain nmreq, nmrep; | |||
| 1963 | struct nfsreq rq, *req = &rq; | |||
| 1964 | struct nfsreq_secinfo_args si; | |||
| 1965 | char *link = NULL((void *)0), *p, *q, ch; | |||
| 1966 | struct nfs_fs_path nfsp2; | |||
| 1967 | ||||
| 1968 | bzero(&nfsp2, sizeof(nfsp2)); | |||
| 1969 | if (dirfhp->fh_len) | |||
| 1970 | NFSREQ_SECINFO_SET(&si, NULL, dirfhp->fh_data, dirfhp->fh_len, nfsp->np_components[curcomp], 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (dirfhp->fh_data); (&si)->rsia_fhsize = (dirfhp-> fh_len); (&si)->rsia_name = (nfsp->np_components[curcomp ]); (&si)->rsia_namelen = (0); } while (0); | |||
| 1971 | else | |||
| 1972 | NFSREQ_SECINFO_SET(&si, NULL, NULL, 0, nfsp->np_components[curcomp], 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (((void *)0)); (&si)->rsia_fhsize = (0); (&si)-> rsia_name = (nfsp->np_components[curcomp]); (&si)-> rsia_namelen = (0); } while (0); | |||
| 1973 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 1974 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 1975 | ||||
| 1976 | MALLOC_ZONE(link, char *, MAXPATHLEN, M_NAMEI, M_WAITOK)(link) = (char *)({ static vm_allocation_site_t site __attribute__ ((section("__DATA, __data"))); __MALLOC_ZONE(1024, 12, 0x0000 , &site); }); | |||
| 1977 | if (!link) | |||
| 1978 | error = ENOMEM12; | |||
| 1979 | ||||
| 1980 | // PUTFH, READLINK | |||
| 1981 | numops = 2; | |||
| 1982 | nfsm_chain_build_alloc_init(error, &nmreq, 12 * NFSX_UNSIGNED)do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((12 * 4)) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget (MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 1983 | nfsm_chain_add_compound_header(error, &nmreq, "readlink", nmp->nm_minor_vers, numops)do { if (("readlink") && strlen("readlink")) { char __nfstag [12 +1]; snprintf(__nfstag, sizeof(__nfstag), "%-*s", 12, ("readlink" )); do { do { if (((error))) break; if ((((&nmreq)))-> nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((& nmreq))), (4)); if (!(((error))) && ((((&nmreq))) ->nmc_left < (4))) (((error))) = 12; } } while (0); if ( (error)) break; *((uint32_t*)((&nmreq))->nmc_ptr) = (( __builtin_constant_p((uint32_t)(12)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(12)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(12)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(12)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(12)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(12)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq ))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((( 12)+3)&(~0x3)); if ((error)) break; if (((&nmreq))-> nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(( (&nmreq)), (const u_char*)(__nfstag), (12)); break; } *(( (uint32_t*)(((&nmreq))->nmc_ptr))+((((((12))+3)&(~ 0x3))>>2)-1)) = 0; bcopy((__nfstag), ((&nmreq))-> nmc_ptr, (12)); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } else { do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), ( 4)); if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break ; *((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); } do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((nmp->nm_minor_vers) )) ? ((__uint32_t)((((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((nmp->nm_minor_vers))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((nmp->nm_minor_vers))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((nmp->nm_minor_vers))))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((numops))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((numops))) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)((numops))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((numops))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numops))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numops))))); ((&nmreq))->nmc_ptr += 4; (( &nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 1984 | numops--; | |||
| 1985 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(22)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(22)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(22)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(22)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(22)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(22)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 1986 | nfsm_chain_add_fh(error, &nmreq, NFS_VER4, fhp->fh_data, fhp->fh_len)do { if (error) break; if ((4) != 2) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error ))) = nfsm_chain_new_mbuf((((&nmreq))), (4)); if (!(((error ))) && ((((&nmreq)))->nmc_left < (4))) (((error ))) = 12; } } while (0); if ((error)) break; *((uint32_t*)((& nmreq))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((fhp ->fh_len))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((fhp ->fh_len))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)((fhp->fh_len))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((fhp->fh_len))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((fhp->fh_len))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((fhp-> fh_len))))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((fhp-> fh_len))+3)&(~0x3)); if ((error)) break; if (((&nmreq ))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f (((&nmreq)), (const u_char*)((fhp->fh_data)), ((fhp-> fh_len))); break; } *(((uint32_t*)(((&nmreq))->nmc_ptr ))+(((((((fhp->fh_len)))+3)&(~0x3))>>2)-1)) = 0; bcopy(((fhp->fh_data)), ((&nmreq))->nmc_ptr, ((fhp ->fh_len))); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } while (0); | |||
| 1987 | numops--; | |||
| 1988 | nfsm_chain_add_32(error, &nmreq, NFS_OP_READLINK)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(27)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(27)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(27)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(27)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(27)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(27)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 1989 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 1990 | nfsm_assert(error, (numops == 0), EPROTO)do { if (error) break; if (!((numops == 0))) (error) = (100); } while (0); | |||
| 1991 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 1992 | ||||
| 1993 | error = nfs_request_async(NULL((void *)0), nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND1, | |||
| 1994 | vfs_context_thread(ctx), vfs_context_ucred(ctx), &si, 0, NULL((void *)0), &req); | |||
| 1995 | if (!error) | |||
| 1996 | error = nfs_request_async_finish(req, &nmrep, &xid, &status); | |||
| 1997 | ||||
| 1998 | nfsm_chain_skip_tag(error, &nmrep)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (((&nmrep))->nmc_left >= (uint32_t)((((__val)+3)&(~0x3)))) { ((&nmrep)) ->nmc_left -= ((((__val)+3)&(~0x3))); ((&nmrep))-> nmc_ptr += ((((__val)+3)&(~0x3))); } else { ((error)) = nfsm_chain_advance (((&nmrep)), ((((__val)+3)&(~0x3)))); } } while (0); } while (0); | |||
| 1999 | nfsm_chain_get_32(error, &nmrep, numops)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (numops ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 2000 | nfsm_chain_op_check(error, &nmrep, NFS_OP_PUTFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (22)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2001 | nfsm_chain_op_check(error, &nmrep, NFS_OP_READLINK)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (27)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2002 | nfsm_chain_get_32(error, &nmrep, len)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (len ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 2003 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2004 | if (len == 0) | |||
| 2005 | error = ENOENT2; | |||
| 2006 | else if (len >= MAXPATHLEN1024) | |||
| 2007 | len = MAXPATHLEN1024 - 1; | |||
| 2008 | nfsm_chain_get_opaque(error, &nmrep, len, link)do { uint32_t rndlen; if (error) break; rndlen = (((len)+3)& (~0x3)); if ((&nmrep)->nmc_left >= rndlen) { u_char *__tmpptr = (u_char*)(&nmrep)->nmc_ptr; (&nmrep)-> nmc_left -= rndlen; (&nmrep)->nmc_ptr += rndlen; bcopy (__tmpptr, (link), (len)); } else { (error) = nfsm_chain_get_opaque_f ((&nmrep), (len), (u_char*)(link)); } } while (0); | |||
| 2009 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2010 | /* make sure link string is terminated properly */ | |||
| 2011 | link[len] = '\0'; | |||
| 2012 | ||||
| 2013 | /* count the number of components in link */ | |||
| 2014 | p = link; | |||
| 2015 | while (*p && (*p == '/')) | |||
| 2016 | p++; | |||
| 2017 | linkcompcount = 0; | |||
| 2018 | while (*p) { | |||
| 2019 | linkcompcount++; | |||
| 2020 | while (*p && (*p != '/')) | |||
| 2021 | p++; | |||
| 2022 | while (*p && (*p == '/')) | |||
| 2023 | p++; | |||
| 2024 | } | |||
| 2025 | ||||
| 2026 | /* free up used components */ | |||
| 2027 | for (comp=0; comp <= curcomp; comp++) { | |||
| 2028 | if (nfsp->np_components[comp]) { | |||
| 2029 | FREE(nfsp->np_components[comp], M_TEMP)_FREE((void *)nfsp->np_components[comp], 80); | |||
| 2030 | nfsp->np_components[comp] = NULL((void *)0); | |||
| 2031 | } | |||
| 2032 | } | |||
| 2033 | ||||
| 2034 | /* set up new path */ | |||
| 2035 | nfsp2.np_compcount = nfsp->np_compcount - curcomp - 1 + linkcompcount; | |||
| 2036 | MALLOC(nfsp2.np_components, char **, nfsp2.np_compcount*sizeof(char*), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nfsp2.np_components) = (char **)__MALLOC(nfsp2.np_compcount *sizeof(char*), 80, 0x0000|0x0004, &site); }); | |||
| 2037 | if (!nfsp2.np_components) { | |||
| 2038 | error = ENOMEM12; | |||
| 2039 | goto nfsmout; | |||
| 2040 | } | |||
| 2041 | ||||
| 2042 | /* add link components */ | |||
| 2043 | p = link; | |||
| 2044 | while (*p && (*p == '/')) | |||
| 2045 | p++; | |||
| 2046 | for (newcomp=0; newcomp < linkcompcount; newcomp++) { | |||
| 2047 | /* find end of component */ | |||
| 2048 | q = p; | |||
| 2049 | while (*q && (*q != '/')) | |||
| 2050 | q++; | |||
| 2051 | MALLOC(nfsp2.np_components[newcomp], char *, q-p+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nfsp2.np_components[newcomp]) = (char *)__MALLOC(q-p+1, 80, 0x0000|0x0004, &site); }); | |||
| 2052 | if (!nfsp2.np_components[newcomp]) { | |||
| 2053 | error = ENOMEM12; | |||
| 2054 | break; | |||
| 2055 | } | |||
| 2056 | ch = *q; | |||
| 2057 | *q = '\0'; | |||
| 2058 | strlcpy(nfsp2.np_components[newcomp], p, q-p+1); | |||
| 2059 | *q = ch; | |||
| 2060 | p = q; | |||
| 2061 | while (*p && (*p == '/')) | |||
| 2062 | p++; | |||
| 2063 | } | |||
| 2064 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2065 | ||||
| 2066 | /* add remaining components */ | |||
| 2067 | for(comp = curcomp + 1; comp < nfsp->np_compcount; comp++,newcomp++) { | |||
| 2068 | nfsp2.np_components[newcomp] = nfsp->np_components[comp]; | |||
| 2069 | nfsp->np_components[comp] = NULL((void *)0); | |||
| 2070 | } | |||
| 2071 | ||||
| 2072 | /* move new path into place */ | |||
| 2073 | FREE(nfsp->np_components, M_TEMP)_FREE((void *)nfsp->np_components, 80); | |||
| 2074 | nfsp->np_components = nfsp2.np_components; | |||
| 2075 | nfsp->np_compcount = nfsp2.np_compcount; | |||
| 2076 | nfsp2.np_components = NULL((void *)0); | |||
| 2077 | ||||
| 2078 | /* for absolute link, let the caller now that the next dirfh is root */ | |||
| 2079 | if (link[0] == '/') { | |||
| 2080 | dirfhp->fh_len = 0; | |||
| 2081 | *depthp = 0; | |||
| 2082 | } | |||
| 2083 | nfsmout: | |||
| 2084 | if (link) | |||
| 2085 | FREE_ZONE(link, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)link, 1024, 12); | |||
| 2086 | if (nfsp2.np_components) { | |||
| 2087 | for (comp=0; comp < nfsp2.np_compcount; comp++) | |||
| 2088 | if (nfsp2.np_components[comp]) | |||
| 2089 | FREE(nfsp2.np_components[comp], M_TEMP)_FREE((void *)nfsp2.np_components[comp], 80); | |||
| 2090 | FREE(nfsp2.np_components, M_TEMP)_FREE((void *)nfsp2.np_components, 80); | |||
| 2091 | } | |||
| 2092 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 2093 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 2094 | return (error); | |||
| 2095 | } | |||
| 2096 | ||||
| 2097 | /* Set up an NFSv4 mount */ | |||
| 2098 | int | |||
| 2099 | nfs4_mount( | |||
| 2100 | struct nfsmount *nmp, | |||
| 2101 | vfs_context_t ctx, | |||
| 2102 | nfsnode_t *npp) | |||
| 2103 | { | |||
| 2104 | struct nfsm_chain nmreq, nmrep; | |||
| 2105 | int error = 0, numops, status, interval, isdotdot, loopcnt = 0, depth = 0; | |||
| 2106 | struct nfs_fs_path fspath, *nfsp, fspath2; | |||
| 2107 | uint32_t bitmap[NFS_ATTR_BITMAP_LEN2], comp, comp2; | |||
| 2108 | fhandle_t fh, dirfh; | |||
| 2109 | struct nfs_vattr nvattr; | |||
| 2110 | u_int64_t xid; | |||
| 2111 | struct nfsreq rq, *req = &rq; | |||
| 2112 | struct nfsreq_secinfo_args si; | |||
| 2113 | struct nfs_sec sec; | |||
| 2114 | struct nfs_fs_locations nfsls; | |||
| 2115 | ||||
| 2116 | *npp = NULL((void *)0); | |||
| 2117 | fh.fh_len = dirfh.fh_len = 0; | |||
| 2118 | TAILQ_INIT(&nmp->nm_open_owners)do { (((&nmp->nm_open_owners))->tqh_first) = ((void *)0); (&nmp->nm_open_owners)->tqh_last = &(((& nmp->nm_open_owners))->tqh_first); ; } while (0); | |||
| 2119 | TAILQ_INIT(&nmp->nm_delegations)do { (((&nmp->nm_un.v4.delegations))->tqh_first) = ( (void *)0); (&nmp->nm_un.v4.delegations)->tqh_last = &(((&nmp->nm_un.v4.delegations))->tqh_first); ; } while (0); | |||
| 2120 | TAILQ_INIT(&nmp->nm_dreturnq)do { (((&nmp->nm_un.v4.dreturnq))->tqh_first) = ((void *)0); (&nmp->nm_un.v4.dreturnq)->tqh_last = &( ((&nmp->nm_un.v4.dreturnq))->tqh_first); ; } while ( 0); | |||
| 2121 | nmp->nm_stategenid = 1; | |||
| 2122 | NVATTR_INIT(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); (& nvattr)->nva_flags = 0; (&nvattr)->nva_acl = ((void *)0); } while (0); | |||
| 2123 | bzero(&nfsls, sizeof(nfsls)); | |||
| 2124 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 2125 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 2126 | ||||
| 2127 | /* | |||
| 2128 | * If no security flavors were specified we'll want to default to the server's | |||
| 2129 | * preferred flavor. For NFSv4.0 we need a file handle and name to get that via | |||
| 2130 | * SECINFO, so we'll do that on the last component of the server path we are | |||
| 2131 | * mounting. If we are mounting the server's root, we'll need to defer the | |||
| 2132 | * SECINFO call to the first successful LOOKUP request. | |||
| 2133 | */ | |||
| 2134 | if (!nmp->nm_sec.count) | |||
| 2135 | nmp->nm_state |= NFSSTA_NEEDSECINFO0x00000200; | |||
| 2136 | ||||
| 2137 | /* make a copy of the current location's path */ | |||
| 2138 | nfsp = &nmp->nm_locations.nl_locations[nmp->nm_locations.nl_current.nli_loc]->nl_path; | |||
| 2139 | bzero(&fspath, sizeof(fspath)); | |||
| 2140 | fspath.np_compcount = nfsp->np_compcount; | |||
| 2141 | if (fspath.np_compcount > 0) { | |||
| 2142 | MALLOC(fspath.np_components, char **, fspath.np_compcount*sizeof(char*), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fspath.np_components) = (char **)__MALLOC(fspath.np_compcount *sizeof(char*), 80, 0x0000|0x0004, &site); }); | |||
| 2143 | if (!fspath.np_components) { | |||
| 2144 | error = ENOMEM12; | |||
| 2145 | goto nfsmout; | |||
| 2146 | } | |||
| 2147 | for (comp=0; comp < nfsp->np_compcount; comp++) { | |||
| 2148 | int slen = strlen(nfsp->np_components[comp]); | |||
| 2149 | MALLOC(fspath.np_components[comp], char *, slen+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fspath.np_components[comp]) = (char *)__MALLOC(slen+1, 80 , 0x0000|0x0004, &site); }); | |||
| 2150 | if (!fspath.np_components[comp]) { | |||
| 2151 | error = ENOMEM12; | |||
| 2152 | break; | |||
| 2153 | } | |||
| 2154 | strlcpy(fspath.np_components[comp], nfsp->np_components[comp], slen+1); | |||
| 2155 | } | |||
| 2156 | if (error) | |||
| 2157 | goto nfsmout; | |||
| 2158 | } | |||
| 2159 | ||||
| 2160 | /* for mirror mounts, we can just use the file handle passed in */ | |||
| 2161 | if (nmp->nm_fh) { | |||
| 2162 | dirfh.fh_len = nmp->nm_fh->fh_len; | |||
| 2163 | bcopy(nmp->nm_fh->fh_data, dirfh.fh_data, dirfh.fh_len); | |||
| 2164 | NFSREQ_SECINFO_SET(&si, NULL, dirfh.fh_data, dirfh.fh_len, NULL, 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (dirfh.fh_data); (&si)->rsia_fhsize = (dirfh.fh_len ); (&si)->rsia_name = (((void *)0)); (&si)->rsia_namelen = (0); } while (0); | |||
| 2165 | goto gotfh; | |||
| 2166 | } | |||
| 2167 | ||||
| 2168 | /* otherwise, we need to get the fh for the directory we are mounting */ | |||
| 2169 | ||||
| 2170 | /* if no components, just get root */ | |||
| 2171 | if (fspath.np_compcount == 0) { | |||
| 2172 | nocomponents: | |||
| 2173 | // PUTROOTFH + GETATTR(FH) | |||
| 2174 | NFSREQ_SECINFO_SET(&si, NULL, NULL, 0, NULL, 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (((void *)0)); (&si)->rsia_fhsize = (0); (&si)-> rsia_name = (((void *)0)); (&si)->rsia_namelen = (0); } while (0); | |||
| 2175 | numops = 2; | |||
| 2176 | nfsm_chain_build_alloc_init(error, &nmreq, 9 * NFSX_UNSIGNED)do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((9 * 4)) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget( MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 2177 | nfsm_chain_add_compound_header(error, &nmreq, "mount", nmp->nm_minor_vers, numops)do { if (("mount") && strlen("mount")) { char __nfstag [12 +1]; snprintf(__nfstag, sizeof(__nfstag), "%-*s", 12, ("mount" )); do { do { if (((error))) break; if ((((&nmreq)))-> nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((& nmreq))), (4)); if (!(((error))) && ((((&nmreq))) ->nmc_left < (4))) (((error))) = 12; } } while (0); if ( (error)) break; *((uint32_t*)((&nmreq))->nmc_ptr) = (( __builtin_constant_p((uint32_t)(12)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(12)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(12)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(12)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(12)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(12)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq ))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((( 12)+3)&(~0x3)); if ((error)) break; if (((&nmreq))-> nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(( (&nmreq)), (const u_char*)(__nfstag), (12)); break; } *(( (uint32_t*)(((&nmreq))->nmc_ptr))+((((((12))+3)&(~ 0x3))>>2)-1)) = 0; bcopy((__nfstag), ((&nmreq))-> nmc_ptr, (12)); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } else { do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), ( 4)); if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break ; *((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); } do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((nmp->nm_minor_vers) )) ? ((__uint32_t)((((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((nmp->nm_minor_vers))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((nmp->nm_minor_vers))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((nmp->nm_minor_vers))))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((numops))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((numops))) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)((numops))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((numops))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numops))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numops))))); ((&nmreq))->nmc_ptr += 4; (( &nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 2178 | numops--; | |||
| 2179 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTROOTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(24)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(24)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(24)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(24)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(24)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(24)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2180 | numops--; | |||
| 2181 | nfsm_chain_add_32(error, &nmreq, NFS_OP_GETATTR)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(9)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(9)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(9)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(9)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(9)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(9)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2182 | NFS_CLEAR_ATTRIBUTES(bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( bitmap)))[__i] = 0; } while (0); | |||
| 2183 | NFS4_DEFAULT_ATTRIBUTES(bitmap)do { (((uint32_t *)((bitmap)))[(0)/32] |= 1<<((0)%32)); (((uint32_t *)((bitmap)))[(1)/32] |= 1<<((1)%32)); ((( uint32_t *)((bitmap)))[(2)/32] |= 1<<((2)%32)); (((uint32_t *)((bitmap)))[(3)/32] |= 1<<((3)%32)); (((uint32_t *)( (bitmap)))[(4)/32] |= 1<<((4)%32)); (((uint32_t *)((bitmap )))[(5)/32] |= 1<<((5)%32)); (((uint32_t *)((bitmap)))[ (6)/32] |= 1<<((6)%32)); (((uint32_t *)((bitmap)))[(7)/ 32] |= 1<<((7)%32)); (((uint32_t *)((bitmap)))[(8)/32] |= 1<<((8)%32)); (((uint32_t *)((bitmap)))[(9)/32] |= 1<< ((9)%32)); (((uint32_t *)((bitmap)))[(10)/32] |= 1<<((10 )%32)); (((uint32_t *)((bitmap)))[(13)/32] |= 1<<((13)% 32)); (((uint32_t *)((bitmap)))[(14)/32] |= 1<<((14)%32 )); (((uint32_t *)((bitmap)))[(16)/32] |= 1<<((16)%32)) ; (((uint32_t *)((bitmap)))[(17)/32] |= 1<<((17)%32)); ( ((uint32_t *)((bitmap)))[(18)/32] |= 1<<((18)%32)); ((( uint32_t *)((bitmap)))[(20)/32] |= 1<<((20)%32)); (((uint32_t *)((bitmap)))[(21)/32] |= 1<<((21)%32)); (((uint32_t * )((bitmap)))[(22)/32] |= 1<<((22)%32)); (((uint32_t *)( (bitmap)))[(23)/32] |= 1<<((23)%32)); (((uint32_t *)((bitmap )))[(25)/32] |= 1<<((25)%32)); (((uint32_t *)((bitmap)) )[(26)/32] |= 1<<((26)%32)); (((uint32_t *)((bitmap)))[ (27)/32] |= 1<<((27)%32)); (((uint32_t *)((bitmap)))[(28 )/32] |= 1<<((28)%32)); (((uint32_t *)((bitmap)))[(29)/ 32] |= 1<<((29)%32)); (((uint32_t *)((bitmap)))[(30)/32 ] |= 1<<((30)%32)); (((uint32_t *)((bitmap)))[(31)/32] |= 1<<((31)%32)); (((uint32_t *)((bitmap)))[(33)/32] |= 1 <<((33)%32)); (((uint32_t *)((bitmap)))[(34)/32] |= 1<< ((34)%32)); (((uint32_t *)((bitmap)))[(35)/32] |= 1<<(( 35)%32)); (((uint32_t *)((bitmap)))[(36)/32] |= 1<<((36 )%32)); (((uint32_t *)((bitmap)))[(37)/32] |= 1<<((37)% 32)); (((uint32_t *)((bitmap)))[(41)/32] |= 1<<((41)%32 )); (((uint32_t *)((bitmap)))[(42)/32] |= 1<<((42)%32)) ; (((uint32_t *)((bitmap)))[(43)/32] |= 1<<((43)%32)); ( ((uint32_t *)((bitmap)))[(44)/32] |= 1<<((44)%32)); ((( uint32_t *)((bitmap)))[(45)/32] |= 1<<((45)%32)); (((uint32_t *)((bitmap)))[(47)/32] |= 1<<((47)%32)); (((uint32_t * )((bitmap)))[(49)/32] |= 1<<((49)%32)); (((uint32_t *)( (bitmap)))[(50)/32] |= 1<<((50)%32)); (((uint32_t *)((bitmap )))[(52)/32] |= 1<<((52)%32)); (((uint32_t *)((bitmap)) )[(53)/32] |= 1<<((53)%32)); (((uint32_t *)((bitmap)))[ (55)/32] |= 1<<((55)%32)); } while (0); | |||
| 2184 | NFS_BITMAP_SET(bitmap, NFS_FATTR_FILEHANDLE)(((uint32_t *)(bitmap))[(19)/32] |= 1<<((19)%32)); | |||
| 2185 | nfsm_chain_add_bitmap(error, &nmreq, bitmap, NFS_ATTR_BITMAP_LEN)do { int __i; do { do { if (((error))) break; if ((((&nmreq )))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((2))) ? ((__uint32_t)(( ((__uint32_t)((uint32_t)((2))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((2))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((2))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((2))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((2))))); ((&nmreq))-> nmc_ptr += 4; ((&nmreq))->nmc_left -= 4; } while (0); for (__i=0; __i < (2); __i++) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((bitmap)[__i])) ? ((__uint32_t )((((__uint32_t)((uint32_t)((bitmap)[__i])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((bitmap)[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((bitmap) [__i])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((bitmap)[__i])) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((bitmap)[__i])))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 2186 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 2187 | nfsm_assert(error, (numops == 0), EPROTO)do { if (error) break; if (!((numops == 0))) (error) = (100); } while (0); | |||
| 2188 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2189 | error = nfs_request_async(NULL((void *)0), nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND1, | |||
| 2190 | vfs_context_thread(ctx), vfs_context_ucred(ctx), &si, 0, NULL((void *)0), &req); | |||
| 2191 | if (!error) | |||
| 2192 | error = nfs_request_async_finish(req, &nmrep, &xid, &status); | |||
| 2193 | nfsm_chain_skip_tag(error, &nmrep)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (((&nmrep))->nmc_left >= (uint32_t)((((__val)+3)&(~0x3)))) { ((&nmrep)) ->nmc_left -= ((((__val)+3)&(~0x3))); ((&nmrep))-> nmc_ptr += ((((__val)+3)&(~0x3))); } else { ((error)) = nfsm_chain_advance (((&nmrep)), ((((__val)+3)&(~0x3)))); } } while (0); } while (0); | |||
| 2194 | nfsm_chain_get_32(error, &nmrep, numops)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (numops ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 2195 | nfsm_chain_op_check(error, &nmrep, NFS_OP_PUTROOTFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (24)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2196 | nfsm_chain_op_check(error, &nmrep, NFS_OP_GETATTR)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (9)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2197 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2198 | NFS_CLEAR_ATTRIBUTES(nmp->nm_fsattr.nfsa_bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( nmp->nm_fsattr.nfsa_bitmap)))[__i] = 0; } while (0); | |||
| 2199 | error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, &dirfh, NULL((void *)0), NULL((void *)0)); | |||
| 2200 | if (!error && !NFS_BITMAP_ISSET(&nvattr.nva_bitmap, NFS_FATTR_FILEHANDLE)(((uint32_t *)(&nvattr.nva_bitmap))[(19)/32] & (1<< ((19)%32)))) { | |||
| 2201 | printf("nfs: mount didn't return filehandle?\n"); | |||
| 2202 | error = EBADRPC72; | |||
| 2203 | } | |||
| 2204 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2205 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 2206 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 2207 | NVATTR_CLEANUP(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); if ((&nvattr)->nva_acl) { kauth_acl_free((&nvattr)-> nva_acl); (&nvattr)->nva_acl = ((void *)0); } } while ( 0); | |||
| 2208 | goto gotfh; | |||
| 2209 | } | |||
| 2210 | ||||
| 2211 | /* look up each path component */ | |||
| 2212 | for (comp=0; comp < fspath.np_compcount; ) { | |||
| 2213 | isdotdot = 0; | |||
| 2214 | if (fspath.np_components[comp][0] == '.') { | |||
| 2215 | if (fspath.np_components[comp][1] == '\0') { | |||
| 2216 | /* skip "." */ | |||
| 2217 | comp++; | |||
| 2218 | continue; | |||
| 2219 | } | |||
| 2220 | /* treat ".." specially */ | |||
| 2221 | if ((fspath.np_components[comp][1] == '.') && | |||
| 2222 | (fspath.np_components[comp][2] == '\0')) | |||
| 2223 | isdotdot = 1; | |||
| 2224 | if (isdotdot && (dirfh.fh_len == 0)) { | |||
| 2225 | /* ".." in root directory is same as "." */ | |||
| 2226 | comp++; | |||
| 2227 | continue; | |||
| 2228 | } | |||
| 2229 | } | |||
| 2230 | // PUT(ROOT)FH + LOOKUP(P) + GETFH + GETATTR | |||
| 2231 | if (dirfh.fh_len == 0) | |||
| 2232 | NFSREQ_SECINFO_SET(&si, NULL, NULL, 0, isdotdot ? NULL : fspath.np_components[comp], 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (((void *)0)); (&si)->rsia_fhsize = (0); (&si)-> rsia_name = (isdotdot ? ((void *)0) : fspath.np_components[comp ]); (&si)->rsia_namelen = (0); } while (0); | |||
| 2233 | else | |||
| 2234 | NFSREQ_SECINFO_SET(&si, NULL, dirfh.fh_data, dirfh.fh_len, isdotdot ? NULL : fspath.np_components[comp], 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (dirfh.fh_data); (&si)->rsia_fhsize = (dirfh.fh_len ); (&si)->rsia_name = (isdotdot ? ((void *)0) : fspath .np_components[comp]); (&si)->rsia_namelen = (0); } while (0); | |||
| 2235 | numops = 4; | |||
| 2236 | nfsm_chain_build_alloc_init(error, &nmreq, 18 * NFSX_UNSIGNED)do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((18 * 4)) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget (MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 2237 | nfsm_chain_add_compound_header(error, &nmreq, "mount", nmp->nm_minor_vers, numops)do { if (("mount") && strlen("mount")) { char __nfstag [12 +1]; snprintf(__nfstag, sizeof(__nfstag), "%-*s", 12, ("mount" )); do { do { if (((error))) break; if ((((&nmreq)))-> nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((& nmreq))), (4)); if (!(((error))) && ((((&nmreq))) ->nmc_left < (4))) (((error))) = 12; } } while (0); if ( (error)) break; *((uint32_t*)((&nmreq))->nmc_ptr) = (( __builtin_constant_p((uint32_t)(12)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(12)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(12)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(12)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(12)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(12)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq ))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((( 12)+3)&(~0x3)); if ((error)) break; if (((&nmreq))-> nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(( (&nmreq)), (const u_char*)(__nfstag), (12)); break; } *(( (uint32_t*)(((&nmreq))->nmc_ptr))+((((((12))+3)&(~ 0x3))>>2)-1)) = 0; bcopy((__nfstag), ((&nmreq))-> nmc_ptr, (12)); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } else { do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), ( 4)); if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break ; *((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); } do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((nmp->nm_minor_vers) )) ? ((__uint32_t)((((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((nmp->nm_minor_vers))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((nmp->nm_minor_vers))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((nmp->nm_minor_vers))))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((numops))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((numops))) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)((numops))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((numops))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numops))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numops))))); ((&nmreq))->nmc_ptr += 4; (( &nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 2238 | numops--; | |||
| 2239 | if (dirfh.fh_len) { | |||
| 2240 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(22)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(22)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(22)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(22)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(22)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(22)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2241 | nfsm_chain_add_fh(error, &nmreq, NFS_VER4, dirfh.fh_data, dirfh.fh_len)do { if (error) break; if ((4) != 2) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error ))) = nfsm_chain_new_mbuf((((&nmreq))), (4)); if (!(((error ))) && ((((&nmreq)))->nmc_left < (4))) (((error ))) = 12; } } while (0); if ((error)) break; *((uint32_t*)((& nmreq))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((dirfh .fh_len))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((dirfh.fh_len ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((dirfh.fh_len))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((dirfh.fh_len))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((dirfh.fh_len))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((dirfh.fh_len))))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((dirfh.fh_len)) +3)&(~0x3)); if ((error)) break; if (((&nmreq))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(((&nmreq )), (const u_char*)((dirfh.fh_data)), ((dirfh.fh_len))); break ; } *(((uint32_t*)(((&nmreq))->nmc_ptr))+(((((((dirfh. fh_len)))+3)&(~0x3))>>2)-1)) = 0; bcopy(((dirfh.fh_data )), ((&nmreq))->nmc_ptr, ((dirfh.fh_len))); ((&nmreq ))->nmc_ptr += rndlen; ((&nmreq))->nmc_left -= rndlen ; } while (0); } while (0); | |||
| 2242 | } else { | |||
| 2243 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTROOTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(24)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(24)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(24)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(24)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(24)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(24)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2244 | } | |||
| 2245 | numops--; | |||
| 2246 | if (isdotdot) { | |||
| 2247 | nfsm_chain_add_32(error, &nmreq, NFS_OP_LOOKUPP)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(16)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(16)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(16)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(16)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(16)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(16)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2248 | } else { | |||
| 2249 | nfsm_chain_add_32(error, &nmreq, NFS_OP_LOOKUP)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(15)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(15)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(15)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(15)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(15)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(15)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2250 | nfsm_chain_add_name(error, &nmreq,do { if (error) break; if ((((uint32_t *)(((nmp))->nm_flags ))[(14)/32] & (1<<((14)%32)))) (error) = nfsm_chain_add_string_nfc ((&nmreq), (const uint8_t*)(fspath.np_components[comp]), ( strlen(fspath.np_components[comp]))); else do { do { do { if ( (((error)))) break; if (((((&nmreq))))->nmc_left < ( 4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq)))), (4)); if (!((((error)))) && (((((&nmreq))))-> nmc_left < (4))) ((((error)))) = 12; } } while (0); if ((( error))) break; *((uint32_t*)(((&nmreq)))->nmc_ptr) = ( (__builtin_constant_p((uint32_t)(((strlen(fspath.np_components [comp]))))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(((strlen (fspath.np_components[comp]))))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)(((strlen(fspath.np_components[comp ]))))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(((strlen(fspath.np_components[comp]))))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((strlen(fspath.np_components [comp]))))) & 0x000000ff) << 24))) : _OSSwapInt32(( uint32_t)(((strlen(fspath.np_components[comp]))))))); (((& nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4 ; } while (0); do { uint32_t rndlen = (((((strlen(fspath.np_components [comp]))))+3)&(~0x3)); if (((error))) break; if ((((& nmreq)))->nmc_left < rndlen) { (((error))) = nfsm_chain_add_opaque_f ((((&nmreq))), (const u_char*)(((fspath.np_components[comp ]))), (((strlen(fspath.np_components[comp]))))); break; } *(( (uint32_t*)((((&nmreq)))->nmc_ptr))+((((((((strlen(fspath .np_components[comp])))))+3)&(~0x3))>>2)-1)) = 0; bcopy ((((fspath.np_components[comp]))), (((&nmreq)))->nmc_ptr , (((strlen(fspath.np_components[comp]))))); (((&nmreq))) ->nmc_ptr += rndlen; (((&nmreq)))->nmc_left -= rndlen ; } while (0); } while (0); } while (0) | |||
| 2251 | fspath.np_components[comp], strlen(fspath.np_components[comp]), nmp)do { if (error) break; if ((((uint32_t *)(((nmp))->nm_flags ))[(14)/32] & (1<<((14)%32)))) (error) = nfsm_chain_add_string_nfc ((&nmreq), (const uint8_t*)(fspath.np_components[comp]), ( strlen(fspath.np_components[comp]))); else do { do { do { if ( (((error)))) break; if (((((&nmreq))))->nmc_left < ( 4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq)))), (4)); if (!((((error)))) && (((((&nmreq))))-> nmc_left < (4))) ((((error)))) = 12; } } while (0); if ((( error))) break; *((uint32_t*)(((&nmreq)))->nmc_ptr) = ( (__builtin_constant_p((uint32_t)(((strlen(fspath.np_components [comp]))))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(((strlen (fspath.np_components[comp]))))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)(((strlen(fspath.np_components[comp ]))))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(((strlen(fspath.np_components[comp]))))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((strlen(fspath.np_components [comp]))))) & 0x000000ff) << 24))) : _OSSwapInt32(( uint32_t)(((strlen(fspath.np_components[comp]))))))); (((& nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4 ; } while (0); do { uint32_t rndlen = (((((strlen(fspath.np_components [comp]))))+3)&(~0x3)); if (((error))) break; if ((((& nmreq)))->nmc_left < rndlen) { (((error))) = nfsm_chain_add_opaque_f ((((&nmreq))), (const u_char*)(((fspath.np_components[comp ]))), (((strlen(fspath.np_components[comp]))))); break; } *(( (uint32_t*)((((&nmreq)))->nmc_ptr))+((((((((strlen(fspath .np_components[comp])))))+3)&(~0x3))>>2)-1)) = 0; bcopy ((((fspath.np_components[comp]))), (((&nmreq)))->nmc_ptr , (((strlen(fspath.np_components[comp]))))); (((&nmreq))) ->nmc_ptr += rndlen; (((&nmreq)))->nmc_left -= rndlen ; } while (0); } while (0); } while (0); | |||
| 2252 | } | |||
| 2253 | numops--; | |||
| 2254 | nfsm_chain_add_32(error, &nmreq, NFS_OP_GETFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(10)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(10)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(10)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(10)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(10)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(10)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2255 | numops--; | |||
| 2256 | nfsm_chain_add_32(error, &nmreq, NFS_OP_GETATTR)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(9)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(9)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(9)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(9)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(9)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(9)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2257 | NFS_CLEAR_ATTRIBUTES(bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( bitmap)))[__i] = 0; } while (0); | |||
| 2258 | NFS4_DEFAULT_ATTRIBUTES(bitmap)do { (((uint32_t *)((bitmap)))[(0)/32] |= 1<<((0)%32)); (((uint32_t *)((bitmap)))[(1)/32] |= 1<<((1)%32)); ((( uint32_t *)((bitmap)))[(2)/32] |= 1<<((2)%32)); (((uint32_t *)((bitmap)))[(3)/32] |= 1<<((3)%32)); (((uint32_t *)( (bitmap)))[(4)/32] |= 1<<((4)%32)); (((uint32_t *)((bitmap )))[(5)/32] |= 1<<((5)%32)); (((uint32_t *)((bitmap)))[ (6)/32] |= 1<<((6)%32)); (((uint32_t *)((bitmap)))[(7)/ 32] |= 1<<((7)%32)); (((uint32_t *)((bitmap)))[(8)/32] |= 1<<((8)%32)); (((uint32_t *)((bitmap)))[(9)/32] |= 1<< ((9)%32)); (((uint32_t *)((bitmap)))[(10)/32] |= 1<<((10 )%32)); (((uint32_t *)((bitmap)))[(13)/32] |= 1<<((13)% 32)); (((uint32_t *)((bitmap)))[(14)/32] |= 1<<((14)%32 )); (((uint32_t *)((bitmap)))[(16)/32] |= 1<<((16)%32)) ; (((uint32_t *)((bitmap)))[(17)/32] |= 1<<((17)%32)); ( ((uint32_t *)((bitmap)))[(18)/32] |= 1<<((18)%32)); ((( uint32_t *)((bitmap)))[(20)/32] |= 1<<((20)%32)); (((uint32_t *)((bitmap)))[(21)/32] |= 1<<((21)%32)); (((uint32_t * )((bitmap)))[(22)/32] |= 1<<((22)%32)); (((uint32_t *)( (bitmap)))[(23)/32] |= 1<<((23)%32)); (((uint32_t *)((bitmap )))[(25)/32] |= 1<<((25)%32)); (((uint32_t *)((bitmap)) )[(26)/32] |= 1<<((26)%32)); (((uint32_t *)((bitmap)))[ (27)/32] |= 1<<((27)%32)); (((uint32_t *)((bitmap)))[(28 )/32] |= 1<<((28)%32)); (((uint32_t *)((bitmap)))[(29)/ 32] |= 1<<((29)%32)); (((uint32_t *)((bitmap)))[(30)/32 ] |= 1<<((30)%32)); (((uint32_t *)((bitmap)))[(31)/32] |= 1<<((31)%32)); (((uint32_t *)((bitmap)))[(33)/32] |= 1 <<((33)%32)); (((uint32_t *)((bitmap)))[(34)/32] |= 1<< ((34)%32)); (((uint32_t *)((bitmap)))[(35)/32] |= 1<<(( 35)%32)); (((uint32_t *)((bitmap)))[(36)/32] |= 1<<((36 )%32)); (((uint32_t *)((bitmap)))[(37)/32] |= 1<<((37)% 32)); (((uint32_t *)((bitmap)))[(41)/32] |= 1<<((41)%32 )); (((uint32_t *)((bitmap)))[(42)/32] |= 1<<((42)%32)) ; (((uint32_t *)((bitmap)))[(43)/32] |= 1<<((43)%32)); ( ((uint32_t *)((bitmap)))[(44)/32] |= 1<<((44)%32)); ((( uint32_t *)((bitmap)))[(45)/32] |= 1<<((45)%32)); (((uint32_t *)((bitmap)))[(47)/32] |= 1<<((47)%32)); (((uint32_t * )((bitmap)))[(49)/32] |= 1<<((49)%32)); (((uint32_t *)( (bitmap)))[(50)/32] |= 1<<((50)%32)); (((uint32_t *)((bitmap )))[(52)/32] |= 1<<((52)%32)); (((uint32_t *)((bitmap)) )[(53)/32] |= 1<<((53)%32)); (((uint32_t *)((bitmap)))[ (55)/32] |= 1<<((55)%32)); } while (0); | |||
| 2259 | /* if no namedattr support or component is ".zfs", clear NFS_FATTR_NAMED_ATTR */ | |||
| 2260 | if (NMFLAG(nmp, NONAMEDATTR)(((uint32_t *)((nmp)->nm_flags))[(11)/32] & (1<< ((11)%32))) || !strcmp(fspath.np_components[comp], ".zfs")) | |||
| 2261 | NFS_BITMAP_CLR(bitmap, NFS_FATTR_NAMED_ATTR)(((uint32_t *)(bitmap))[(7)/32] &= ~(1<<((7)%32))); | |||
| 2262 | nfsm_chain_add_bitmap(error, &nmreq, bitmap, NFS_ATTR_BITMAP_LEN)do { int __i; do { do { if (((error))) break; if ((((&nmreq )))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((2))) ? ((__uint32_t)(( ((__uint32_t)((uint32_t)((2))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((2))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((2))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((2))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((2))))); ((&nmreq))-> nmc_ptr += 4; ((&nmreq))->nmc_left -= 4; } while (0); for (__i=0; __i < (2); __i++) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((bitmap)[__i])) ? ((__uint32_t )((((__uint32_t)((uint32_t)((bitmap)[__i])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((bitmap)[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((bitmap) [__i])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((bitmap)[__i])) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((bitmap)[__i])))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 2263 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 2264 | nfsm_assert(error, (numops == 0), EPROTO)do { if (error) break; if (!((numops == 0))) (error) = (100); } while (0); | |||
| 2265 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2266 | error = nfs_request_async(NULL((void *)0), nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND1, | |||
| 2267 | vfs_context_thread(ctx), vfs_context_ucred(ctx), &si, 0, NULL((void *)0), &req); | |||
| 2268 | if (!error) | |||
| 2269 | error = nfs_request_async_finish(req, &nmrep, &xid, &status); | |||
| 2270 | nfsm_chain_skip_tag(error, &nmrep)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (((&nmrep))->nmc_left >= (uint32_t)((((__val)+3)&(~0x3)))) { ((&nmrep)) ->nmc_left -= ((((__val)+3)&(~0x3))); ((&nmrep))-> nmc_ptr += ((((__val)+3)&(~0x3))); } else { ((error)) = nfsm_chain_advance (((&nmrep)), ((((__val)+3)&(~0x3)))); } } while (0); } while (0); | |||
| 2271 | nfsm_chain_get_32(error, &nmrep, numops)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (numops ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 2272 | nfsm_chain_op_check(error, &nmrep, dirfh.fh_len ? NFS_OP_PUTFH : NFS_OP_PUTROOTFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (dirfh.fh_len ? 22 : 24)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t *)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4 ; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32 ; ((error)) = nfsm_chain_get_opaque_f(((&nmrep)), 4, (u_char *)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p ((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t) ((uint32_t)(*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2273 | nfsm_chain_op_check(error, &nmrep, isdotdot ? NFS_OP_LOOKUPP : NFS_OP_LOOKUP)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (isdotdot ? 16 : 15)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if ((( &nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)(( &nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ( (&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32 ; ((error)) = nfsm_chain_get_opaque_f(((&nmrep)), 4, (u_char *)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p ((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t) ((uint32_t)(*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2274 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2275 | nfsm_chain_op_check(error, &nmrep, NFS_OP_GETFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (10)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2276 | nfsm_chain_get_32(error, &nmrep, fh.fh_len)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (fh .fh_len) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 2277 | nfsm_chain_get_opaque(error, &nmrep, fh.fh_len, fh.fh_data)do { uint32_t rndlen; if (error) break; rndlen = (((fh.fh_len )+3)&(~0x3)); if ((&nmrep)->nmc_left >= rndlen) { u_char *__tmpptr = (u_char*)(&nmrep)->nmc_ptr; (& nmrep)->nmc_left -= rndlen; (&nmrep)->nmc_ptr += rndlen ; bcopy(__tmpptr, (fh.fh_data), (fh.fh_len)); } else { (error ) = nfsm_chain_get_opaque_f((&nmrep), (fh.fh_len), (u_char *)(fh.fh_data)); } } while (0); | |||
| 2278 | nfsm_chain_op_check(error, &nmrep, NFS_OP_GETATTR)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (9)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2279 | if (!error) { | |||
| 2280 | NFS_CLEAR_ATTRIBUTES(nmp->nm_fsattr.nfsa_bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( nmp->nm_fsattr.nfsa_bitmap)))[__i] = 0; } while (0); | |||
| 2281 | error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, NULL((void *)0), NULL((void *)0), &nfsls); | |||
| 2282 | } | |||
| 2283 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 2284 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 2285 | if (error) { | |||
| 2286 | /* LOOKUP succeeded but GETATTR failed? This could be a referral. */ | |||
| 2287 | /* Try the lookup again with a getattr for fs_locations. */ | |||
| 2288 | nfs_fs_locations_cleanup(&nfsls); | |||
| 2289 | error = nfs4_get_fs_locations(nmp, NULL((void *)0), dirfh.fh_data, dirfh.fh_len, fspath.np_components[comp], ctx, &nfsls); | |||
| 2290 | if (!error && (nfsls.nl_numlocs < 1)) | |||
| 2291 | error = ENOENT2; | |||
| 2292 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2293 | if (++loopcnt > MAXSYMLINKS32) { | |||
| 2294 | /* too many symlink/referral redirections */ | |||
| 2295 | error = ELOOP62; | |||
| 2296 | goto nfsmout; | |||
| 2297 | } | |||
| 2298 | /* tear down the current connection */ | |||
| 2299 | nfs_disconnect(nmp); | |||
| 2300 | /* replace fs locations */ | |||
| 2301 | nfs_fs_locations_cleanup(&nmp->nm_locations); | |||
| 2302 | nmp->nm_locations = nfsls; | |||
| 2303 | bzero(&nfsls, sizeof(nfsls)); | |||
| 2304 | /* initiate a connection using the new fs locations */ | |||
| 2305 | error = nfs_mount_connect(nmp); | |||
| 2306 | if (!error && !(nmp->nm_locations.nl_current.nli_flags & NLI_VALID0x01)) | |||
| 2307 | error = EIO5; | |||
| 2308 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2309 | /* add new server's remote path to beginning of our path and continue */ | |||
| 2310 | nfsp = &nmp->nm_locations.nl_locations[nmp->nm_locations.nl_current.nli_loc]->nl_path; | |||
| 2311 | bzero(&fspath2, sizeof(fspath2)); | |||
| 2312 | fspath2.np_compcount = (fspath.np_compcount - comp - 1) + nfsp->np_compcount; | |||
| 2313 | if (fspath2.np_compcount > 0) { | |||
| 2314 | MALLOC(fspath2.np_components, char **, fspath2.np_compcount*sizeof(char*), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fspath2.np_components) = (char **)__MALLOC(fspath2.np_compcount *sizeof(char*), 80, 0x0000|0x0004, &site); }); | |||
| 2315 | if (!fspath2.np_components) { | |||
| 2316 | error = ENOMEM12; | |||
| 2317 | goto nfsmout; | |||
| 2318 | } | |||
| 2319 | for (comp2=0; comp2 < nfsp->np_compcount; comp2++) { | |||
| 2320 | int slen = strlen(nfsp->np_components[comp2]); | |||
| 2321 | MALLOC(fspath2.np_components[comp2], char *, slen+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fspath2.np_components[comp2]) = (char *)__MALLOC(slen+1 , 80, 0x0000|0x0004, &site); }); | |||
| 2322 | if (!fspath2.np_components[comp2]) { | |||
| 2323 | /* clean up fspath2, then error out */ | |||
| 2324 | while (comp2 > 0) { | |||
| 2325 | comp2--; | |||
| 2326 | FREE(fspath2.np_components[comp2], M_TEMP)_FREE((void *)fspath2.np_components[comp2], 80); | |||
| 2327 | } | |||
| 2328 | FREE(fspath2.np_components, M_TEMP)_FREE((void *)fspath2.np_components, 80); | |||
| 2329 | error = ENOMEM12; | |||
| 2330 | goto nfsmout; | |||
| 2331 | } | |||
| 2332 | strlcpy(fspath2.np_components[comp2], nfsp->np_components[comp2], slen+1); | |||
| 2333 | } | |||
| 2334 | if ((fspath.np_compcount - comp - 1) > 0) | |||
| 2335 | bcopy(&fspath.np_components[comp+1], &fspath2.np_components[nfsp->np_compcount], (fspath.np_compcount - comp - 1)*sizeof(char*)); | |||
| 2336 | /* free up unused parts of old path (prior components and component array) */ | |||
| 2337 | do { | |||
| 2338 | FREE(fspath.np_components[comp], M_TEMP)_FREE((void *)fspath.np_components[comp], 80); | |||
| 2339 | } while (comp-- > 0); | |||
| 2340 | FREE(fspath.np_components, M_TEMP)_FREE((void *)fspath.np_components, 80); | |||
| 2341 | /* put new path in place */ | |||
| 2342 | fspath = fspath2; | |||
| 2343 | } | |||
| 2344 | /* reset dirfh and component index */ | |||
| 2345 | dirfh.fh_len = 0; | |||
| 2346 | comp = 0; | |||
| 2347 | NVATTR_CLEANUP(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); if ((&nvattr)->nva_acl) { kauth_acl_free((&nvattr)-> nva_acl); (&nvattr)->nva_acl = ((void *)0); } } while ( 0); | |||
| 2348 | if (fspath.np_compcount == 0) | |||
| 2349 | goto nocomponents; | |||
| 2350 | continue; | |||
| 2351 | } | |||
| 2352 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2353 | /* if file handle is for a symlink, then update the path with the symlink contents */ | |||
| 2354 | if (NFS_BITMAP_ISSET(&nvattr.nva_bitmap, NFS_FATTR_TYPE)(((uint32_t *)(&nvattr.nva_bitmap))[(1)/32] & (1<< ((1)%32))) && (nvattr.nva_type == VLNK)) { | |||
| 2355 | if (++loopcnt > MAXSYMLINKS32) | |||
| 2356 | error = ELOOP62; | |||
| 2357 | else | |||
| 2358 | error = nfs4_mount_update_path_with_symlink(nmp, &fspath, comp, &dirfh, &depth, &fh, ctx); | |||
| 2359 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2360 | /* directory file handle is either left the same or reset to root (if link was absolute) */ | |||
| 2361 | /* path traversal starts at beginning of the path again */ | |||
| 2362 | comp = 0; | |||
| 2363 | NVATTR_CLEANUP(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); if ((&nvattr)->nva_acl) { kauth_acl_free((&nvattr)-> nva_acl); (&nvattr)->nva_acl = ((void *)0); } } while ( 0); | |||
| 2364 | nfs_fs_locations_cleanup(&nfsls); | |||
| 2365 | continue; | |||
| 2366 | } | |||
| 2367 | NVATTR_CLEANUP(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); if ((&nvattr)->nva_acl) { kauth_acl_free((&nvattr)-> nva_acl); (&nvattr)->nva_acl = ((void *)0); } } while ( 0); | |||
| 2368 | nfs_fs_locations_cleanup(&nfsls); | |||
| 2369 | /* not a symlink... */ | |||
| 2370 | if ((nmp->nm_state & NFSSTA_NEEDSECINFO0x00000200) && (comp == (fspath.np_compcount-1)) && !isdotdot) { | |||
| 2371 | /* need to get SECINFO for the directory being mounted */ | |||
| 2372 | if (dirfh.fh_len == 0) | |||
| 2373 | NFSREQ_SECINFO_SET(&si, NULL, NULL, 0, isdotdot ? NULL : fspath.np_components[comp], 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (((void *)0)); (&si)->rsia_fhsize = (0); (&si)-> rsia_name = (isdotdot ? ((void *)0) : fspath.np_components[comp ]); (&si)->rsia_namelen = (0); } while (0); | |||
| 2374 | else | |||
| 2375 | NFSREQ_SECINFO_SET(&si, NULL, dirfh.fh_data, dirfh.fh_len, isdotdot ? NULL : fspath.np_components[comp], 0)do { (&si)->rsia_np = (((void *)0)); (&si)->rsia_fh = (dirfh.fh_data); (&si)->rsia_fhsize = (dirfh.fh_len ); (&si)->rsia_name = (isdotdot ? ((void *)0) : fspath .np_components[comp]); (&si)->rsia_namelen = (0); } while (0); | |||
| 2376 | sec.count = NX_MAX_SEC_FLAVORS5; | |||
| 2377 | error = nfs4_secinfo_rpc(nmp, &si, vfs_context_ucred(ctx), sec.flavors, &sec.count); | |||
| 2378 | /* [sigh] some implementations return "illegal" error for unsupported ops */ | |||
| 2379 | if (error == NFSERR_OP_ILLEGAL10044) | |||
| 2380 | error = 0; | |||
| 2381 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2382 | /* set our default security flavor to the first in the list */ | |||
| 2383 | if (sec.count) | |||
| 2384 | nmp->nm_auth = sec.flavors[0]; | |||
| 2385 | nmp->nm_state &= ~NFSSTA_NEEDSECINFO0x00000200; | |||
| 2386 | } | |||
| 2387 | /* advance directory file handle, component index, & update depth */ | |||
| 2388 | dirfh = fh; | |||
| 2389 | comp++; | |||
| 2390 | if (!isdotdot) /* going down the hierarchy */ | |||
| 2391 | depth++; | |||
| 2392 | else if (--depth <= 0) /* going up the hierarchy */ | |||
| 2393 | dirfh.fh_len = 0; /* clear dirfh when we hit root */ | |||
| 2394 | } | |||
| 2395 | ||||
| 2396 | gotfh: | |||
| 2397 | /* get attrs for mount point root */ | |||
| 2398 | numops = NMFLAG(nmp, NONAMEDATTR)(((uint32_t *)((nmp)->nm_flags))[(11)/32] & (1<< ((11)%32))) ? 2 : 3; // PUTFH + GETATTR + OPENATTR | |||
| 2399 | nfsm_chain_build_alloc_init(error, &nmreq, 25 * NFSX_UNSIGNED)do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((25 * 4)) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget (MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 2400 | nfsm_chain_add_compound_header(error, &nmreq, "mount", nmp->nm_minor_vers, numops)do { if (("mount") && strlen("mount")) { char __nfstag [12 +1]; snprintf(__nfstag, sizeof(__nfstag), "%-*s", 12, ("mount" )); do { do { if (((error))) break; if ((((&nmreq)))-> nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((& nmreq))), (4)); if (!(((error))) && ((((&nmreq))) ->nmc_left < (4))) (((error))) = 12; } } while (0); if ( (error)) break; *((uint32_t*)((&nmreq))->nmc_ptr) = (( __builtin_constant_p((uint32_t)(12)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(12)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(12)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(12)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(12)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(12)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq ))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((( 12)+3)&(~0x3)); if ((error)) break; if (((&nmreq))-> nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(( (&nmreq)), (const u_char*)(__nfstag), (12)); break; } *(( (uint32_t*)(((&nmreq))->nmc_ptr))+((((((12))+3)&(~ 0x3))>>2)-1)) = 0; bcopy((__nfstag), ((&nmreq))-> nmc_ptr, (12)); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } else { do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), ( 4)); if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break ; *((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); } do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((nmp->nm_minor_vers) )) ? ((__uint32_t)((((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((nmp->nm_minor_vers))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((nmp->nm_minor_vers))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((nmp->nm_minor_vers))))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((numops))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((numops))) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)((numops))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((numops))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numops))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numops))))); ((&nmreq))->nmc_ptr += 4; (( &nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 2401 | numops--; | |||
| 2402 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(22)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(22)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(22)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(22)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(22)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(22)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2403 | nfsm_chain_add_fh(error, &nmreq, NFS_VER4, dirfh.fh_data, dirfh.fh_len)do { if (error) break; if ((4) != 2) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error ))) = nfsm_chain_new_mbuf((((&nmreq))), (4)); if (!(((error ))) && ((((&nmreq)))->nmc_left < (4))) (((error ))) = 12; } } while (0); if ((error)) break; *((uint32_t*)((& nmreq))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((dirfh .fh_len))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((dirfh.fh_len ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((dirfh.fh_len))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((dirfh.fh_len))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((dirfh.fh_len))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((dirfh.fh_len))))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((dirfh.fh_len)) +3)&(~0x3)); if ((error)) break; if (((&nmreq))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(((&nmreq )), (const u_char*)((dirfh.fh_data)), ((dirfh.fh_len))); break ; } *(((uint32_t*)(((&nmreq))->nmc_ptr))+(((((((dirfh. fh_len)))+3)&(~0x3))>>2)-1)) = 0; bcopy(((dirfh.fh_data )), ((&nmreq))->nmc_ptr, ((dirfh.fh_len))); ((&nmreq ))->nmc_ptr += rndlen; ((&nmreq))->nmc_left -= rndlen ; } while (0); } while (0); | |||
| 2404 | numops--; | |||
| 2405 | nfsm_chain_add_32(error, &nmreq, NFS_OP_GETATTR)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(9)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(9)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(9)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(9)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(9)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(9)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2406 | NFS_CLEAR_ATTRIBUTES(bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( bitmap)))[__i] = 0; } while (0); | |||
| 2407 | NFS4_DEFAULT_ATTRIBUTES(bitmap)do { (((uint32_t *)((bitmap)))[(0)/32] |= 1<<((0)%32)); (((uint32_t *)((bitmap)))[(1)/32] |= 1<<((1)%32)); ((( uint32_t *)((bitmap)))[(2)/32] |= 1<<((2)%32)); (((uint32_t *)((bitmap)))[(3)/32] |= 1<<((3)%32)); (((uint32_t *)( (bitmap)))[(4)/32] |= 1<<((4)%32)); (((uint32_t *)((bitmap )))[(5)/32] |= 1<<((5)%32)); (((uint32_t *)((bitmap)))[ (6)/32] |= 1<<((6)%32)); (((uint32_t *)((bitmap)))[(7)/ 32] |= 1<<((7)%32)); (((uint32_t *)((bitmap)))[(8)/32] |= 1<<((8)%32)); (((uint32_t *)((bitmap)))[(9)/32] |= 1<< ((9)%32)); (((uint32_t *)((bitmap)))[(10)/32] |= 1<<((10 )%32)); (((uint32_t *)((bitmap)))[(13)/32] |= 1<<((13)% 32)); (((uint32_t *)((bitmap)))[(14)/32] |= 1<<((14)%32 )); (((uint32_t *)((bitmap)))[(16)/32] |= 1<<((16)%32)) ; (((uint32_t *)((bitmap)))[(17)/32] |= 1<<((17)%32)); ( ((uint32_t *)((bitmap)))[(18)/32] |= 1<<((18)%32)); ((( uint32_t *)((bitmap)))[(20)/32] |= 1<<((20)%32)); (((uint32_t *)((bitmap)))[(21)/32] |= 1<<((21)%32)); (((uint32_t * )((bitmap)))[(22)/32] |= 1<<((22)%32)); (((uint32_t *)( (bitmap)))[(23)/32] |= 1<<((23)%32)); (((uint32_t *)((bitmap )))[(25)/32] |= 1<<((25)%32)); (((uint32_t *)((bitmap)) )[(26)/32] |= 1<<((26)%32)); (((uint32_t *)((bitmap)))[ (27)/32] |= 1<<((27)%32)); (((uint32_t *)((bitmap)))[(28 )/32] |= 1<<((28)%32)); (((uint32_t *)((bitmap)))[(29)/ 32] |= 1<<((29)%32)); (((uint32_t *)((bitmap)))[(30)/32 ] |= 1<<((30)%32)); (((uint32_t *)((bitmap)))[(31)/32] |= 1<<((31)%32)); (((uint32_t *)((bitmap)))[(33)/32] |= 1 <<((33)%32)); (((uint32_t *)((bitmap)))[(34)/32] |= 1<< ((34)%32)); (((uint32_t *)((bitmap)))[(35)/32] |= 1<<(( 35)%32)); (((uint32_t *)((bitmap)))[(36)/32] |= 1<<((36 )%32)); (((uint32_t *)((bitmap)))[(37)/32] |= 1<<((37)% 32)); (((uint32_t *)((bitmap)))[(41)/32] |= 1<<((41)%32 )); (((uint32_t *)((bitmap)))[(42)/32] |= 1<<((42)%32)) ; (((uint32_t *)((bitmap)))[(43)/32] |= 1<<((43)%32)); ( ((uint32_t *)((bitmap)))[(44)/32] |= 1<<((44)%32)); ((( uint32_t *)((bitmap)))[(45)/32] |= 1<<((45)%32)); (((uint32_t *)((bitmap)))[(47)/32] |= 1<<((47)%32)); (((uint32_t * )((bitmap)))[(49)/32] |= 1<<((49)%32)); (((uint32_t *)( (bitmap)))[(50)/32] |= 1<<((50)%32)); (((uint32_t *)((bitmap )))[(52)/32] |= 1<<((52)%32)); (((uint32_t *)((bitmap)) )[(53)/32] |= 1<<((53)%32)); (((uint32_t *)((bitmap)))[ (55)/32] |= 1<<((55)%32)); } while (0); | |||
| 2408 | /* if no namedattr support or last component is ".zfs", clear NFS_FATTR_NAMED_ATTR */ | |||
| 2409 | if (NMFLAG(nmp, NONAMEDATTR)(((uint32_t *)((nmp)->nm_flags))[(11)/32] & (1<< ((11)%32))) || ((fspath.np_compcount > 0) && !strcmp(fspath.np_components[fspath.np_compcount-1], ".zfs"))) | |||
| 2410 | NFS_BITMAP_CLR(bitmap, NFS_FATTR_NAMED_ATTR)(((uint32_t *)(bitmap))[(7)/32] &= ~(1<<((7)%32))); | |||
| 2411 | nfsm_chain_add_bitmap(error, &nmreq, bitmap, NFS_ATTR_BITMAP_LEN)do { int __i; do { do { if (((error))) break; if ((((&nmreq )))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((2))) ? ((__uint32_t)(( ((__uint32_t)((uint32_t)((2))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((2))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((2))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((2))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((2))))); ((&nmreq))-> nmc_ptr += 4; ((&nmreq))->nmc_left -= 4; } while (0); for (__i=0; __i < (2); __i++) do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((bitmap)[__i])) ? ((__uint32_t )((((__uint32_t)((uint32_t)((bitmap)[__i])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((bitmap)[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((bitmap) [__i])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((bitmap)[__i])) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((bitmap)[__i])))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 2412 | if (!NMFLAG(nmp, NONAMEDATTR)(((uint32_t *)((nmp)->nm_flags))[(11)/32] & (1<< ((11)%32)))) { | |||
| 2413 | numops--; | |||
| 2414 | nfsm_chain_add_32(error, &nmreq, NFS_OP_OPENATTR)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(19)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(19)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(19)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(19)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(19)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(19)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2415 | nfsm_chain_add_32(error, &nmreq, 0)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(0)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(0)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(0)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(0)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 2416 | } | |||
| 2417 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 2418 | nfsm_assert(error, (numops == 0), EPROTO)do { if (error) break; if (!((numops == 0))) (error) = (100); } while (0); | |||
| 2419 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2420 | error = nfs_request_async(NULL((void *)0), nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND1, | |||
| 2421 | vfs_context_thread(ctx), vfs_context_ucred(ctx), &si, 0, NULL((void *)0), &req); | |||
| 2422 | if (!error) | |||
| 2423 | error = nfs_request_async_finish(req, &nmrep, &xid, &status); | |||
| 2424 | nfsm_chain_skip_tag(error, &nmrep)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (((&nmrep))->nmc_left >= (uint32_t)((((__val)+3)&(~0x3)))) { ((&nmrep)) ->nmc_left -= ((((__val)+3)&(~0x3))); ((&nmrep))-> nmc_ptr += ((((__val)+3)&(~0x3))); } else { ((error)) = nfsm_chain_advance (((&nmrep)), ((((__val)+3)&(~0x3)))); } } while (0); } while (0); | |||
| 2425 | nfsm_chain_get_32(error, &nmrep, numops)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (numops ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 2426 | nfsm_chain_op_check(error, &nmrep, NFS_OP_PUTFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (22)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2427 | nfsm_chain_op_check(error, &nmrep, NFS_OP_GETATTR)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (9)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2428 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2429 | NFS_CLEAR_ATTRIBUTES(nmp->nm_fsattr.nfsa_bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( nmp->nm_fsattr.nfsa_bitmap)))[__i] = 0; } while (0); | |||
| 2430 | error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, NULL((void *)0), NULL((void *)0), NULL((void *)0)); | |||
| 2431 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2432 | if (!NMFLAG(nmp, NONAMEDATTR)(((uint32_t *)((nmp)->nm_flags))[(11)/32] & (1<< ((11)%32)))) { | |||
| 2433 | nfsm_chain_op_check(error, &nmrep, NFS_OP_OPENATTR)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (19)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 2434 | if (error == ENOENT2) | |||
| 2435 | error = 0; | |||
| 2436 | /* [sigh] some implementations return "illegal" error for unsupported ops */ | |||
| 2437 | if (error || !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_NAMED_ATTR)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(7)/32] & (1<<((7)%32)))) { | |||
| 2438 | nmp->nm_fsattr.nfsa_flags &= ~NFS_FSFLAG_NAMED_ATTR0x00000400; | |||
| 2439 | } else { | |||
| 2440 | nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_NAMED_ATTR0x00000400; | |||
| 2441 | } | |||
| 2442 | } else { | |||
| 2443 | nmp->nm_fsattr.nfsa_flags &= ~NFS_FSFLAG_NAMED_ATTR0x00000400; | |||
| 2444 | } | |||
| 2445 | if (NMFLAG(nmp, NOACL)(((uint32_t *)((nmp)->nm_flags))[(12)/32] & (1<< ((12)%32)))) /* make sure ACL support is turned off */ | |||
| 2446 | nmp->nm_fsattr.nfsa_flags &= ~NFS_FSFLAG_ACL0x00000008; | |||
| 2447 | if (NMFLAG(nmp, ACLONLY)(((uint32_t *)((nmp)->nm_flags))[(13)/32] & (1<< ((13)%32))) && !(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL0x00000008)) | |||
| 2448 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_ACLONLY)(((uint32_t *)(nmp->nm_flags))[(13)/32] &= ~(1<< ((13)%32))); | |||
| 2449 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_FH_EXPIRE_TYPE)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(2)/32] & (1<<((2)%32)))) { | |||
| 2450 | uint32_t fhtype = ((nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_FHTYPE_MASK0xFF000000) >> NFS_FSFLAG_FHTYPE_SHIFT24); | |||
| 2451 | if (fhtype != NFS_FH_PERSISTENT0x00000000) | |||
| 2452 | printf("nfs: warning: non-persistent file handles! for %s\n", vfs_statfs(nmp->nm_mountp)->f_mntfromname); | |||
| 2453 | } | |||
| 2454 | ||||
| 2455 | /* make sure it's a directory */ | |||
| 2456 | if (!NFS_BITMAP_ISSET(&nvattr.nva_bitmap, NFS_FATTR_TYPE)(((uint32_t *)(&nvattr.nva_bitmap))[(1)/32] & (1<< ((1)%32))) || (nvattr.nva_type != VDIR)) { | |||
| 2457 | error = ENOTDIR20; | |||
| 2458 | goto nfsmout; | |||
| 2459 | } | |||
| 2460 | ||||
| 2461 | /* save the NFS fsid */ | |||
| 2462 | nmp->nm_fsidnm_un.v4.fsid = nvattr.nva_fsid; | |||
| 2463 | ||||
| 2464 | /* create the root node */ | |||
| 2465 | error = nfs_nget(nmp->nm_mountp, NULL((void *)0), NULL((void *)0), dirfh.fh_data, dirfh.fh_len, &nvattr, &xid, rq.r_auth, NG_MARKROOT0x0001, npp); | |||
| 2466 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 2467 | ||||
| 2468 | if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL0x00000008) | |||
| 2469 | vfs_setextendedsecurity(nmp->nm_mountp); | |||
| 2470 | ||||
| 2471 | /* adjust I/O sizes to server limits */ | |||
| 2472 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXREAD)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(30)/32] & (1<<((30)%32))) && (nmp->nm_fsattr.nfsa_maxread > 0)) { | |||
| 2473 | if (nmp->nm_fsattr.nfsa_maxread < (uint64_t)nmp->nm_rsize) { | |||
| 2474 | nmp->nm_rsize = nmp->nm_fsattr.nfsa_maxread & ~(NFS_FABLKSIZE512 - 1); | |||
| 2475 | if (nmp->nm_rsize == 0) | |||
| 2476 | nmp->nm_rsize = nmp->nm_fsattr.nfsa_maxread; | |||
| 2477 | } | |||
| 2478 | } | |||
| 2479 | if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXWRITE)(((uint32_t *)(nmp->nm_fsattr.nfsa_bitmap))[(31)/32] & (1<<((31)%32))) && (nmp->nm_fsattr.nfsa_maxwrite > 0)) { | |||
| 2480 | if (nmp->nm_fsattr.nfsa_maxwrite < (uint64_t)nmp->nm_wsize) { | |||
| 2481 | nmp->nm_wsize = nmp->nm_fsattr.nfsa_maxwrite & ~(NFS_FABLKSIZE512 - 1); | |||
| 2482 | if (nmp->nm_wsize == 0) | |||
| 2483 | nmp->nm_wsize = nmp->nm_fsattr.nfsa_maxwrite; | |||
| 2484 | } | |||
| 2485 | } | |||
| 2486 | ||||
| 2487 | /* set up lease renew timer */ | |||
| 2488 | nmp->nm_renew_timernm_un.v4.renew_timer = thread_call_allocate(nfs4_renew_timer, nmp); | |||
| 2489 | interval = nmp->nm_fsattr.nfsa_lease / 2; | |||
| 2490 | if (interval < 1) | |||
| 2491 | interval = 1; | |||
| 2492 | nfs_interval_timer_start(nmp->nm_renew_timernm_un.v4.renew_timer, interval * 1000); | |||
| 2493 | ||||
| 2494 | nfsmout: | |||
| 2495 | if (fspath.np_components) { | |||
| 2496 | for (comp=0; comp < fspath.np_compcount; comp++) | |||
| 2497 | if (fspath.np_components[comp]) | |||
| 2498 | FREE(fspath.np_components[comp], M_TEMP)_FREE((void *)fspath.np_components[comp], 80); | |||
| 2499 | FREE(fspath.np_components, M_TEMP)_FREE((void *)fspath.np_components, 80); | |||
| 2500 | } | |||
| 2501 | NVATTR_CLEANUP(&nvattr)do { do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t *)(((&nvattr)->nva_bitmap)))[__i] = 0; } while (0); if ((&nvattr)->nva_acl) { kauth_acl_free((&nvattr)-> nva_acl); (&nvattr)->nva_acl = ((void *)0); } } while ( 0); | |||
| 2502 | nfs_fs_locations_cleanup(&nfsls); | |||
| 2503 | if (*npp) | |||
| 2504 | nfs_node_unlock(*npp); | |||
| 2505 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 2506 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 2507 | return (error); | |||
| 2508 | } | |||
| 2509 | ||||
| 2510 | /* | |||
| 2511 | * Thread to handle initial NFS mount connection. | |||
| 2512 | */ | |||
| 2513 | void | |||
| 2514 | nfs_mount_connect_thread(void *arg, __unused__attribute__((unused)) wait_result_t wr) | |||
| 2515 | { | |||
| 2516 | struct nfsmount *nmp = arg; | |||
| 2517 | int error = 0, savederror = 0, slpflag = (NMFLAG(nmp, INTR)(((uint32_t *)((nmp)->nm_flags))[(1)/32] & (1<<( (1)%32))) ? PCATCH0x100 : 0); | |||
| 2518 | int done = 0, timeo, tries, maxtries; | |||
| 2519 | ||||
| 2520 | if (NM_OMFLAG(nmp, MNTQUICK)(((uint32_t *)((nmp)->nm_mflags))[(17)/32] & (1<< ((17)%32)))) { | |||
| 2521 | timeo = 8; | |||
| 2522 | maxtries = 1; | |||
| 2523 | } else { | |||
| 2524 | timeo = 30; | |||
| 2525 | maxtries = 2; | |||
| 2526 | } | |||
| 2527 | ||||
| 2528 | for (tries = 0; tries < maxtries; tries++) { | |||
| 2529 | error = nfs_connect(nmp, 1, timeo); | |||
| 2530 | switch (error) { | |||
| 2531 | case ETIMEDOUT60: | |||
| 2532 | case EAGAIN35: | |||
| 2533 | case EPIPE32: | |||
| 2534 | case EADDRNOTAVAIL49: | |||
| 2535 | case ENETDOWN50: | |||
| 2536 | case ENETUNREACH51: | |||
| 2537 | case ENETRESET52: | |||
| 2538 | case ECONNABORTED53: | |||
| 2539 | case ECONNRESET54: | |||
| 2540 | case EISCONN56: | |||
| 2541 | case ENOTCONN57: | |||
| 2542 | case ESHUTDOWN58: | |||
| 2543 | case ECONNREFUSED61: | |||
| 2544 | case EHOSTDOWN64: | |||
| 2545 | case EHOSTUNREACH65: | |||
| 2546 | /* just keep retrying on any of these errors */ | |||
| 2547 | break; | |||
| 2548 | case 0: | |||
| 2549 | default: | |||
| 2550 | /* looks like we got an answer... */ | |||
| 2551 | done = 1; | |||
| 2552 | break; | |||
| 2553 | } | |||
| 2554 | ||||
| 2555 | /* save the best error */ | |||
| 2556 | if (nfs_connect_error_class(error) >= nfs_connect_error_class(savederror)) | |||
| 2557 | savederror = error; | |||
| 2558 | if (done) { | |||
| 2559 | error = savederror; | |||
| 2560 | break; | |||
| 2561 | } | |||
| 2562 | ||||
| 2563 | /* pause before next attempt */ | |||
| 2564 | if ((error = nfs_sigintr(nmp, NULL((void *)0), current_thread(), 0))) | |||
| 2565 | break; | |||
| 2566 | error = tsleep(nmp, PSOCK24|slpflag, "nfs_mount_connect_retry", 2*hz); | |||
| 2567 | if (error && (error != EWOULDBLOCK35)) | |||
| 2568 | break; | |||
| 2569 | error = savederror; | |||
| 2570 | } | |||
| 2571 | ||||
| 2572 | /* update status of mount connect */ | |||
| 2573 | lck_mtx_lock(&nmp->nm_lock); | |||
| 2574 | if (!nmp->nm_mounterror) | |||
| 2575 | nmp->nm_mounterror = error; | |||
| 2576 | nmp->nm_state &= ~NFSSTA_MOUNT_THREAD0x00000040; | |||
| 2577 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 2578 | wakeup(&nmp->nm_nss); | |||
| 2579 | } | |||
| 2580 | ||||
| 2581 | int | |||
| 2582 | nfs_mount_connect(struct nfsmount *nmp) | |||
| 2583 | { | |||
| 2584 | int error = 0, slpflag; | |||
| 2585 | thread_t thd; | |||
| 2586 | struct timespec ts = { 2, 0 }; | |||
| 2587 | ||||
| 2588 | /* | |||
| 2589 | * Set up the socket. Perform initial search for a location/server/address to | |||
| 2590 | * connect to and negotiate any unspecified mount parameters. This work is | |||
| 2591 | * done on a kernel thread to satisfy reserved port usage needs. | |||
| 2592 | */ | |||
| 2593 | slpflag = NMFLAG(nmp, INTR)(((uint32_t *)((nmp)->nm_flags))[(1)/32] & (1<<( (1)%32))) ? PCATCH0x100 : 0; | |||
| 2594 | lck_mtx_lock(&nmp->nm_lock); | |||
| 2595 | /* set flag that the thread is running */ | |||
| 2596 | nmp->nm_state |= NFSSTA_MOUNT_THREAD0x00000040; | |||
| 2597 | if (kernel_thread_start(nfs_mount_connect_thread, nmp, &thd) != KERN_SUCCESS0) { | |||
| 2598 | nmp->nm_state &= ~NFSSTA_MOUNT_THREAD0x00000040; | |||
| 2599 | nmp->nm_mounterror = EIO5; | |||
| 2600 | printf("nfs mount %s start socket connect thread failed\n", vfs_statfs(nmp->nm_mountp)->f_mntfromname); | |||
| 2601 | } else { | |||
| 2602 | thread_deallocate(thd); | |||
| 2603 | } | |||
| 2604 | ||||
| 2605 | /* wait until mount connect thread is finished/gone */ | |||
| 2606 | while (nmp->nm_state & NFSSTA_MOUNT_THREAD0x00000040) { | |||
| 2607 | error = msleep(&nmp->nm_nss, &nmp->nm_lock, slpflag|PSOCK24, "nfsconnectthread", &ts); | |||
| 2608 | if ((error && (error != EWOULDBLOCK35)) || ((error = nfs_sigintr(nmp, NULL((void *)0), current_thread(), 1)))) { | |||
| 2609 | /* record error */ | |||
| 2610 | if (!nmp->nm_mounterror) | |||
| 2611 | nmp->nm_mounterror = error; | |||
| 2612 | /* signal the thread that we are aborting */ | |||
| 2613 | nmp->nm_sockflags |= NMSOCK_UNMOUNT0x0008; | |||
| 2614 | if (nmp->nm_nss) | |||
| 2615 | wakeup(nmp->nm_nss); | |||
| 2616 | /* and continue waiting on it to finish */ | |||
| 2617 | slpflag = 0; | |||
| 2618 | } | |||
| 2619 | } | |||
| 2620 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 2621 | ||||
| 2622 | /* grab mount connect status */ | |||
| 2623 | error = nmp->nm_mounterror; | |||
| 2624 | ||||
| 2625 | return (error); | |||
| 2626 | } | |||
| 2627 | ||||
| 2628 | /* Table of maximum minor version for a given version */ | |||
| 2629 | uint32_t maxminorverstab[] = { | |||
| 2630 | 0, /* Version 0 (does not exist) */ | |||
| 2631 | 0, /* Version 1 (does not exist) */ | |||
| 2632 | 0, /* Version 2 */ | |||
| 2633 | 0, /* Version 3 */ | |||
| 2634 | 0, /* Version 4 */ | |||
| 2635 | }; | |||
| 2636 | ||||
| 2637 | #define NFS_MAX_SUPPORTED_VERSION((long)(sizeof (maxminorverstab) / sizeof (uint32_t) - 1)) ((long)(sizeof (maxminorverstab) / sizeof (uint32_t) - 1)) | |||
| 2638 | #define NFS_MAX_SUPPORTED_MINOR_VERSION(v)((long)(maxminorverstab[(v)])) ((long)(maxminorverstab[(v)])) | |||
| 2639 | ||||
| 2640 | #define DEFAULT_NFS_MIN_VERS((uint32_t)((2) << 16) | ((0) & 0xffff)) VER2PVER(2, 0)((uint32_t)((2) << 16) | ((0) & 0xffff)) | |||
| 2641 | #define DEFAULT_NFS_MAX_VERS((uint32_t)((3) << 16) | ((0) & 0xffff)) VER2PVER(3, 0)((uint32_t)((3) << 16) | ((0) & 0xffff)) | |||
| 2642 | ||||
| 2643 | /* | |||
| 2644 | * Common code to mount an NFS file system. | |||
| 2645 | */ | |||
| 2646 | int | |||
| 2647 | mountnfs( | |||
| 2648 | char *xdrbuf, | |||
| 2649 | mount_t mp, | |||
| 2650 | vfs_context_t ctx, | |||
| 2651 | vnode_t *vpp) | |||
| 2652 | { | |||
| 2653 | struct nfsmount *nmp; | |||
| 2654 | nfsnode_t np; | |||
| 2655 | int error = 0; | |||
| 2656 | struct vfsstatfs *sbp; | |||
| 2657 | struct xdrbuf xb; | |||
| 2658 | uint32_t i, val, maxio, iosize, len; | |||
| 2659 | uint32_t *mattrs; | |||
| 2660 | uint32_t *mflags_mask; | |||
| 2661 | uint32_t *mflags; | |||
| 2662 | uint32_t argslength, attrslength; | |||
| 2663 | struct nfs_location_index firstloc = { NLI_VALID0x01, 0, 0, 0 }; | |||
| 2664 | static const struct nfs_etype nfs_default_etypes = { | |||
| 2665 | .count = NFS_MAX_ETYPES3, | |||
| 2666 | .selected = NFS_MAX_ETYPES3, | |||
| 2667 | .etypes = { NFS_AES256_CTS_HMAC_SHA1_96, | |||
| 2668 | NFS_AES128_CTS_HMAC_SHA1_96, | |||
| 2669 | NFS_DES3_CBC_SHA1_KD | |||
| 2670 | } | |||
| 2671 | }; | |||
| 2672 | /* make sure mbuf constants are set up */ | |||
| 2673 | if (!nfs_mbuf_mhlen) | |||
| 2674 | nfs_mbuf_init(); | |||
| 2675 | ||||
| 2676 | if (vfs_flags(mp) & MNT_UPDATE0x00010000) { | |||
| 2677 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 2678 | /* update paths, file handles, etc, here XXX */ | |||
| 2679 | xb_free(xdrbuf); | |||
| 2680 | return (0); | |||
| 2681 | } else { | |||
| 2682 | /* allocate an NFS mount structure for this mount */ | |||
| 2683 | MALLOC_ZONE(nmp, struct nfsmount *,(nmp) = (struct nfsmount *)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data"))); __MALLOC_ZONE(sizeof (struct nfsmount), 23, 0x0000, &site); }) | |||
| 2684 | sizeof (struct nfsmount), M_NFSMNT, M_WAITOK)(nmp) = (struct nfsmount *)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data"))); __MALLOC_ZONE(sizeof (struct nfsmount), 23, 0x0000, &site); }); | |||
| 2685 | if (!nmp) { | |||
| 2686 | xb_free(xdrbuf); | |||
| 2687 | return (ENOMEM12); | |||
| 2688 | } | |||
| 2689 | bzero((caddr_t)nmp, sizeof (struct nfsmount)); | |||
| 2690 | lck_mtx_init(&nmp->nm_lock, nfs_mount_grp, LCK_ATTR_NULL(lck_attr_t *)0); | |||
| 2691 | TAILQ_INIT(&nmp->nm_resendq)do { (((&nmp->nm_resendq))->tqh_first) = ((void *)0 ); (&nmp->nm_resendq)->tqh_last = &(((&nmp-> nm_resendq))->tqh_first); ; } while (0); | |||
| 2692 | TAILQ_INIT(&nmp->nm_iodq)do { (((&nmp->nm_iodq))->tqh_first) = ((void *)0); ( &nmp->nm_iodq)->tqh_last = &(((&nmp->nm_iodq ))->tqh_first); ; } while (0); | |||
| 2693 | TAILQ_INIT(&nmp->nm_gsscl)do { (((&nmp->nm_gsscl))->tqh_first) = ((void *)0); (&nmp->nm_gsscl)->tqh_last = &(((&nmp-> nm_gsscl))->tqh_first); ; } while (0); | |||
| 2694 | LIST_INIT(&nmp->nm_monlist)do { (((&nmp->nm_monlist))->lh_first) = ((void *)0) ; } while (0); | |||
| 2695 | vfs_setfsprivate(mp, nmp); | |||
| 2696 | vfs_getnewfsid(mp); | |||
| 2697 | nmp->nm_mountp = mp; | |||
| 2698 | vfs_setauthopaque(mp); | |||
| 2699 | ||||
| 2700 | nfs_nhinit_finish(); | |||
| 2701 | ||||
| 2702 | nmp->nm_args = xdrbuf; | |||
| 2703 | ||||
| 2704 | /* set up defaults */ | |||
| 2705 | nmp->nm_ref = 0; | |||
| 2706 | nmp->nm_vers = 0; | |||
| 2707 | nmp->nm_min_vers = DEFAULT_NFS_MIN_VERS((uint32_t)((2) << 16) | ((0) & 0xffff)); | |||
| 2708 | nmp->nm_max_vers = DEFAULT_NFS_MAX_VERS((uint32_t)((3) << 16) | ((0) & 0xffff)); | |||
| 2709 | nmp->nm_timeo = NFS_TIMEO(1 * (hz / nfs_ticks)); | |||
| 2710 | nmp->nm_retry = NFS_RETRANS10; | |||
| 2711 | nmp->nm_sotype = 0; | |||
| 2712 | nmp->nm_sofamily = 0; | |||
| 2713 | nmp->nm_nfsport = 0; | |||
| 2714 | nmp->nm_wsize = NFS_WSIZE32768; | |||
| 2715 | nmp->nm_rsize = NFS_RSIZE32768; | |||
| 2716 | nmp->nm_readdirsize = NFS_READDIRSIZE32768; | |||
| 2717 | nmp->nm_numgrps = NFS_MAXGRPS16U; | |||
| 2718 | nmp->nm_readahead = NFS_DEFRAHEAD16; | |||
| 2719 | nmp->nm_tprintf_delay = nfs_tprintf_delay; | |||
| 2720 | if (nmp->nm_tprintf_delay < 0) | |||
| 2721 | nmp->nm_tprintf_delay = 0; | |||
| 2722 | nmp->nm_tprintf_initial_delay = nfs_tprintf_initial_delay; | |||
| 2723 | if (nmp->nm_tprintf_initial_delay < 0) | |||
| 2724 | nmp->nm_tprintf_initial_delay = 0; | |||
| 2725 | nmp->nm_acregmin = NFS_MINATTRTIMO5; | |||
| 2726 | nmp->nm_acregmax = NFS_MAXATTRTIMO60; | |||
| 2727 | nmp->nm_acdirmin = NFS_MINDIRATTRTIMO5; | |||
| 2728 | nmp->nm_acdirmax = NFS_MAXDIRATTRTIMO60; | |||
| 2729 | nmp->nm_etype = nfs_default_etypes; | |||
| 2730 | nmp->nm_auth = RPCAUTH_SYS1; | |||
| 2731 | nmp->nm_iodlink.tqe_next = NFSNOLIST((void *)0x0badcafe); | |||
| 2732 | nmp->nm_deadtimeout = 0; | |||
| 2733 | nmp->nm_curdeadtimeout = 0; | |||
| 2734 | NFS_BITMAP_SET(nmp->nm_flags, NFS_MFLAG_NOACL)(((uint32_t *)(nmp->nm_flags))[(12)/32] |= 1<<((12)% 32)); | |||
| 2735 | nmp->nm_realm = NULL((void *)0); | |||
| 2736 | nmp->nm_principal = NULL((void *)0); | |||
| 2737 | nmp->nm_sprinc = NULL((void *)0); | |||
| 2738 | } | |||
| 2739 | ||||
| 2740 | mattrs = nmp->nm_mattrs; | |||
| 2741 | mflags = nmp->nm_mflags; | |||
| 2742 | mflags_mask = nmp->nm_mflags_mask; | |||
| 2743 | ||||
| 2744 | /* set up NFS mount with args */ | |||
| 2745 | xb_init_buffer(&xb, xdrbuf, 2*XDRWORD4); | |||
| 2746 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* version */ | |||
| 2747 | xb_get_32(error, &xb, argslength)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (argslength ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* args length */ | |||
| 2748 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2749 | xb_init_buffer(&xb, xdrbuf, argslength); /* restart parsing with actual buffer length */ | |||
| 2750 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* version */ | |||
| 2751 | xb_get_32(error, &xb, argslength)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (argslength ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* args length */ | |||
| 2752 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* XDR args version */ | |||
| 2753 | if (val != NFS_XDRARGS_VERSION_00) | |||
| 2754 | error = EINVAL22; | |||
| 2755 | len = NFS_MATTR_BITMAP_LEN1; | |||
| 2756 | xb_get_bitmap(error, &xb, mattrs, len)do { uint32_t __len = 0, __i; do { uint32_t __tmp; if (((error ))) break; (((error))) = xb_get_bytes((((&xb))), (char*)& __tmp, 4, 0); if (((error))) break; (__len) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (__i=0; __i < (((__len)<((uint32_t)((len))))?(__len):((uint32_t)(( len)))); __i++) do { uint32_t __tmp; if (((error))) break; (( (error))) = xb_get_bytes((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break; (((mattrs))[__i]) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (; __i < __len; __i++) do { if (((error))) break; (((error))) = xb_advance ((((&xb))), (4)); } while (0); for (; __i < (uint32_t) ((len)); __i++) ((mattrs))[__i] = 0; ((len)) = __len; } while (0); /* mount attribute bitmap */ | |||
| 2757 | attrslength = 0; | |||
| 2758 | xb_get_32(error, &xb, attrslength)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (attrslength ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* attrs length */ | |||
| 2759 | if (!error && (attrslength > (argslength - ((4+NFS_MATTR_BITMAP_LEN1+1)*XDRWORD4)))) | |||
| 2760 | error = EINVAL22; | |||
| 2761 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2762 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FLAGS)(((uint32_t *)(mattrs))[(0)/32] & (1<<((0)%32)))) { | |||
| 2763 | len = NFS_MFLAG_BITMAP_LEN1; | |||
| 2764 | xb_get_bitmap(error, &xb, mflags_mask, len)do { uint32_t __len = 0, __i; do { uint32_t __tmp; if (((error ))) break; (((error))) = xb_get_bytes((((&xb))), (char*)& __tmp, 4, 0); if (((error))) break; (__len) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (__i=0; __i < (((__len)<((uint32_t)((len))))?(__len):((uint32_t)(( len)))); __i++) do { uint32_t __tmp; if (((error))) break; (( (error))) = xb_get_bytes((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break; (((mflags_mask))[__i]) = ((uint32_t )(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t)(((( __uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if ( (error)) break; for (; __i < __len; __i++) do { if (((error ))) break; (((error))) = xb_advance((((&xb))), (4)); } while (0); for (; __i < (uint32_t)((len)); __i++) ((mflags_mask ))[__i] = 0; ((len)) = __len; } while (0); /* mount flag mask */ | |||
| 2765 | len = NFS_MFLAG_BITMAP_LEN1; | |||
| 2766 | xb_get_bitmap(error, &xb, mflags, len)do { uint32_t __len = 0, __i; do { uint32_t __tmp; if (((error ))) break; (((error))) = xb_get_bytes((((&xb))), (char*)& __tmp, 4, 0); if (((error))) break; (__len) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (__i=0; __i < (((__len)<((uint32_t)((len))))?(__len):((uint32_t)(( len)))); __i++) do { uint32_t __tmp; if (((error))) break; (( (error))) = xb_get_bytes((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break; (((mflags))[__i]) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (; __i < __len; __i++) do { if (((error))) break; (((error))) = xb_advance ((((&xb))), (4)); } while (0); for (; __i < (uint32_t) ((len)); __i++) ((mflags))[__i] = 0; ((len)) = __len; } while (0); /* mount flag values */ | |||
| 2767 | if (!error) { | |||
| 2768 | /* clear all mask bits and OR in all the ones that are set */ | |||
| 2769 | nmp->nm_flags[0] &= ~mflags_mask[0]; | |||
| 2770 | nmp->nm_flags[0] |= (mflags_mask[0] & mflags[0]); | |||
| 2771 | } | |||
| 2772 | } | |||
| 2773 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] & (1<<((1)%32)))) { | |||
| 2774 | /* Can't specify a single version and a range */ | |||
| 2775 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_VERSION_RANGE)(((uint32_t *)(mattrs))[(27)/32] & (1<<((27)%32)))) | |||
| 2776 | error = EINVAL22; | |||
| 2777 | xb_get_32(error, &xb, nmp->nm_vers)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_vers) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2778 | if (nmp->nm_vers > NFS_MAX_SUPPORTED_VERSION((long)(sizeof (maxminorverstab) / sizeof (uint32_t) - 1)) || | |||
| 2779 | nmp->nm_vers < NFS_VER22) | |||
| 2780 | error = EINVAL22; | |||
| 2781 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_MINOR_VERSION)(((uint32_t *)(mattrs))[(2)/32] & (1<<((2)%32)))) | |||
| 2782 | xb_get_32(error, &xb, nmp->nm_minor_vers)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_minor_vers) = ((uint32_t)(__builtin_constant_p((uint32_t)( __tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2783 | else | |||
| 2784 | nmp->nm_minor_vers = maxminorverstab[nmp->nm_vers]; | |||
| 2785 | if (nmp->nm_minor_vers > maxminorverstab[nmp->nm_vers]) | |||
| 2786 | error = EINVAL22; | |||
| 2787 | nmp->nm_max_vers = nmp->nm_min_vers = | |||
| 2788 | VER2PVER(nmp->nm_vers, nmp->nm_minor_vers)((uint32_t)((nmp->nm_vers) << 16) | ((nmp->nm_minor_vers ) & 0xffff)); | |||
| 2789 | } | |||
| 2790 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_MINOR_VERSION)(((uint32_t *)(mattrs))[(2)/32] & (1<<((2)%32)))) { | |||
| 2791 | /* should have also gotten NFS version (and already gotten minor version) */ | |||
| 2792 | if (!NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] & (1<<((1)%32)))) | |||
| 2793 | error = EINVAL22; | |||
| 2794 | } | |||
| 2795 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_VERSION_RANGE)(((uint32_t *)(mattrs))[(27)/32] & (1<<((27)%32)))) { | |||
| 2796 | xb_get_32(error, &xb, nmp->nm_min_vers)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_min_vers) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2797 | xb_get_32(error, &xb, nmp->nm_max_vers)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_max_vers) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2798 | if ((nmp->nm_min_vers > nmp->nm_max_vers) || | |||
| 2799 | (PVER2MAJOR(nmp->nm_max_vers)((uint32_t)(((nmp->nm_max_vers) >> 16) & 0xffff) ) > NFS_MAX_SUPPORTED_VERSION((long)(sizeof (maxminorverstab) / sizeof (uint32_t) - 1))) || | |||
| 2800 | (PVER2MINOR(nmp->nm_min_vers)((uint32_t)((nmp->nm_min_vers) & 0xffff)) > maxminorverstab[PVER2MAJOR(nmp->nm_min_vers)((uint32_t)(((nmp->nm_min_vers) >> 16) & 0xffff) )]) || | |||
| 2801 | (PVER2MINOR(nmp->nm_max_vers)((uint32_t)((nmp->nm_max_vers) & 0xffff)) > maxminorverstab[PVER2MAJOR(nmp->nm_max_vers)((uint32_t)(((nmp->nm_max_vers) >> 16) & 0xffff) )])) | |||
| 2802 | error = EINVAL22; | |||
| 2803 | } | |||
| 2804 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READ_SIZE)(((uint32_t *)(mattrs))[(3)/32] & (1<<((3)%32)))) | |||
| 2805 | xb_get_32(error, &xb, nmp->nm_rsize)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_rsize) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2806 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_WRITE_SIZE)(((uint32_t *)(mattrs))[(4)/32] & (1<<((4)%32)))) | |||
| 2807 | xb_get_32(error, &xb, nmp->nm_wsize)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_wsize) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2808 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READDIR_SIZE)(((uint32_t *)(mattrs))[(5)/32] & (1<<((5)%32)))) | |||
| 2809 | xb_get_32(error, &xb, nmp->nm_readdirsize)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_readdirsize) = ((uint32_t)(__builtin_constant_p((uint32_t) (__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2810 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READAHEAD)(((uint32_t *)(mattrs))[(6)/32] & (1<<((6)%32)))) | |||
| 2811 | xb_get_32(error, &xb, nmp->nm_readahead)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_readahead) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2812 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_REG_MIN)(((uint32_t *)(mattrs))[(7)/32] & (1<<((7)%32)))) { | |||
| 2813 | xb_get_32(error, &xb, nmp->nm_acregmin)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_acregmin) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2814 | xb_skip(error, &xb, XDRWORD)do { if (error) break; (error) = xb_advance((&xb), (4)); } while (0); | |||
| 2815 | } | |||
| 2816 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_REG_MAX)(((uint32_t *)(mattrs))[(8)/32] & (1<<((8)%32)))) { | |||
| 2817 | xb_get_32(error, &xb, nmp->nm_acregmax)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_acregmax) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2818 | xb_skip(error, &xb, XDRWORD)do { if (error) break; (error) = xb_advance((&xb), (4)); } while (0); | |||
| 2819 | } | |||
| 2820 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MIN)(((uint32_t *)(mattrs))[(9)/32] & (1<<((9)%32)))) { | |||
| 2821 | xb_get_32(error, &xb, nmp->nm_acdirmin)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_acdirmin) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2822 | xb_skip(error, &xb, XDRWORD)do { if (error) break; (error) = xb_advance((&xb), (4)); } while (0); | |||
| 2823 | } | |||
| 2824 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MAX)(((uint32_t *)(mattrs))[(10)/32] & (1<<((10)%32)))) { | |||
| 2825 | xb_get_32(error, &xb, nmp->nm_acdirmax)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_acdirmax) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2826 | xb_skip(error, &xb, XDRWORD)do { if (error) break; (error) = xb_advance((&xb), (4)); } while (0); | |||
| 2827 | } | |||
| 2828 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2829 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_LOCK_MODE)(((uint32_t *)(mattrs))[(11)/32] & (1<<((11)%32)))) { | |||
| 2830 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2831 | switch (val) { | |||
| 2832 | case NFS_LOCK_MODE_DISABLED1: | |||
| 2833 | case NFS_LOCK_MODE_LOCAL2: | |||
| 2834 | if (nmp->nm_vers >= NFS_VER44) { | |||
| 2835 | /* disabled/local lock mode only allowed on v2/v3 */ | |||
| 2836 | error = EINVAL22; | |||
| 2837 | break; | |||
| 2838 | } | |||
| 2839 | /* FALLTHROUGH */ | |||
| 2840 | case NFS_LOCK_MODE_ENABLED0: | |||
| 2841 | nmp->nm_lockmode = val; | |||
| 2842 | break; | |||
| 2843 | default: | |||
| 2844 | error = EINVAL22; | |||
| 2845 | } | |||
| 2846 | } | |||
| 2847 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2848 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SECURITY)(((uint32_t *)(mattrs))[(12)/32] & (1<<((12)%32)))) { | |||
| 2849 | uint32_t seccnt; | |||
| 2850 | xb_get_32(error, &xb, seccnt)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (seccnt ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2851 | if (!error && ((seccnt < 1) || (seccnt > NX_MAX_SEC_FLAVORS5))) | |||
| 2852 | error = EINVAL22; | |||
| 2853 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2854 | nmp->nm_sec.count = seccnt; | |||
| 2855 | for (i=0; i < seccnt; i++) { | |||
| 2856 | xb_get_32(error, &xb, nmp->nm_sec.flavors[i])do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_sec.flavors[i]) = ((uint32_t)(__builtin_constant_p((uint32_t )(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2857 | /* Check for valid security flavor */ | |||
| 2858 | switch (nmp->nm_sec.flavors[i]) { | |||
| 2859 | case RPCAUTH_NONE0: | |||
| 2860 | case RPCAUTH_SYS1: | |||
| 2861 | case RPCAUTH_KRB5390003: | |||
| 2862 | case RPCAUTH_KRB5I390004: | |||
| 2863 | case RPCAUTH_KRB5P390005: | |||
| 2864 | break; | |||
| 2865 | default: | |||
| 2866 | error = EINVAL22; | |||
| 2867 | } | |||
| 2868 | } | |||
| 2869 | /* start with the first flavor */ | |||
| 2870 | nmp->nm_auth = nmp->nm_sec.flavors[0]; | |||
| 2871 | } | |||
| 2872 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_KERB_ETYPE)(((uint32_t *)(mattrs))[(28)/32] & (1<<((28)%32)))) { | |||
| 2873 | uint32_t etypecnt; | |||
| 2874 | xb_get_32(error, &xb, etypecnt)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (etypecnt ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2875 | if (!error && ((etypecnt < 1) || (etypecnt > NFS_MAX_ETYPES3))) | |||
| 2876 | error = EINVAL22; | |||
| 2877 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2878 | nmp->nm_etype.count = etypecnt; | |||
| 2879 | xb_get_32(error, &xb, nmp->nm_etype.selected)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_etype.selected) = ((uint32_t)(__builtin_constant_p((uint32_t )(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2880 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2881 | if (etypecnt) { | |||
| 2882 | nmp->nm_etype.selected = etypecnt; /* Nothing is selected yet, so set selected to count */ | |||
| 2883 | for (i=0; i < etypecnt; i++) { | |||
| 2884 | xb_get_32(error, &xb, nmp->nm_etype.etypes[i])do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_etype.etypes[i]) = ((uint32_t)(__builtin_constant_p((uint32_t )(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2885 | /* Check for valid encryption type */ | |||
| 2886 | switch (nmp->nm_etype.etypes[i]) { | |||
| 2887 | case NFS_DES3_CBC_SHA1_KD: | |||
| 2888 | case NFS_AES128_CTS_HMAC_SHA1_96: | |||
| 2889 | case NFS_AES256_CTS_HMAC_SHA1_96: | |||
| 2890 | break; | |||
| 2891 | default: | |||
| 2892 | error = EINVAL22; | |||
| 2893 | } | |||
| 2894 | } | |||
| 2895 | } | |||
| 2896 | } | |||
| 2897 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MAX_GROUP_LIST)(((uint32_t *)(mattrs))[(13)/32] & (1<<((13)%32)))) | |||
| 2898 | xb_get_32(error, &xb, nmp->nm_numgrps)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_numgrps) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2899 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] & (1<<((14)%32)))) { | |||
| 2900 | char sotype[6]; | |||
| 2901 | ||||
| 2902 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2903 | if (!error && ((val < 3) || (val > 5))) | |||
| 2904 | error = EINVAL22; | |||
| 2905 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2906 | error = xb_get_bytes(&xb, sotype, val, 0); | |||
| 2907 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2908 | sotype[val] = '\0'; | |||
| 2909 | if (!strcmp(sotype, "tcp")) { | |||
| 2910 | nmp->nm_sotype = SOCK_STREAM1; | |||
| 2911 | } else if (!strcmp(sotype, "udp")) { | |||
| 2912 | nmp->nm_sotype = SOCK_DGRAM2; | |||
| 2913 | } else if (!strcmp(sotype, "tcp4")) { | |||
| 2914 | nmp->nm_sotype = SOCK_STREAM1; | |||
| 2915 | nmp->nm_sofamily = AF_INET2; | |||
| 2916 | } else if (!strcmp(sotype, "udp4")) { | |||
| 2917 | nmp->nm_sotype = SOCK_DGRAM2; | |||
| 2918 | nmp->nm_sofamily = AF_INET2; | |||
| 2919 | } else if (!strcmp(sotype, "tcp6")) { | |||
| 2920 | nmp->nm_sotype = SOCK_STREAM1; | |||
| 2921 | nmp->nm_sofamily = AF_INET630; | |||
| 2922 | } else if (!strcmp(sotype, "udp6")) { | |||
| 2923 | nmp->nm_sotype = SOCK_DGRAM2; | |||
| 2924 | nmp->nm_sofamily = AF_INET630; | |||
| 2925 | } else if (!strcmp(sotype, "inet4")) { | |||
| 2926 | nmp->nm_sofamily = AF_INET2; | |||
| 2927 | } else if (!strcmp(sotype, "inet6")) { | |||
| 2928 | nmp->nm_sofamily = AF_INET630; | |||
| 2929 | } else if (!strcmp(sotype, "inet")) { | |||
| 2930 | nmp->nm_sofamily = 0; /* ok */ | |||
| 2931 | } else { | |||
| 2932 | error = EINVAL22; | |||
| 2933 | } | |||
| 2934 | if (!error && (nmp->nm_vers >= NFS_VER44) && nmp->nm_sotype && | |||
| 2935 | (nmp->nm_sotype != SOCK_STREAM1)) | |||
| 2936 | error = EINVAL22; /* NFSv4 is only allowed over TCP. */ | |||
| 2937 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2938 | } | |||
| 2939 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] & (1<<((15)%32)))) | |||
| 2940 | xb_get_32(error, &xb, nmp->nm_nfsport)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_nfsport) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2941 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MOUNT_PORT)(((uint32_t *)(mattrs))[(16)/32] & (1<<((16)%32)))) | |||
| 2942 | xb_get_32(error, &xb, nmp->nm_mountport)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_mountport) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2943 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_REQUEST_TIMEOUT)(((uint32_t *)(mattrs))[(17)/32] & (1<<((17)%32)))) { | |||
| 2944 | /* convert from time to 0.1s units */ | |||
| 2945 | xb_get_32(error, &xb, nmp->nm_timeo)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_timeo) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2946 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2947 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2948 | if (val >= 1000000000) | |||
| 2949 | error = EINVAL22; | |||
| 2950 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2951 | nmp->nm_timeo *= 10; | |||
| 2952 | nmp->nm_timeo += (val+100000000-1)/100000000; | |||
| 2953 | /* now convert to ticks */ | |||
| 2954 | nmp->nm_timeo = (nmp->nm_timeo * NFS_HZ(hz / nfs_ticks) + 5) / 10; | |||
| 2955 | } | |||
| 2956 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SOFT_RETRY_COUNT)(((uint32_t *)(mattrs))[(18)/32] & (1<<((18)%32)))) { | |||
| 2957 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 2958 | if (!error && (val > 1)) | |||
| 2959 | nmp->nm_retry = val; | |||
| 2960 | } | |||
| 2961 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_DEAD_TIMEOUT)(((uint32_t *)(mattrs))[(19)/32] & (1<<((19)%32)))) { | |||
| 2962 | xb_get_32(error, &xb, nmp->nm_deadtimeout)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_deadtimeout) = ((uint32_t)(__builtin_constant_p((uint32_t) (__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2963 | xb_skip(error, &xb, XDRWORD)do { if (error) break; (error) = xb_advance((&xb), (4)); } while (0); | |||
| 2964 | } | |||
| 2965 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] & (1<<((20)%32)))) { | |||
| 2966 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2967 | MALLOC(nmp->nm_fh, fhandle_t *, sizeof(fhandle_t), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nmp->nm_fh) = (fhandle_t *)__MALLOC(sizeof(fhandle_t ), 80, 0x0000|0x0004, &site); }); | |||
| 2968 | if (!nmp->nm_fh) | |||
| 2969 | error = ENOMEM12; | |||
| 2970 | xb_get_32(error, &xb, nmp->nm_fh->fh_len)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_fh->fh_len) = ((uint32_t)(__builtin_constant_p((uint32_t )(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); | |||
| 2971 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2972 | if (nmp->nm_fh->fh_len < 0 || | |||
| 2973 | (size_t)nmp->nm_fh->fh_len > sizeof(nmp->nm_fh->fh_data)) | |||
| 2974 | error = EINVAL22; | |||
| 2975 | else | |||
| 2976 | error = xb_get_bytes(&xb, (char*)&nmp->nm_fh->fh_data[0], nmp->nm_fh->fh_len, 0); | |||
| 2977 | } | |||
| 2978 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2979 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] & (1<<((21)%32)))) { | |||
| 2980 | uint32_t loc, serv, addr, comp; | |||
| 2981 | struct nfs_fs_location *fsl; | |||
| 2982 | struct nfs_fs_server *fss; | |||
| 2983 | struct nfs_fs_path *fsp; | |||
| 2984 | ||||
| 2985 | xb_get_32(error, &xb, nmp->nm_locations.nl_numlocs)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (nmp-> nm_locations.nl_numlocs) = ((uint32_t)(__builtin_constant_p(( uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); /* fs location count */ | |||
| 2986 | /* sanity check location count */ | |||
| 2987 | if (!error && ((nmp->nm_locations.nl_numlocs < 1) || (nmp->nm_locations.nl_numlocs > 256))) | |||
| 2988 | error = EINVAL22; | |||
| 2989 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2990 | MALLOC(nmp->nm_locations.nl_locations, struct nfs_fs_location **, nmp->nm_locations.nl_numlocs * sizeof(struct nfs_fs_location*), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nmp->nm_locations.nl_locations) = (struct nfs_fs_location **)__MALLOC(nmp->nm_locations.nl_numlocs * sizeof(struct nfs_fs_location *), 80, 0x0000|0x0004, &site); }); | |||
| 2991 | if (!nmp->nm_locations.nl_locations) | |||
| 2992 | error = ENOMEM12; | |||
| 2993 | for (loc = 0; loc < nmp->nm_locations.nl_numlocs; loc++) { | |||
| 2994 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 2995 | MALLOC(fsl, struct nfs_fs_location *, sizeof(struct nfs_fs_location), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fsl) = (struct nfs_fs_location *)__MALLOC(sizeof(struct nfs_fs_location), 80, 0x0000|0x0004, &site); }); | |||
| 2996 | if (!fsl) | |||
| 2997 | error = ENOMEM12; | |||
| 2998 | nmp->nm_locations.nl_locations[loc] = fsl; | |||
| 2999 | xb_get_32(error, &xb, fsl->nl_servcount)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (fsl-> nl_servcount) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* server count */ | |||
| 3000 | /* sanity check server count */ | |||
| 3001 | if (!error && ((fsl->nl_servcount < 1) || (fsl->nl_servcount > 256))) | |||
| 3002 | error = EINVAL22; | |||
| 3003 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3004 | MALLOC(fsl->nl_servers, struct nfs_fs_server **, fsl->nl_servcount * sizeof(struct nfs_fs_server*), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fsl->nl_servers) = (struct nfs_fs_server **)__MALLOC (fsl->nl_servcount * sizeof(struct nfs_fs_server*), 80, 0x0000 |0x0004, &site); }); | |||
| 3005 | if (!fsl->nl_servers) | |||
| 3006 | error = ENOMEM12; | |||
| 3007 | for (serv = 0; serv < fsl->nl_servcount; serv++) { | |||
| 3008 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3009 | MALLOC(fss, struct nfs_fs_server *, sizeof(struct nfs_fs_server), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fss) = (struct nfs_fs_server *)__MALLOC(sizeof(struct nfs_fs_server ), 80, 0x0000|0x0004, &site); }); | |||
| 3010 | if (!fss) | |||
| 3011 | error = ENOMEM12; | |||
| 3012 | fsl->nl_servers[serv] = fss; | |||
| 3013 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* server name length */ | |||
| 3014 | /* sanity check server name length */ | |||
| 3015 | if (!error && ((val < 1) || (val > MAXPATHLEN1024))) | |||
| 3016 | error = EINVAL22; | |||
| 3017 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3018 | MALLOC(fss->ns_name, char *, val+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fss->ns_name) = (char *)__MALLOC(val+1, 80, 0x0000|0x0004 , &site); }); | |||
| 3019 | if (!fss->ns_name) | |||
| 3020 | error = ENOMEM12; | |||
| 3021 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3022 | error = xb_get_bytes(&xb, fss->ns_name, val, 0); /* server name */ | |||
| 3023 | xb_get_32(error, &xb, fss->ns_addrcount)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (fss-> ns_addrcount) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* address count */ | |||
| 3024 | /* sanity check address count (OK to be zero) */ | |||
| 3025 | if (!error && (fss->ns_addrcount > 256)) | |||
| 3026 | error = EINVAL22; | |||
| 3027 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3028 | if (fss->ns_addrcount > 0) { | |||
| 3029 | MALLOC(fss->ns_addresses, char **, fss->ns_addrcount * sizeof(char *), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fss->ns_addresses) = (char **)__MALLOC(fss->ns_addrcount * sizeof(char *), 80, 0x0000|0x0004, &site); }); | |||
| 3030 | if (!fss->ns_addresses) | |||
| 3031 | error = ENOMEM12; | |||
| 3032 | for (addr = 0; addr < fss->ns_addrcount; addr++) { | |||
| 3033 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* address length */ | |||
| 3034 | /* sanity check address length */ | |||
| 3035 | if (!error && ((val < 1) || (val > 128))) | |||
| 3036 | error = EINVAL22; | |||
| 3037 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3038 | MALLOC(fss->ns_addresses[addr], char *, val+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fss->ns_addresses[addr]) = (char *)__MALLOC(val+1, 80 , 0x0000|0x0004, &site); }); | |||
| 3039 | if (!fss->ns_addresses[addr]) | |||
| 3040 | error = ENOMEM12; | |||
| 3041 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3042 | error = xb_get_bytes(&xb, fss->ns_addresses[addr], val, 0); /* address */ | |||
| 3043 | } | |||
| 3044 | } | |||
| 3045 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* server info length */ | |||
| 3046 | xb_skip(error, &xb, val)do { if (error) break; (error) = xb_advance((&xb), (val)) ; } while (0); /* skip server info */ | |||
| 3047 | } | |||
| 3048 | /* get pathname */ | |||
| 3049 | fsp = &fsl->nl_path; | |||
| 3050 | xb_get_32(error, &xb, fsp->np_compcount)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (fsp-> np_compcount) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* component count */ | |||
| 3051 | /* sanity check component count */ | |||
| 3052 | if (!error && (fsp->np_compcount > MAXPATHLEN1024)) | |||
| 3053 | error = EINVAL22; | |||
| 3054 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3055 | if (fsp->np_compcount) { | |||
| 3056 | MALLOC(fsp->np_components, char **, fsp->np_compcount * sizeof(char*), M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fsp->np_components) = (char **)__MALLOC(fsp->np_compcount * sizeof(char*), 80, 0x0000|0x0004, &site); }); | |||
| 3057 | if (!fsp->np_components) | |||
| 3058 | error = ENOMEM12; | |||
| 3059 | } | |||
| 3060 | for (comp = 0; comp < fsp->np_compcount; comp++) { | |||
| 3061 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* component length */ | |||
| 3062 | /* sanity check component length */ | |||
| 3063 | if (!error && (val == 0)) { | |||
| 3064 | /* | |||
| 3065 | * Apparently some people think a path with zero components should | |||
| 3066 | * be encoded with one zero-length component. So, just ignore any | |||
| 3067 | * zero length components. | |||
| 3068 | */ | |||
| 3069 | comp--; | |||
| 3070 | fsp->np_compcount--; | |||
| 3071 | if (fsp->np_compcount == 0) { | |||
| 3072 | FREE(fsp->np_components, M_TEMP)_FREE((void *)fsp->np_components, 80); | |||
| 3073 | fsp->np_components = NULL((void *)0); | |||
| 3074 | } | |||
| 3075 | continue; | |||
| 3076 | } | |||
| 3077 | if (!error && ((val < 1) || (val > MAXPATHLEN1024))) | |||
| 3078 | error = EINVAL22; | |||
| 3079 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3080 | MALLOC(fsp->np_components[comp], char *, val+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (fsp->np_components[comp]) = (char *)__MALLOC(val+1, 80 , 0x0000|0x0004, &site); }); | |||
| 3081 | if (!fsp->np_components[comp]) | |||
| 3082 | error = ENOMEM12; | |||
| 3083 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3084 | error = xb_get_bytes(&xb, fsp->np_components[comp], val, 0); /* component */ | |||
| 3085 | } | |||
| 3086 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* fs location info length */ | |||
| 3087 | xb_skip(error, &xb, val)do { if (error) break; (error) = xb_advance((&xb), (val)) ; } while (0); /* skip fs location info */ | |||
| 3088 | } | |||
| 3089 | } | |||
| 3090 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] & (1<<((22)%32)))) | |||
| 3091 | xb_skip(error, &xb, XDRWORD)do { if (error) break; (error) = xb_advance((&xb), (4)); } while (0); | |||
| 3092 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MNTFROM)(((uint32_t *)(mattrs))[(23)/32] & (1<<((23)%32)))) { | |||
| 3093 | xb_get_32(error, &xb, len)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (len) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3094 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3095 | val = len; | |||
| 3096 | if (val >= sizeof(vfs_statfs(mp)->f_mntfromname)) | |||
| 3097 | val = sizeof(vfs_statfs(mp)->f_mntfromname) - 1; | |||
| 3098 | error = xb_get_bytes(&xb, vfs_statfs(mp)->f_mntfromname, val, 0); | |||
| 3099 | if ((len - val) > 0) | |||
| 3100 | xb_skip(error, &xb, len - val)do { if (error) break; (error) = xb_advance((&xb), (len - val)); } while (0); | |||
| 3101 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3102 | vfs_statfs(mp)->f_mntfromname[val] = '\0'; | |||
| 3103 | } | |||
| 3104 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3105 | ||||
| 3106 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_REALM)(((uint32_t *)(mattrs))[(24)/32] & (1<<((24)%32)))) { | |||
| 3107 | xb_get_32(error, &xb, len)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (len) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3108 | if (!error && ((len < 1) || (len > MAXPATHLEN1024))) | |||
| 3109 | error=EINVAL22; | |||
| 3110 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3111 | /* allocate an extra byte for a leading '@' if its not already prepended to the realm */ | |||
| 3112 | MALLOC(nmp->nm_realm, char *, len+2, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nmp->nm_realm) = (char *)__MALLOC(len+2, 80, 0x0000| 0x0004, &site); }); | |||
| 3113 | if (!nmp->nm_realm) | |||
| 3114 | error = ENOMEM12; | |||
| 3115 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3116 | error = xb_get_bytes(&xb, nmp->nm_realm, len, 0); | |||
| 3117 | if (error == 0 && *nmp->nm_realm != '@') { | |||
| 3118 | bcopy(nmp->nm_realm, &nmp->nm_realm[1], len); | |||
| 3119 | nmp->nm_realm[0] = '@'; | |||
| 3120 | } | |||
| 3121 | } | |||
| 3122 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3123 | ||||
| 3124 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_PRINCIPAL)(((uint32_t *)(mattrs))[(25)/32] & (1<<((25)%32)))) { | |||
| 3125 | xb_get_32(error, &xb, len)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (len) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3126 | if (!error && ((len < 1) || (len > MAXPATHLEN1024))) | |||
| 3127 | error=EINVAL22; | |||
| 3128 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3129 | MALLOC(nmp->nm_principal, char *, len+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nmp->nm_principal) = (char *)__MALLOC(len+1, 80, 0x0000 |0x0004, &site); }); | |||
| 3130 | if (!nmp->nm_principal) | |||
| 3131 | error = ENOMEM12; | |||
| 3132 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3133 | error = xb_get_bytes(&xb, nmp->nm_principal, len, 0); | |||
| 3134 | } | |||
| 3135 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3136 | ||||
| 3137 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SVCPRINCIPAL)(((uint32_t *)(mattrs))[(26)/32] & (1<<((26)%32)))) { | |||
| 3138 | xb_get_32(error, &xb, len)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (len) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3139 | if (!error && ((len < 1) || (len > MAXPATHLEN1024))) | |||
| 3140 | error=EINVAL22; | |||
| 3141 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3142 | MALLOC(nmp->nm_sprinc, char *, len+1, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nmp->nm_sprinc) = (char *)__MALLOC(len+1, 80, 0x0000 |0x0004, &site); }); | |||
| 3143 | if (!nmp->nm_sprinc) | |||
| 3144 | error = ENOMEM12; | |||
| 3145 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3146 | error = xb_get_bytes(&xb, nmp->nm_sprinc, len, 0); | |||
| 3147 | } | |||
| 3148 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3149 | ||||
| 3150 | /* | |||
| 3151 | * Sanity check/finalize settings. | |||
| 3152 | */ | |||
| 3153 | ||||
| 3154 | if (nmp->nm_timeo < NFS_MINTIMEO(1 * (hz / nfs_ticks))) | |||
| 3155 | nmp->nm_timeo = NFS_MINTIMEO(1 * (hz / nfs_ticks)); | |||
| 3156 | else if (nmp->nm_timeo > NFS_MAXTIMEO(60 * (hz / nfs_ticks))) | |||
| 3157 | nmp->nm_timeo = NFS_MAXTIMEO(60 * (hz / nfs_ticks)); | |||
| 3158 | if (nmp->nm_retry > NFS_MAXREXMIT100) | |||
| 3159 | nmp->nm_retry = NFS_MAXREXMIT100; | |||
| 3160 | ||||
| 3161 | if (nmp->nm_numgrps > NFS_MAXGRPS16U) | |||
| 3162 | nmp->nm_numgrps = NFS_MAXGRPS16U; | |||
| 3163 | if (nmp->nm_readahead > NFS_MAXRAHEAD128) | |||
| 3164 | nmp->nm_readahead = NFS_MAXRAHEAD128; | |||
| 3165 | if (nmp->nm_acregmin > nmp->nm_acregmax) | |||
| 3166 | nmp->nm_acregmin = nmp->nm_acregmax; | |||
| 3167 | if (nmp->nm_acdirmin > nmp->nm_acdirmax) | |||
| 3168 | nmp->nm_acdirmin = nmp->nm_acdirmax; | |||
| 3169 | ||||
| 3170 | /* need at least one fs location */ | |||
| 3171 | if (nmp->nm_locations.nl_numlocs < 1) | |||
| 3172 | error = EINVAL22; | |||
| 3173 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3174 | ||||
| 3175 | /* init mount's mntfromname to first location */ | |||
| 3176 | if (!NM_OMATTR_GIVEN(nmp, MNTFROM)(((uint32_t *)((nmp)->nm_mattrs))[(23)/32] & (1<< ((23)%32)))) | |||
| 3177 | nfs_location_mntfromname(&nmp->nm_locations, firstloc, | |||
| 3178 | vfs_statfs(mp)->f_mntfromname, sizeof(vfs_statfs(mp)->f_mntfromname), 0); | |||
| 3179 | ||||
| 3180 | /* Need to save the mounting credential for v4. */ | |||
| 3181 | nmp->nm_mcred = vfs_context_ucred(ctx); | |||
| 3182 | if (IS_VALID_CRED(nmp->nm_mcred)((nmp->nm_mcred) != ((kauth_cred_t )0) && (nmp-> nm_mcred) != ((kauth_cred_t )-1))) | |||
| 3183 | kauth_cred_ref(nmp->nm_mcred); | |||
| 3184 | ||||
| 3185 | /* | |||
| 3186 | * If a reserved port is required, check for that privilege. | |||
| 3187 | * (Note that mirror mounts are exempt because the privilege was | |||
| 3188 | * already checked for the original mount.) | |||
| 3189 | */ | |||
| 3190 | if (NMFLAG(nmp, RESVPORT)(((uint32_t *)((nmp)->nm_flags))[(2)/32] & (1<<( (2)%32))) && !vfs_iskernelmount(mp)) | |||
| 3191 | error = priv_check_cred(nmp->nm_mcred, PRIV_NETINET_RESERVEDPORT11000, 0); | |||
| 3192 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3193 | ||||
| 3194 | /* do mount's initial socket connection */ | |||
| 3195 | error = nfs_mount_connect(nmp); | |||
| 3196 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3197 | ||||
| 3198 | /* set up the version-specific function tables */ | |||
| 3199 | if (nmp->nm_vers < NFS_VER44) | |||
| 3200 | nmp->nm_funcs = &nfs3_funcs; | |||
| 3201 | else | |||
| 3202 | nmp->nm_funcs = &nfs4_funcs; | |||
| 3203 | ||||
| 3204 | /* sanity check settings now that version/connection is set */ | |||
| 3205 | if (nmp->nm_vers == NFS_VER22) /* ignore RDIRPLUS on NFSv2 */ | |||
| 3206 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_RDIRPLUS)(((uint32_t *)(nmp->nm_flags))[(6)/32] &= ~(1<<( (6)%32))); | |||
| 3207 | if (nmp->nm_vers >= NFS_VER44) { | |||
| 3208 | if (NFS_BITMAP_ISSET(nmp->nm_flags, NFS_MFLAG_ACLONLY)(((uint32_t *)(nmp->nm_flags))[(13)/32] & (1<<(( 13)%32)))) /* aclonly trumps noacl */ | |||
| 3209 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NOACL)(((uint32_t *)(nmp->nm_flags))[(12)/32] &= ~(1<< ((12)%32))); | |||
| 3210 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_CALLUMNT)(((uint32_t *)(nmp->nm_flags))[(5)/32] &= ~(1<<( (5)%32))); | |||
| 3211 | if (nmp->nm_lockmode != NFS_LOCK_MODE_ENABLED0) | |||
| 3212 | error = EINVAL22; /* disabled/local lock mode only allowed on v2/v3 */ | |||
| 3213 | } else { | |||
| 3214 | /* ignore these if not v4 */ | |||
| 3215 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NOCALLBACK)(((uint32_t *)(nmp->nm_flags))[(10)/32] &= ~(1<< ((10)%32))); | |||
| 3216 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NONAMEDATTR)(((uint32_t *)(nmp->nm_flags))[(11)/32] &= ~(1<< ((11)%32))); | |||
| 3217 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NOACL)(((uint32_t *)(nmp->nm_flags))[(12)/32] &= ~(1<< ((12)%32))); | |||
| 3218 | NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_ACLONLY)(((uint32_t *)(nmp->nm_flags))[(13)/32] &= ~(1<< ((13)%32))); | |||
| 3219 | } | |||
| 3220 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3221 | ||||
| 3222 | if (nmp->nm_sotype == SOCK_DGRAM2) { | |||
| 3223 | /* I/O size defaults for UDP are different */ | |||
| 3224 | if (!NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READ_SIZE)(((uint32_t *)(mattrs))[(3)/32] & (1<<((3)%32)))) | |||
| 3225 | nmp->nm_rsize = NFS_DGRAM_RSIZE8192; | |||
| 3226 | if (!NFS_BITMAP_ISSET(mattrs, NFS_MATTR_WRITE_SIZE)(((uint32_t *)(mattrs))[(4)/32] & (1<<((4)%32)))) | |||
| 3227 | nmp->nm_wsize = NFS_DGRAM_WSIZE8192; | |||
| 3228 | } | |||
| 3229 | ||||
| 3230 | /* round down I/O sizes to multiple of NFS_FABLKSIZE */ | |||
| 3231 | nmp->nm_rsize &= ~(NFS_FABLKSIZE512 - 1); | |||
| 3232 | if (nmp->nm_rsize <= 0) | |||
| 3233 | nmp->nm_rsize = NFS_FABLKSIZE512; | |||
| 3234 | nmp->nm_wsize &= ~(NFS_FABLKSIZE512 - 1); | |||
| 3235 | if (nmp->nm_wsize <= 0) | |||
| 3236 | nmp->nm_wsize = NFS_FABLKSIZE512; | |||
| 3237 | ||||
| 3238 | /* and limit I/O sizes to maximum allowed */ | |||
| 3239 | maxio = (nmp->nm_vers == NFS_VER22) ? NFS_V2MAXDATA8192 : | |||
| 3240 | (nmp->nm_sotype == SOCK_DGRAM2) ? NFS_MAXDGRAMDATA16384 : NFS_MAXDATA(64*1024); | |||
| 3241 | if (maxio > NFS_MAXBSIZE(32 * 4096)) | |||
| 3242 | maxio = NFS_MAXBSIZE(32 * 4096); | |||
| 3243 | if (nmp->nm_rsize > maxio) | |||
| 3244 | nmp->nm_rsize = maxio; | |||
| 3245 | if (nmp->nm_wsize > maxio) | |||
| 3246 | nmp->nm_wsize = maxio; | |||
| 3247 | ||||
| 3248 | if (nmp->nm_readdirsize > maxio) | |||
| 3249 | nmp->nm_readdirsize = maxio; | |||
| 3250 | if (nmp->nm_readdirsize > nmp->nm_rsize) | |||
| 3251 | nmp->nm_readdirsize = nmp->nm_rsize; | |||
| 3252 | ||||
| 3253 | /* Set up the sockets and related info */ | |||
| 3254 | if (nmp->nm_sotype == SOCK_DGRAM2) | |||
| 3255 | TAILQ_INIT(&nmp->nm_cwndq)do { (((&nmp->nm_un.v3.udp_cwndq))->tqh_first) = (( void *)0); (&nmp->nm_un.v3.udp_cwndq)->tqh_last = & (((&nmp->nm_un.v3.udp_cwndq))->tqh_first); ; } while (0); | |||
| 3256 | ||||
| 3257 | /* | |||
| 3258 | * Get the root node/attributes from the NFS server and | |||
| 3259 | * do any basic, version-specific setup. | |||
| 3260 | */ | |||
| 3261 | error = nmp->nm_funcs->nf_mount(nmp, ctx, &np); | |||
| 3262 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3263 | ||||
| 3264 | /* | |||
| 3265 | * A reference count is needed on the node representing the | |||
| 3266 | * remote root. If this object is not persistent, then backward | |||
| 3267 | * traversals of the mount point (i.e. "..") will not work if | |||
| 3268 | * the node gets flushed out of the cache. | |||
| 3269 | */ | |||
| 3270 | nmp->nm_dnp = np; | |||
| 3271 | *vpp = NFSTOV(np)((np)->n_vnode); | |||
| 3272 | /* get usecount and drop iocount */ | |||
| 3273 | error = vnode_ref(*vpp); | |||
| 3274 | vnode_put(*vpp); | |||
| 3275 | if (error) { | |||
| 3276 | vnode_recycle(*vpp); | |||
| 3277 | goto nfsmerr; | |||
| 3278 | } | |||
| 3279 | ||||
| 3280 | /* | |||
| 3281 | * Do statfs to ensure static info gets set to reasonable values. | |||
| 3282 | */ | |||
| 3283 | if ((error = nmp->nm_funcs->nf_update_statfs(nmp, ctx))) { | |||
| 3284 | int error2 = vnode_getwithref(*vpp); | |||
| 3285 | vnode_rele(*vpp); | |||
| 3286 | if (!error2) | |||
| 3287 | vnode_put(*vpp); | |||
| 3288 | vnode_recycle(*vpp); | |||
| 3289 | goto nfsmerr; | |||
| 3290 | } | |||
| 3291 | sbp = vfs_statfs(mp); | |||
| 3292 | sbp->f_bsize = nmp->nm_fsattr.nfsa_bsize; | |||
| 3293 | sbp->f_blocks = nmp->nm_fsattr.nfsa_space_total / sbp->f_bsize; | |||
| 3294 | sbp->f_bfree = nmp->nm_fsattr.nfsa_space_free / sbp->f_bsize; | |||
| 3295 | sbp->f_bavail = nmp->nm_fsattr.nfsa_space_avail / sbp->f_bsize; | |||
| 3296 | sbp->f_bused = (nmp->nm_fsattr.nfsa_space_total / sbp->f_bsize) - | |||
| 3297 | (nmp->nm_fsattr.nfsa_space_free / sbp->f_bsize); | |||
| 3298 | sbp->f_files = nmp->nm_fsattr.nfsa_files_total; | |||
| 3299 | sbp->f_ffree = nmp->nm_fsattr.nfsa_files_free; | |||
| 3300 | sbp->f_iosize = nfs_iosize; | |||
| 3301 | ||||
| 3302 | /* | |||
| 3303 | * Calculate the size used for I/O buffers. Use the larger | |||
| 3304 | * of the two sizes to minimise NFS requests but make sure | |||
| 3305 | * that it is at least one VM page to avoid wasting buffer | |||
| 3306 | * space and to allow easy mmapping of I/O buffers. | |||
| 3307 | * The read/write RPC calls handle the splitting up of | |||
| 3308 | * buffers into multiple requests if the buffer size is | |||
| 3309 | * larger than the I/O size. | |||
| 3310 | */ | |||
| 3311 | iosize = max(nmp->nm_rsize, nmp->nm_wsize); | |||
| 3312 | if (iosize < PAGE_SIZE4096) | |||
| 3313 | iosize = PAGE_SIZE4096; | |||
| 3314 | nmp->nm_biosize = trunc_page_32(iosize)((uint32_t)(iosize) & ~((uint32_t)(4096 - 1))); | |||
| 3315 | ||||
| 3316 | /* For NFSv3 and greater, there is a (relatively) reliable ACCESS call. */ | |||
| 3317 | if (nmp->nm_vers > NFS_VER22) | |||
| 3318 | vfs_setauthopaqueaccess(mp); | |||
| 3319 | ||||
| 3320 | switch (nmp->nm_lockmode) { | |||
| 3321 | case NFS_LOCK_MODE_DISABLED1: | |||
| 3322 | break; | |||
| 3323 | case NFS_LOCK_MODE_LOCAL2: | |||
| 3324 | vfs_setlocklocal(nmp->nm_mountp); | |||
| 3325 | break; | |||
| 3326 | case NFS_LOCK_MODE_ENABLED0: | |||
| 3327 | default: | |||
| 3328 | if (nmp->nm_vers <= NFS_VER33) | |||
| 3329 | nfs_lockd_mount_register(nmp); | |||
| 3330 | break; | |||
| 3331 | } | |||
| 3332 | ||||
| 3333 | /* success! */ | |||
| 3334 | lck_mtx_lock(&nmp->nm_lock); | |||
| 3335 | nmp->nm_state |= NFSSTA_MOUNTED0x00004000; | |||
| 3336 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 3337 | return (0); | |||
| 3338 | nfsmerr: | |||
| 3339 | nfs_mount_drain_and_cleanup(nmp); | |||
| 3340 | return (error); | |||
| 3341 | } | |||
| 3342 | ||||
| 3343 | #if CONFIG_TRIGGERS1 | |||
| 3344 | ||||
| 3345 | /* | |||
| 3346 | * We've detected a file system boundary on the server and | |||
| 3347 | * need to mount a new file system so that our file systems | |||
| 3348 | * MIRROR the file systems on the server. | |||
| 3349 | * | |||
| 3350 | * Build the mount arguments for the new mount and call kernel_mount(). | |||
| 3351 | */ | |||
| 3352 | int | |||
| 3353 | nfs_mirror_mount_domount(vnode_t dvp, vnode_t vp, vfs_context_t ctx) | |||
| 3354 | { | |||
| 3355 | nfsnode_t np = VTONFS(vp)((nfsnode_t)vnode_fsnode(vp)); | |||
| 3356 | nfsnode_t dnp = VTONFS(dvp)((nfsnode_t)vnode_fsnode(dvp)); | |||
| 3357 | struct nfsmount *nmp = NFSTONMP(np)((vnode_mount(((np)->n_vnode))) ? ((struct nfsmount *)vfs_fsprivate (vnode_mount(((np)->n_vnode)))) : ((void *)0)); | |||
| 3358 | char fstype[MFSTYPENAMELEN16], *mntfromname = NULL((void *)0), *path = NULL((void *)0), *relpath, *p, *cp; | |||
| 3359 | int error = 0, pathbuflen = MAXPATHLEN1024, i, mntflags = 0, referral, skipcopy = 0; | |||
| 3360 | size_t nlen; | |||
| 3361 | struct xdrbuf xb, xbnew; | |||
| 3362 | uint32_t mattrs[NFS_MATTR_BITMAP_LEN1]; | |||
| 3363 | uint32_t newmattrs[NFS_MATTR_BITMAP_LEN1]; | |||
| 3364 | uint32_t newmflags[NFS_MFLAG_BITMAP_LEN1]; | |||
| 3365 | uint32_t newmflags_mask[NFS_MFLAG_BITMAP_LEN1]; | |||
| 3366 | uint32_t argslength = 0, val, count, mlen, mlen2, rlen, relpathcomps; | |||
| 3367 | uint32_t argslength_offset, attrslength_offset, end_offset; | |||
| 3368 | uint32_t numlocs, loc, numserv, serv, numaddr, addr, numcomp, comp; | |||
| 3369 | char buf[XDRWORD4]; | |||
| 3370 | struct nfs_fs_locations nfsls; | |||
| 3371 | ||||
| 3372 | referral = (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL0x0010); | |||
| 3373 | if (referral) | |||
| 3374 | bzero(&nfsls, sizeof(nfsls)); | |||
| 3375 | ||||
| 3376 | xb_init(&xbnew, 0); | |||
| 3377 | ||||
| 3378 | if (!nmp || (nmp->nm_state & (NFSSTA_FORCE0x00020000|NFSSTA_DEAD0x04000000))) | |||
| 3379 | return (ENXIO6); | |||
| 3380 | ||||
| 3381 | /* allocate a couple path buffers we need */ | |||
| 3382 | MALLOC_ZONE(mntfromname, char *, pathbuflen, M_NAMEI, M_WAITOK)(mntfromname) = (char *)({ static vm_allocation_site_t site __attribute__ ((section("__DATA, __data"))); __MALLOC_ZONE(pathbuflen, 12, 0x0000 , &site); }); | |||
| 3383 | if (!mntfromname) { | |||
| 3384 | error = ENOMEM12; | |||
| 3385 | goto nfsmerr; | |||
| 3386 | } | |||
| 3387 | MALLOC_ZONE(path, char *, pathbuflen, M_NAMEI, M_WAITOK)(path) = (char *)({ static vm_allocation_site_t site __attribute__ ((section("__DATA, __data"))); __MALLOC_ZONE(pathbuflen, 12, 0x0000 , &site); }); | |||
| 3388 | if (!path) { | |||
| 3389 | error = ENOMEM12; | |||
| 3390 | goto nfsmerr; | |||
| 3391 | } | |||
| 3392 | ||||
| 3393 | /* get the path for the directory being mounted on */ | |||
| 3394 | error = vn_getpath(vp, path, &pathbuflen); | |||
| 3395 | if (error) { | |||
| 3396 | error = ENOMEM12; | |||
| 3397 | goto nfsmerr; | |||
| 3398 | } | |||
| 3399 | ||||
| 3400 | /* | |||
| 3401 | * Set up the mntfromname for the new mount based on the | |||
| 3402 | * current mount's mntfromname and the directory's path | |||
| 3403 | * relative to the current mount's mntonname. | |||
| 3404 | * Set up relpath to point at the relative path on the current mount. | |||
| 3405 | * Also, count the number of components in relpath. | |||
| 3406 | * We'll be adding those to each fs location path in the new args. | |||
| 3407 | */ | |||
| 3408 | nlen = strlcpy(mntfromname, vfs_statfs(nmp->nm_mountp)->f_mntfromname, MAXPATHLEN1024); | |||
| 3409 | if ((nlen > 0) && (mntfromname[nlen-1] == '/')) { /* avoid double '/' in new name */ | |||
| 3410 | mntfromname[nlen-1] = '\0'; | |||
| 3411 | nlen--; | |||
| 3412 | } | |||
| 3413 | relpath = mntfromname + nlen; | |||
| 3414 | nlen = strlcat(mntfromname, path + strlen(vfs_statfs(nmp->nm_mountp)->f_mntonname), MAXPATHLEN1024); | |||
| 3415 | if (nlen >= MAXPATHLEN1024) { | |||
| 3416 | error = ENAMETOOLONG63; | |||
| 3417 | goto nfsmerr; | |||
| 3418 | } | |||
| 3419 | /* count the number of components in relpath */ | |||
| 3420 | p = relpath; | |||
| 3421 | while (*p && (*p == '/')) | |||
| 3422 | p++; | |||
| 3423 | relpathcomps = 0; | |||
| 3424 | while (*p) { | |||
| 3425 | relpathcomps++; | |||
| 3426 | while (*p && (*p != '/')) | |||
| 3427 | p++; | |||
| 3428 | while (*p && (*p == '/')) | |||
| 3429 | p++; | |||
| 3430 | } | |||
| 3431 | ||||
| 3432 | /* grab a copy of the file system type */ | |||
| 3433 | vfs_name(vnode_mount(vp), fstype); | |||
| 3434 | ||||
| 3435 | /* for referrals, fetch the fs locations */ | |||
| 3436 | if (referral) { | |||
| 3437 | const char *vname = vnode_getname(NFSTOV(np)((np)->n_vnode)); | |||
| 3438 | if (!vname) { | |||
| 3439 | error = ENOENT2; | |||
| 3440 | } else { | |||
| 3441 | error = nfs4_get_fs_locations(nmp, dnp, NULL((void *)0), 0, vname, ctx, &nfsls); | |||
| 3442 | vnode_putname(vname); | |||
| 3443 | if (!error && (nfsls.nl_numlocs < 1)) | |||
| 3444 | error = ENOENT2; | |||
| 3445 | } | |||
| 3446 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3447 | } | |||
| 3448 | ||||
| 3449 | /* set up NFS mount args based on current mount args */ | |||
| 3450 | ||||
| 3451 | #define xb_copy_32(E, XBSRC, XBDST, V)do { if (E) break; do { uint32_t __tmp; if ((E)) break; ((E)) = xb_get_bytes(((XBSRC)), (char*)&__tmp, 4, 0); if ((E)) break; ((V)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if ((E)) break ; __tmp = ((__builtin_constant_p((uint32_t)((V))) ? ((__uint32_t )((((__uint32_t)((uint32_t)((V))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((V))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((V))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((V))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((V))))); ((E)) = xb_add_bytes (((XBDST)), (void*)&__tmp, 4, 0); } while (0); } while (0 ) \ | |||
| 3452 | do { \ | |||
| 3453 | if (E) break; \ | |||
| 3454 | xb_get_32((E), (XBSRC), (V))do { uint32_t __tmp; if ((E)) break; ((E)) = xb_get_bytes(((XBSRC )), (char*)&__tmp, 4, 0); if ((E)) break; ((V)) = ((uint32_t )(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t)(((( __uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); \ | |||
| 3455 | if (skipcopy) break; \ | |||
| 3456 | xb_add_32((E), (XBDST), (V))do { uint32_t __tmp; if ((E)) break; __tmp = ((__builtin_constant_p ((uint32_t)((V))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(( V))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((V))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((V))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((V))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((V))))); ((E)) = xb_add_bytes(((XBDST)), (void*)&__tmp, 4, 0); } while (0); \ | |||
| 3457 | } while (0) | |||
| 3458 | #define xb_copy_opaque(E, XBSRC, XBDST)do { uint32_t __count, __val; do { if ((E)) break; do { uint32_t __tmp; if (((E))) break; (((E))) = xb_get_bytes((((XBSRC))), (char*)&__tmp, 4, 0); if (((E))) break; ((__count)) = (( uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if ( skipcopy) break; do { uint32_t __tmp; if (((E))) break; __tmp = ((__builtin_constant_p((uint32_t)((__count))) ? ((__uint32_t )((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__count))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__count))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__count))))); ((( E))) = xb_add_bytes((((XBDST))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (E) break; __count = (((__count)+3)& (~0x3)); __count /= 4; while (__count-- > 0) do { if ((E)) break; do { uint32_t __tmp; if (((E))) break; (((E))) = xb_get_bytes ((((XBSRC))), (char*)&__tmp, 4, 0); if (((E))) break; ((__val )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((E))) break ; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t )((((__uint32_t)((uint32_t)((__val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((E))) = xb_add_bytes ((((XBDST))), (void*)&__tmp, 4, 0); } while (0); } while ( 0); } while (0) \ | |||
| 3459 | do { \ | |||
| 3460 | uint32_t __count, __val; \ | |||
| 3461 | xb_copy_32((E), (XBSRC), (XBDST), __count)do { if ((E)) break; do { uint32_t __tmp; if (((E))) break; ( ((E))) = xb_get_bytes((((XBSRC))), (char*)&__tmp, 4, 0); if (((E))) break; ((__count)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if (((E))) break; __tmp = ((__builtin_constant_p((uint32_t) ((__count))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((__count))) & 0x00ff0000) >> 8) | (((__uint32_t)( (uint32_t)((__count))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((E))) = xb_add_bytes((((XBDST))) , (void*)&__tmp, 4, 0); } while (0); } while (0); \ | |||
| 3462 | if (E) break; \ | |||
| 3463 | __count = nfsm_rndup(__count)(((__count)+3)&(~0x3)); \ | |||
| 3464 | __count /= XDRWORD4; \ | |||
| 3465 | while (__count-- > 0) \ | |||
| 3466 | xb_copy_32((E), (XBSRC), (XBDST), __val)do { if ((E)) break; do { uint32_t __tmp; if (((E))) break; ( ((E))) = xb_get_bytes((((XBSRC))), (char*)&__tmp, 4, 0); if (((E))) break; ((__val)) = ((uint32_t)(__builtin_constant_p( (uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)( __tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if (((E))) break; __tmp = ((__builtin_constant_p((uint32_t) ((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val)) ) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)( (__val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((__val))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((__val))) & 0x000000ff) << 24))) : _OSSwapInt32(( uint32_t)((__val))))); (((E))) = xb_add_bytes((((XBDST))), (void *)&__tmp, 4, 0); } while (0); } while (0); \ | |||
| 3467 | } while (0) | |||
| 3468 | ||||
| 3469 | xb_init_buffer(&xb, nmp->nm_args, 2*XDRWORD4); | |||
| 3470 | xb_get_32(error, &xb, val)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (val) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* version */ | |||
| 3471 | xb_get_32(error, &xb, argslength)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (argslength ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* args length */ | |||
| 3472 | xb_init_buffer(&xb, nmp->nm_args, argslength); | |||
| 3473 | ||||
| 3474 | xb_init_buffer(&xbnew, NULL((void *)0), 0); | |||
| 3475 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); /* version */ | |||
| 3476 | argslength_offset = xb_offset(&xbnew); | |||
| 3477 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); /* args length */ | |||
| 3478 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); /* XDR args version */ | |||
| 3479 | count = NFS_MATTR_BITMAP_LEN1; | |||
| 3480 | xb_get_bitmap(error, &xb, mattrs, count)do { uint32_t __len = 0, __i; do { uint32_t __tmp; if (((error ))) break; (((error))) = xb_get_bytes((((&xb))), (char*)& __tmp, 4, 0); if (((error))) break; (__len) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (__i=0; __i < (((__len)<((uint32_t)((count))))?(__len):((uint32_t) ((count)))); __i++) do { uint32_t __tmp; if (((error))) break ; (((error))) = xb_get_bytes((((&xb))), (char*)&__tmp , 4, 0); if (((error))) break; (((mattrs))[__i]) = ((uint32_t )(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t)(((( __uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if ( (error)) break; for (; __i < __len; __i++) do { if (((error ))) break; (((error))) = xb_advance((((&xb))), (4)); } while (0); for (; __i < (uint32_t)((count)); __i++) ((mattrs))[ __i] = 0; ((count)) = __len; } while (0); /* mount attribute bitmap */ | |||
| 3481 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3482 | for (i = 0; i < NFS_MATTR_BITMAP_LEN1; i++) | |||
| 3483 | newmattrs[i] = mattrs[i]; | |||
| 3484 | if (referral) | |||
| 3485 | NFS_BITMAP_SET(newmattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(newmattrs))[(21)/32] |= 1<<((21)%32)); | |||
| 3486 | else | |||
| 3487 | NFS_BITMAP_SET(newmattrs, NFS_MATTR_FH)(((uint32_t *)(newmattrs))[(20)/32] |= 1<<((20)%32)); | |||
| 3488 | NFS_BITMAP_SET(newmattrs, NFS_MATTR_FLAGS)(((uint32_t *)(newmattrs))[(0)/32] |= 1<<((0)%32)); | |||
| 3489 | NFS_BITMAP_SET(newmattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(newmattrs))[(22)/32] |= 1<<((22)%32)); | |||
| 3490 | NFS_BITMAP_CLR(newmattrs, NFS_MATTR_MNTFROM)(((uint32_t *)(newmattrs))[(23)/32] &= ~(1<<((23)%32 ))); | |||
| 3491 | xb_add_bitmap(error, &xbnew, newmattrs, NFS_MATTR_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbnew))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((newmattrs))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((newmattrs))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((newmattrs))[__i])) & 0x00ff0000) >> 8 ) | (((__uint32_t)((uint32_t)(((newmattrs))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((newmattrs))[__i]) ) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)( ((newmattrs))[__i])))); (((error))) = xb_add_bytes((((&xbnew ))), (void*)&__tmp, 4, 0); } while (0); } while (0); | |||
| 3492 | attrslength_offset = xb_offset(&xbnew); | |||
| 3493 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); /* attrs length */ | |||
| 3494 | NFS_BITMAP_ZERO(newmflags_mask, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(newmflags_mask ))[__i] = 0; } while (0); | |||
| 3495 | NFS_BITMAP_ZERO(newmflags, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(newmflags ))[__i] = 0; } while (0); | |||
| 3496 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FLAGS)(((uint32_t *)(mattrs))[(0)/32] & (1<<((0)%32)))) { | |||
| 3497 | count = NFS_MFLAG_BITMAP_LEN1; | |||
| 3498 | xb_get_bitmap(error, &xb, newmflags_mask, count)do { uint32_t __len = 0, __i; do { uint32_t __tmp; if (((error ))) break; (((error))) = xb_get_bytes((((&xb))), (char*)& __tmp, 4, 0); if (((error))) break; (__len) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (__i=0; __i < (((__len)<((uint32_t)((count))))?(__len):((uint32_t) ((count)))); __i++) do { uint32_t __tmp; if (((error))) break ; (((error))) = xb_get_bytes((((&xb))), (char*)&__tmp , 4, 0); if (((error))) break; (((newmflags_mask))[__i]) = (( uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if ( (error)) break; for (; __i < __len; __i++) do { if (((error ))) break; (((error))) = xb_advance((((&xb))), (4)); } while (0); for (; __i < (uint32_t)((count)); __i++) ((newmflags_mask ))[__i] = 0; ((count)) = __len; } while (0); /* mount flag mask bitmap */ | |||
| 3499 | count = NFS_MFLAG_BITMAP_LEN1; | |||
| 3500 | xb_get_bitmap(error, &xb, newmflags, count)do { uint32_t __len = 0, __i; do { uint32_t __tmp; if (((error ))) break; (((error))) = xb_get_bytes((((&xb))), (char*)& __tmp, 4, 0); if (((error))) break; (__len) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if ((error)) break; for (__i=0; __i < (((__len)<((uint32_t)((count))))?(__len):((uint32_t) ((count)))); __i++) do { uint32_t __tmp; if (((error))) break ; (((error))) = xb_get_bytes((((&xb))), (char*)&__tmp , 4, 0); if (((error))) break; (((newmflags))[__i]) = ((uint32_t )(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t)(((( __uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if ( (error)) break; for (; __i < __len; __i++) do { if (((error ))) break; (((error))) = xb_advance((((&xb))), (4)); } while (0); for (; __i < (uint32_t)((count)); __i++) ((newmflags ))[__i] = 0; ((count)) = __len; } while (0); /* mount flag bitmap */ | |||
| 3501 | } | |||
| 3502 | NFS_BITMAP_SET(newmflags_mask, NFS_MFLAG_EPHEMERAL)(((uint32_t *)(newmflags_mask))[(9)/32] |= 1<<((9)%32)); | |||
| 3503 | NFS_BITMAP_SET(newmflags, NFS_MFLAG_EPHEMERAL)(((uint32_t *)(newmflags))[(9)/32] |= 1<<((9)%32)); | |||
| 3504 | xb_add_bitmap(error, &xbnew, newmflags_mask, NFS_MFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbnew))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((newmflags_mask))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((newmflags_mask))[__i])) & 0xff000000) >> 24) | ( ((__uint32_t)((uint32_t)(((newmflags_mask))[__i])) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(((newmflags_mask))[ __i])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(((newmflags_mask))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((newmflags_mask))[__i])))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); | |||
| 3505 | xb_add_bitmap(error, &xbnew, newmflags, NFS_MFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbnew))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((newmflags))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((newmflags))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((newmflags))[__i])) & 0x00ff0000) >> 8 ) | (((__uint32_t)((uint32_t)(((newmflags))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((newmflags))[__i]) ) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)( ((newmflags))[__i])))); (((error))) = xb_add_bytes((((&xbnew ))), (void*)&__tmp, 4, 0); } while (0); } while (0); | |||
| 3506 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] & (1<<((1)%32)))) | |||
| 3507 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3508 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_MINOR_VERSION)(((uint32_t *)(mattrs))[(2)/32] & (1<<((2)%32)))) | |||
| 3509 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3510 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_VERSION_RANGE)(((uint32_t *)(mattrs))[(27)/32] & (1<<((27)%32)))) { | |||
| 3511 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3512 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3513 | } | |||
| 3514 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READ_SIZE)(((uint32_t *)(mattrs))[(3)/32] & (1<<((3)%32)))) | |||
| 3515 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3516 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_WRITE_SIZE)(((uint32_t *)(mattrs))[(4)/32] & (1<<((4)%32)))) | |||
| 3517 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3518 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READDIR_SIZE)(((uint32_t *)(mattrs))[(5)/32] & (1<<((5)%32)))) | |||
| 3519 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3520 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_READAHEAD)(((uint32_t *)(mattrs))[(6)/32] & (1<<((6)%32)))) | |||
| 3521 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3522 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_REG_MIN)(((uint32_t *)(mattrs))[(7)/32] & (1<<((7)%32)))) { | |||
| 3523 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3524 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3525 | } | |||
| 3526 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_REG_MAX)(((uint32_t *)(mattrs))[(8)/32] & (1<<((8)%32)))) { | |||
| 3527 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3528 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3529 | } | |||
| 3530 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MIN)(((uint32_t *)(mattrs))[(9)/32] & (1<<((9)%32)))) { | |||
| 3531 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3532 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3533 | } | |||
| 3534 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MAX)(((uint32_t *)(mattrs))[(10)/32] & (1<<((10)%32)))) { | |||
| 3535 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3536 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3537 | } | |||
| 3538 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_LOCK_MODE)(((uint32_t *)(mattrs))[(11)/32] & (1<<((11)%32)))) | |||
| 3539 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3540 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SECURITY)(((uint32_t *)(mattrs))[(12)/32] & (1<<((12)%32)))) { | |||
| 3541 | xb_copy_32(error, &xb, &xbnew, count)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((count)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((count))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((count) )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) ((count))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((count))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((count))) & 0x000000ff) << 24))) : _OSSwapInt32(( uint32_t)((count))))); ((error)) = xb_add_bytes(((&xbnew) ), (void*)&__tmp, 4, 0); } while (0); } while (0); | |||
| 3542 | while (!error && (count-- > 0)) | |||
| 3543 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3544 | } | |||
| 3545 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_KERB_ETYPE)(((uint32_t *)(mattrs))[(28)/32] & (1<<((28)%32)))) { | |||
| 3546 | xb_copy_32(error, &xb, &xbnew, count)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((count)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((count))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((count) )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) ((count))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((count))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((count))) & 0x000000ff) << 24))) : _OSSwapInt32(( uint32_t)((count))))); ((error)) = xb_add_bytes(((&xbnew) ), (void*)&__tmp, 4, 0); } while (0); } while (0); | |||
| 3547 | xb_add_32(error, &xbnew, -1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(-1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(-1 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (-1)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(-1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(-1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(-1)))); (error) = xb_add_bytes((&xbnew), (void*)&__tmp , 4, 0); } while (0); | |||
| 3548 | while (!error && (count-- > 0)) | |||
| 3549 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3550 | } | |||
| 3551 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MAX_GROUP_LIST)(((uint32_t *)(mattrs))[(13)/32] & (1<<((13)%32)))) | |||
| 3552 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3553 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] & (1<<((14)%32)))) | |||
| 3554 | xb_copy_opaque(error, &xb, &xbnew)do { uint32_t __count, __val; do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes((((& xb))), (char*)&__tmp, 4, 0); if (((error))) break; ((__count )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__count)) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count ))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t) ((__count))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((error))) = xb_add_bytes((((& xbnew))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (error) break; __count = (((__count)+3)&(~0x3)); __count /= 4; while (__count-- > 0) do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes ((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break ; ((__val)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); } while (0); | |||
| 3555 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] & (1<<((15)%32)))) | |||
| 3556 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3557 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MOUNT_PORT)(((uint32_t *)(mattrs))[(16)/32] & (1<<((16)%32)))) | |||
| 3558 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3559 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_REQUEST_TIMEOUT)(((uint32_t *)(mattrs))[(17)/32] & (1<<((17)%32)))) { | |||
| 3560 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3561 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3562 | } | |||
| 3563 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SOFT_RETRY_COUNT)(((uint32_t *)(mattrs))[(18)/32] & (1<<((18)%32)))) | |||
| 3564 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3565 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_DEAD_TIMEOUT)(((uint32_t *)(mattrs))[(19)/32] & (1<<((19)%32)))) { | |||
| 3566 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3567 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3568 | } | |||
| 3569 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] & (1<<((20)%32)))) { | |||
| 3570 | xb_get_32(error, &xb, count)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (count ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3571 | xb_skip(error, &xb, count)do { if (error) break; (error) = xb_advance((&xb), (count )); } while (0); | |||
| 3572 | } | |||
| 3573 | if (!referral) { | |||
| 3574 | /* set the initial file handle to the directory's file handle */ | |||
| 3575 | xb_add_fh(error, &xbnew, np->n_fhp, np->n_fhsize)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((np->n_fhsize))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((np->n_fhsize))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((np ->n_fhsize))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((np->n_fhsize))))); ((error)) = xb_add_bytes(( (&xbnew)), (void*)&__tmp, 4, 0); } while (0); if (error ) break; (error) = xb_add_bytes((&xbnew), (char*)(np-> n_fhp), (np->n_fhsize), 0); } while (0); | |||
| 3576 | } | |||
| 3577 | /* copy/extend/skip fs locations */ | |||
| 3578 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] & (1<<((21)%32)))) { | |||
| 3579 | numlocs = numserv = numaddr = numcomp = 0; | |||
| 3580 | if (referral) /* don't copy the fs locations for a referral */ | |||
| 3581 | skipcopy = 1; | |||
| 3582 | xb_copy_32(error, &xb, &xbnew, numlocs)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((numlocs)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((numlocs))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((numlocs ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((numlocs))) & 0x00ff0000) >> 8) | (((__uint32_t)( (uint32_t)((numlocs))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numlocs))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numlocs))))); ((error)) = xb_add_bytes(((&xbnew )), (void*)&__tmp, 4, 0); } while (0); } while (0); /* location count */ | |||
| 3583 | for (loc = 0; !error && (loc < numlocs); loc++) { | |||
| 3584 | xb_copy_32(error, &xb, &xbnew, numserv)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((numserv)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((numserv))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((numserv ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((numserv))) & 0x00ff0000) >> 8) | (((__uint32_t)( (uint32_t)((numserv))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numserv))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numserv))))); ((error)) = xb_add_bytes(((&xbnew )), (void*)&__tmp, 4, 0); } while (0); } while (0); /* server count */ | |||
| 3585 | for (serv = 0; !error && (serv < numserv); serv++) { | |||
| 3586 | xb_copy_opaque(error, &xb, &xbnew)do { uint32_t __count, __val; do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes((((& xb))), (char*)&__tmp, 4, 0); if (((error))) break; ((__count )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__count)) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count ))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t) ((__count))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((error))) = xb_add_bytes((((& xbnew))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (error) break; __count = (((__count)+3)&(~0x3)); __count /= 4; while (__count-- > 0) do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes ((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break ; ((__val)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); } while (0); /* server name */ | |||
| 3587 | xb_copy_32(error, &xb, &xbnew, numaddr)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((numaddr)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((numaddr))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((numaddr ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((numaddr))) & 0x00ff0000) >> 8) | (((__uint32_t)( (uint32_t)((numaddr))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numaddr))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numaddr))))); ((error)) = xb_add_bytes(((&xbnew )), (void*)&__tmp, 4, 0); } while (0); } while (0); /* address count */ | |||
| 3588 | for (addr = 0; !error && (addr < numaddr); addr++) | |||
| 3589 | xb_copy_opaque(error, &xb, &xbnew)do { uint32_t __count, __val; do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes((((& xb))), (char*)&__tmp, 4, 0); if (((error))) break; ((__count )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__count)) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count ))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t) ((__count))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((error))) = xb_add_bytes((((& xbnew))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (error) break; __count = (((__count)+3)&(~0x3)); __count /= 4; while (__count-- > 0) do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes ((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break ; ((__val)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); } while (0); /* address */ | |||
| 3590 | xb_copy_opaque(error, &xb, &xbnew)do { uint32_t __count, __val; do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes((((& xb))), (char*)&__tmp, 4, 0); if (((error))) break; ((__count )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__count)) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count ))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t) ((__count))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((error))) = xb_add_bytes((((& xbnew))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (error) break; __count = (((__count)+3)&(~0x3)); __count /= 4; while (__count-- > 0) do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes ((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break ; ((__val)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); } while (0); /* server info */ | |||
| 3591 | } | |||
| 3592 | /* pathname */ | |||
| 3593 | xb_get_32(error, &xb, numcomp)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (numcomp ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* component count */ | |||
| 3594 | if (!skipcopy) | |||
| 3595 | xb_add_32(error, &xbnew, numcomp+relpathcomps)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(numcomp+relpathcomps)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(numcomp+relpathcomps)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(numcomp+relpathcomps)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(numcomp+ relpathcomps)) & 0x0000ff00) << 8) | (((__uint32_t) ((uint32_t)(numcomp+relpathcomps)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(numcomp+relpathcomps)))); (error ) = xb_add_bytes((&xbnew), (void*)&__tmp, 4, 0); } while (0); /* new component count */ | |||
| 3596 | for (comp = 0; !error && (comp < numcomp); comp++) | |||
| 3597 | xb_copy_opaque(error, &xb, &xbnew)do { uint32_t __count, __val; do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes((((& xb))), (char*)&__tmp, 4, 0); if (((error))) break; ((__count )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__count)) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count ))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t) ((__count))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((error))) = xb_add_bytes((((& xbnew))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (error) break; __count = (((__count)+3)&(~0x3)); __count /= 4; while (__count-- > 0) do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes ((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break ; ((__val)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); } while (0); /* component */ | |||
| 3598 | /* add additional components */ | |||
| 3599 | for (comp = 0; !skipcopy && !error && (comp < relpathcomps); comp++) { | |||
| 3600 | p = relpath; | |||
| 3601 | while (*p && (*p == '/')) | |||
| 3602 | p++; | |||
| 3603 | while (*p && !error) { | |||
| 3604 | cp = p; | |||
| 3605 | while (*p && (*p != '/')) | |||
| 3606 | p++; | |||
| 3607 | xb_add_string(error, &xbnew, cp, (p - cp))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)(((p - cp)))) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((p - cp)))) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((p - cp)))) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(((p - cp)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((p - cp)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((p - cp)))))); (( error)) = xb_add_bytes(((&xbnew)), (void*)&__tmp, 4, 0 ); } while (0); if (error) break; (error) = xb_add_bytes((& xbnew), (const char*)(cp), ((p - cp)), 0); } while (0); /* component */ | |||
| 3608 | while (*p && (*p == '/')) | |||
| 3609 | p++; | |||
| 3610 | } | |||
| 3611 | } | |||
| 3612 | xb_copy_opaque(error, &xb, &xbnew)do { uint32_t __count, __val; do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes((((& xb))), (char*)&__tmp, 4, 0); if (((error))) break; ((__count )) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? (( __uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__count)) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__count))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((__count ))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t) ((__count))) & 0x0000ff00) << 8) | (((__uint32_t)(( uint32_t)((__count))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((__count))))); (((error))) = xb_add_bytes((((& xbnew))), (void*)&__tmp, 4, 0); } while (0); } while (0); if (error) break; __count = (((__count)+3)&(~0x3)); __count /= 4; while (__count-- > 0) do { if ((error)) break; do { uint32_t __tmp; if (((error))) break; (((error))) = xb_get_bytes ((((&xb))), (char*)&__tmp, 4, 0); if (((error))) break ; ((__val)) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp; if (((error)) ) break; __tmp = ((__builtin_constant_p((uint32_t)((__val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((__val))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((__val))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((__val))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((__val))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((__val))))); (((error ))) = xb_add_bytes((((&xbnew))), (void*)&__tmp, 4, 0) ; } while (0); } while (0); } while (0); /* fs location info */ | |||
| 3613 | } | |||
| 3614 | if (referral) | |||
| 3615 | skipcopy = 0; | |||
| 3616 | } | |||
| 3617 | if (referral) { | |||
| 3618 | /* add referral's fs locations */ | |||
| 3619 | xb_add_32(error, &xbnew, nfsls.nl_numlocs)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nfsls.nl_numlocs)) ? ((__uint32_t)((((__uint32_t) ((uint32_t)(nfsls.nl_numlocs)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nfsls.nl_numlocs)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nfsls.nl_numlocs)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nfsls.nl_numlocs )) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t) (nfsls.nl_numlocs)))); (error) = xb_add_bytes((&xbnew), ( void*)&__tmp, 4, 0); } while (0); /* FS_LOCATIONS */ | |||
| 3620 | for (loc = 0; !error && (loc < nfsls.nl_numlocs); loc++) { | |||
| 3621 | xb_add_32(error, &xbnew, nfsls.nl_locations[loc]->nl_servcount)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nfsls.nl_locations[loc]->nl_servcount)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(nfsls.nl_locations[loc]->nl_servcount )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (nfsls.nl_locations[loc]->nl_servcount)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nfsls.nl_locations[loc ]->nl_servcount)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nfsls.nl_locations[loc]->nl_servcount)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nfsls.nl_locations [loc]->nl_servcount)))); (error) = xb_add_bytes((&xbnew ), (void*)&__tmp, 4, 0); } while (0); | |||
| 3622 | for (serv = 0; !error && (serv < nfsls.nl_locations[loc]->nl_servcount); serv++) { | |||
| 3623 | xb_add_string(error, &xbnew, nfsls.nl_locations[loc]->nl_servers[serv]->ns_name,do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nfsls.nl_locations[loc]->nl_servers[serv ]->ns_name)))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(( strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))))); ((error)) = xb_add_bytes(((&xbnew)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbnew), (const char*)(nfsls.nl_locations[loc]->nl_servers [serv]->ns_name), (strlen(nfsls.nl_locations[loc]->nl_servers [serv]->ns_name)), 0); } while (0) | |||
| 3624 | strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nfsls.nl_locations[loc]->nl_servers[serv ]->ns_name)))) ? ((__uint32_t)((((__uint32_t)((uint32_t)(( strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_name )))))); ((error)) = xb_add_bytes(((&xbnew)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbnew), (const char*)(nfsls.nl_locations[loc]->nl_servers [serv]->ns_name), (strlen(nfsls.nl_locations[loc]->nl_servers [serv]->ns_name)), 0); } while (0); | |||
| 3625 | xb_add_32(error, &xbnew, nfsls.nl_locations[loc]->nl_servers[serv]->ns_addrcount)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nfsls.nl_locations[loc]->nl_servers[serv]-> ns_addrcount)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(nfsls .nl_locations[loc]->nl_servers[serv]->ns_addrcount)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addrcount)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nfsls.nl_locations[ loc]->nl_servers[serv]->ns_addrcount)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(nfsls.nl_locations[ loc]->nl_servers[serv]->ns_addrcount)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addrcount)))); (error) = xb_add_bytes ((&xbnew), (void*)&__tmp, 4, 0); } while (0); | |||
| 3626 | for (addr = 0; !error && (addr < nfsls.nl_locations[loc]->nl_servers[serv]->ns_addrcount); addr++) | |||
| 3627 | xb_add_string(error, &xbnew, nfsls.nl_locations[loc]->nl_servers[serv]->ns_addresses[addr],do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nfsls.nl_locations[loc]->nl_servers[serv ]->ns_addresses[addr])))) ? ((__uint32_t)((((__uint32_t)(( uint32_t)((strlen(nfsls.nl_locations[loc]->nl_servers[serv ]->ns_addresses[addr])))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(nfsls.nl_locations[loc]-> nl_servers[serv]->ns_addresses[addr])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((strlen(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((strlen(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))))); ((error )) = xb_add_bytes(((&xbnew)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((&xbnew ), (const char*)(nfsls.nl_locations[loc]->nl_servers[serv] ->ns_addresses[addr]), (strlen(nfsls.nl_locations[loc]-> nl_servers[serv]->ns_addresses[addr])), 0); } while (0) | |||
| 3628 | strlen(nfsls.nl_locations[loc]->nl_servers[serv]->ns_addresses[addr]))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nfsls.nl_locations[loc]->nl_servers[serv ]->ns_addresses[addr])))) ? ((__uint32_t)((((__uint32_t)(( uint32_t)((strlen(nfsls.nl_locations[loc]->nl_servers[serv ]->ns_addresses[addr])))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(nfsls.nl_locations[loc]-> nl_servers[serv]->ns_addresses[addr])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((strlen(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((strlen(nfsls.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))))); ((error )) = xb_add_bytes(((&xbnew)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((&xbnew ), (const char*)(nfsls.nl_locations[loc]->nl_servers[serv] ->ns_addresses[addr]), (strlen(nfsls.nl_locations[loc]-> nl_servers[serv]->ns_addresses[addr])), 0); } while (0); | |||
| 3629 | xb_add_32(error, &xbnew, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbnew), (void*)&__tmp , 4, 0); } while (0); /* empty server info */ | |||
| 3630 | } | |||
| 3631 | xb_add_32(error, &xbnew, nfsls.nl_locations[loc]->nl_path.np_compcount)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nfsls.nl_locations[loc]->nl_path.np_compcount) ) ? ((__uint32_t)((((__uint32_t)((uint32_t)(nfsls.nl_locations [loc]->nl_path.np_compcount)) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)(nfsls.nl_locations[loc]->nl_path .np_compcount)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(nfsls.nl_locations[loc]->nl_path.np_compcount )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nfsls.nl_locations[loc]->nl_path.np_compcount)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(nfsls.nl_locations [loc]->nl_path.np_compcount)))); (error) = xb_add_bytes((& xbnew), (void*)&__tmp, 4, 0); } while (0); | |||
| 3632 | for (comp = 0; !error && (comp < nfsls.nl_locations[loc]->nl_path.np_compcount); comp++) | |||
| 3633 | xb_add_string(error, &xbnew, nfsls.nl_locations[loc]->nl_path.np_components[comp],do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nfsls.nl_locations[loc]->nl_path.np_components [comp])))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((strlen( nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen (nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen( nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((strlen (nfsls.nl_locations[loc]->nl_path.np_components[comp]))))) ); ((error)) = xb_add_bytes(((&xbnew)), (void*)&__tmp , 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbnew), (const char*)(nfsls.nl_locations[loc]->nl_path .np_components[comp]), (strlen(nfsls.nl_locations[loc]->nl_path .np_components[comp])), 0); } while (0) | |||
| 3634 | strlen(nfsls.nl_locations[loc]->nl_path.np_components[comp]))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nfsls.nl_locations[loc]->nl_path.np_components [comp])))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((strlen( nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen (nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen( nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( nfsls.nl_locations[loc]->nl_path.np_components[comp])))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((strlen (nfsls.nl_locations[loc]->nl_path.np_components[comp]))))) ); ((error)) = xb_add_bytes(((&xbnew)), (void*)&__tmp , 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbnew), (const char*)(nfsls.nl_locations[loc]->nl_path .np_components[comp]), (strlen(nfsls.nl_locations[loc]->nl_path .np_components[comp])), 0); } while (0); | |||
| 3635 | xb_add_32(error, &xbnew, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbnew), (void*)&__tmp , 4, 0); } while (0); /* empty fs location info */ | |||
| 3636 | } | |||
| 3637 | } | |||
| 3638 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] & (1<<((22)%32)))) | |||
| 3639 | xb_get_32(error, &xb, mntflags)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (mntflags ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3640 | /* | |||
| 3641 | * We add the following mount flags to the ones for the mounted-on mount: | |||
| 3642 | * MNT_DONTBROWSE - to keep the mount from showing up as a separate volume | |||
| 3643 | * MNT_AUTOMOUNTED - to keep DiskArb from retriggering the mount after | |||
| 3644 | * an unmount (looking for /.autodiskmounted) | |||
| 3645 | */ | |||
| 3646 | mntflags |= (MNT_AUTOMOUNTED0x00400000 | MNT_DONTBROWSE0x00100000); | |||
| 3647 | xb_add_32(error, &xbnew, mntflags)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(mntflags)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(mntflags)) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)(mntflags)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(mntflags)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(mntflags)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(mntflags)))); (error) = xb_add_bytes((&xbnew) , (void*)&__tmp, 4, 0); } while (0); | |||
| 3648 | if (!referral && NFS_BITMAP_ISSET(mattrs, NFS_MATTR_MNTFROM)(((uint32_t *)(mattrs))[(23)/32] & (1<<((23)%32)))) { | |||
| 3649 | /* copy mntfrom string and add relpath */ | |||
| 3650 | rlen = strlen(relpath); | |||
| 3651 | xb_get_32(error, &xb, mlen)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xb), (char*)&__tmp, 4, 0); if (error) break; (mlen ) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); | |||
| 3652 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3653 | mlen2 = mlen + ((relpath[0] != '/') ? 1 : 0) + rlen; | |||
| 3654 | xb_add_32(error, &xbnew, mlen2)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(mlen2)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (mlen2)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(mlen2)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(mlen2)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(mlen2)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(mlen2)))); (error) = xb_add_bytes((&xbnew), (void*)& __tmp, 4, 0); } while (0); | |||
| 3655 | count = mlen/XDRWORD4; | |||
| 3656 | /* copy the original string */ | |||
| 3657 | while (count-- > 0) | |||
| 3658 | xb_copy_32(error, &xb, &xbnew, val)do { if (error) break; do { uint32_t __tmp; if ((error)) break ; ((error)) = xb_get_bytes(((&xb)), (char*)&__tmp, 4, 0); if ((error)) break; ((val)) = ((uint32_t)(__builtin_constant_p ((uint32_t)(__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t) (__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(__tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); if (skipcopy) break; do { uint32_t __tmp ; if ((error)) break; __tmp = ((__builtin_constant_p((uint32_t )((val))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((val))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((val))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((val ))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) ((val))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((val))))); ((error)) = xb_add_bytes(((&xbnew)), (void*) &__tmp, 4, 0); } while (0); } while (0); | |||
| 3659 | if (!error && (mlen % XDRWORD4)) { | |||
| 3660 | error = xb_get_bytes(&xb, buf, mlen%XDRWORD4, 0); | |||
| 3661 | if (!error) | |||
| 3662 | error = xb_add_bytes(&xbnew, buf, mlen%XDRWORD4, 1); | |||
| 3663 | } | |||
| 3664 | /* insert a '/' if the relative path doesn't start with one */ | |||
| 3665 | if (!error && (relpath[0] != '/')) { | |||
| 3666 | buf[0] = '/'; | |||
| 3667 | error = xb_add_bytes(&xbnew, buf, 1, 1); | |||
| 3668 | } | |||
| 3669 | /* add the additional relative path */ | |||
| 3670 | if (!error) | |||
| 3671 | error = xb_add_bytes(&xbnew, relpath, rlen, 1); | |||
| 3672 | /* make sure the resulting string has the right number of pad bytes */ | |||
| 3673 | if (!error && (mlen2 != nfsm_rndup(mlen2)(((mlen2)+3)&(~0x3)))) { | |||
| 3674 | bzero(buf, sizeof(buf)); | |||
| 3675 | count = nfsm_rndup(mlen2)(((mlen2)+3)&(~0x3)) - mlen2; | |||
| 3676 | error = xb_add_bytes(&xbnew, buf, count, 1); | |||
| 3677 | } | |||
| 3678 | } | |||
| 3679 | xb_build_done(error, &xbnew)do { if (error) break; xb_set_cur_buf_len(&xbnew); } while (0); | |||
| 3680 | ||||
| 3681 | /* update opaque counts */ | |||
| 3682 | end_offset = xb_offset(&xbnew); | |||
| 3683 | if (!error) { | |||
| 3684 | error = xb_seek(&xbnew, argslength_offset); | |||
| 3685 | argslength = end_offset - argslength_offset + XDRWORD4/*version*/; | |||
| 3686 | xb_add_32(error, &xbnew, argslength)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(argslength)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(argslength)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(argslength)) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(argslength)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(argslength)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(argslength)))); (error ) = xb_add_bytes((&xbnew), (void*)&__tmp, 4, 0); } while (0); | |||
| 3687 | } | |||
| 3688 | if (!error) { | |||
| 3689 | error = xb_seek(&xbnew, attrslength_offset); | |||
| 3690 | xb_add_32(error, &xbnew, end_offset - attrslength_offset - XDRWORD/*don't include length field*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - attrslength_offset - 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - attrslength_offset - 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - attrslength_offset - 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - attrslength_offset - 4)))); (error) = xb_add_bytes((&xbnew), (void*)&__tmp , 4, 0); } while (0); | |||
| 3691 | } | |||
| 3692 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 3693 | ||||
| 3694 | /* | |||
| 3695 | * For kernel_mount() call, use the existing mount flags (instead of the | |||
| 3696 | * original flags) because flags like MNT_NOSUID and MNT_NODEV may have | |||
| 3697 | * been silently enforced. | |||
| 3698 | */ | |||
| 3699 | mntflags = vnode_vfsvisflags(vp); | |||
| 3700 | mntflags |= (MNT_AUTOMOUNTED0x00400000 | MNT_DONTBROWSE0x00100000); | |||
| 3701 | ||||
| 3702 | /* do the mount */ | |||
| 3703 | error = kernel_mount(fstype, dvp, vp, path, xb_buffer_base(&xbnew), argslength, | |||
| 3704 | mntflags, KERNEL_MOUNT_PERMIT_UNMOUNT0x02 | KERNEL_MOUNT_NOAUTH0x01, ctx); | |||
| 3705 | ||||
| 3706 | nfsmerr: | |||
| 3707 | if (error) | |||
| 3708 | printf("nfs: mirror mount of %s on %s failed (%d)\n", | |||
| 3709 | mntfromname, path, error); | |||
| 3710 | /* clean up */ | |||
| 3711 | xb_cleanup(&xbnew); | |||
| 3712 | if (referral) | |||
| 3713 | nfs_fs_locations_cleanup(&nfsls); | |||
| 3714 | if (path) | |||
| 3715 | FREE_ZONE(path, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)path, 1024, 12); | |||
| 3716 | if (mntfromname) | |||
| 3717 | FREE_ZONE(mntfromname, MAXPATHLEN, M_NAMEI)_FREE_ZONE((void *)mntfromname, 1024, 12); | |||
| 3718 | if (!error) | |||
| 3719 | nfs_ephemeral_mount_harvester_start(); | |||
| 3720 | return (error); | |||
| 3721 | } | |||
| 3722 | ||||
| 3723 | /* | |||
| 3724 | * trigger vnode functions | |||
| 3725 | */ | |||
| 3726 | ||||
| 3727 | resolver_result_t | |||
| 3728 | nfs_mirror_mount_trigger_resolve( | |||
| 3729 | vnode_t vp, | |||
| 3730 | const struct componentname *cnp, | |||
| 3731 | enum path_operation pop, | |||
| 3732 | __unused__attribute__((unused)) int flags, | |||
| 3733 | __unused__attribute__((unused)) void *data, | |||
| 3734 | vfs_context_t ctx) | |||
| 3735 | { | |||
| 3736 | nfsnode_t np = VTONFS(vp)((nfsnode_t)vnode_fsnode(vp)); | |||
| 3737 | vnode_t pvp = NULLVP((struct vnode *)((void *)0)); | |||
| 3738 | int error = 0; | |||
| 3739 | resolver_result_t result; | |||
| 3740 | ||||
| 3741 | /* | |||
| 3742 | * We have a trigger node that doesn't have anything mounted on it yet. | |||
| 3743 | * We'll do the mount if either: | |||
| 3744 | * (a) this isn't the last component of the path OR | |||
| 3745 | * (b) this is an op that looks like it should trigger the mount. | |||
| 3746 | */ | |||
| 3747 | if (cnp->cn_flags & ISLASTCN0x00008000) { | |||
| 3748 | switch (pop) { | |||
| 3749 | case OP_MOUNT: | |||
| 3750 | case OP_UNMOUNT: | |||
| 3751 | case OP_STATFS: | |||
| 3752 | case OP_LINK: | |||
| 3753 | case OP_UNLINK: | |||
| 3754 | case OP_RENAME: | |||
| 3755 | case OP_MKNOD: | |||
| 3756 | case OP_MKFIFO: | |||
| 3757 | case OP_SYMLINK: | |||
| 3758 | case OP_ACCESS: | |||
| 3759 | case OP_GETATTR: | |||
| 3760 | case OP_MKDIR: | |||
| 3761 | case OP_RMDIR: | |||
| 3762 | case OP_REVOKE: | |||
| 3763 | case OP_GETXATTR: | |||
| 3764 | case OP_LISTXATTR: | |||
| 3765 | /* don't perform the mount for these operations */ | |||
| 3766 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, RESOLVER_NOCHANGE, 0); | |||
| 3767 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3768 | NP(np, "nfs trigger RESOLVE: no change, last %d nameiop %d, seq %d",do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: no change, last %d nameiop %d, seq %d" " %s\n", (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp-> cn_nameiop, np->n_un7.nd_trigseq, __vname ? __vname : "???" ); if (__vname) vnode_putname(__vname); } while (0) | |||
| 3769 | (cnp->cn_flags & ISLASTCN) ? 1 : 0, cnp->cn_nameiop, np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: no change, last %d nameiop %d, seq %d" " %s\n", (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp-> cn_nameiop, np->n_un7.nd_trigseq, __vname ? __vname : "???" ); if (__vname) vnode_putname(__vname); } while (0); | |||
| 3770 | #endif | |||
| 3771 | return (result); | |||
| 3772 | case OP_OPEN: | |||
| 3773 | case OP_CHDIR: | |||
| 3774 | case OP_CHROOT: | |||
| 3775 | case OP_TRUNCATE: | |||
| 3776 | case OP_COPYFILE: | |||
| 3777 | case OP_PATHCONF: | |||
| 3778 | case OP_READLINK: | |||
| 3779 | case OP_SETATTR: | |||
| 3780 | case OP_EXCHANGEDATA: | |||
| 3781 | case OP_SEARCHFS: | |||
| 3782 | case OP_FSCTL: | |||
| 3783 | case OP_SETXATTR: | |||
| 3784 | case OP_REMOVEXATTR: | |||
| 3785 | default: | |||
| 3786 | /* go ahead and do the mount */ | |||
| 3787 | break; | |||
| 3788 | } | |||
| 3789 | } | |||
| 3790 | ||||
| 3791 | if (vnode_mountedhere(vp) != NULL((void *)0)) { | |||
| 3792 | /* | |||
| 3793 | * Um... there's already something mounted. | |||
| 3794 | * Been there. Done that. Let's just say it succeeded. | |||
| 3795 | */ | |||
| 3796 | error = 0; | |||
| 3797 | goto skipmount; | |||
| 3798 | } | |||
| 3799 | ||||
| 3800 | if ((error = nfs_node_set_busy(np, vfs_context_thread(ctx)))) { | |||
| 3801 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, RESOLVER_ERROR, error); | |||
| 3802 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3803 | NP(np, "nfs trigger RESOLVE: busy error %d, last %d nameiop %d, seq %d",do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: busy error %d, last %d nameiop %d, seq %d" " %s\n", error, (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp->cn_nameiop, np->n_un7.nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname(__vname); } while (0) | |||
| 3804 | error, (cnp->cn_flags & ISLASTCN) ? 1 : 0, cnp->cn_nameiop, np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: busy error %d, last %d nameiop %d, seq %d" " %s\n", error, (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp->cn_nameiop, np->n_un7.nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname(__vname); } while (0); | |||
| 3805 | #endif | |||
| 3806 | return (result); | |||
| 3807 | } | |||
| 3808 | ||||
| 3809 | pvp = vnode_getparent(vp); | |||
| 3810 | if (pvp == NULLVP((struct vnode *)((void *)0))) | |||
| 3811 | error = EINVAL22; | |||
| 3812 | if (!error) | |||
| 3813 | error = nfs_mirror_mount_domount(pvp, vp, ctx); | |||
| 3814 | skipmount: | |||
| 3815 | if (!error) | |||
| 3816 | np->n_trigseqn_un7.nd_trigseq++; | |||
| 3817 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, error ? RESOLVER_ERROR : RESOLVER_RESOLVED, error); | |||
| 3818 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3819 | NP(np, "nfs trigger RESOLVE: %s %d, last %d nameiop %d, seq %d",do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: %s %d, last %d nameiop %d, seq %d" " %s\n", error ? "error" : "resolved", error, (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp->cn_nameiop, np->n_un7. nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0) | |||
| 3820 | error ? "error" : "resolved", error,do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: %s %d, last %d nameiop %d, seq %d" " %s\n", error ? "error" : "resolved", error, (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp->cn_nameiop, np->n_un7. nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0) | |||
| 3821 | (cnp->cn_flags & ISLASTCN) ? 1 : 0, cnp->cn_nameiop, np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger RESOLVE: %s %d, last %d nameiop %d, seq %d" " %s\n", error ? "error" : "resolved", error, (cnp->cn_flags & 0x00008000) ? 1 : 0, cnp->cn_nameiop, np->n_un7. nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0); | |||
| 3822 | #endif | |||
| 3823 | ||||
| 3824 | if (pvp != NULLVP((struct vnode *)((void *)0))) | |||
| 3825 | vnode_put(pvp); | |||
| 3826 | nfs_node_clear_busy(np); | |||
| 3827 | return (result); | |||
| 3828 | } | |||
| 3829 | ||||
| 3830 | resolver_result_t | |||
| 3831 | nfs_mirror_mount_trigger_unresolve( | |||
| 3832 | vnode_t vp, | |||
| 3833 | int flags, | |||
| 3834 | __unused__attribute__((unused)) void *data, | |||
| 3835 | vfs_context_t ctx) | |||
| 3836 | { | |||
| 3837 | nfsnode_t np = VTONFS(vp)((nfsnode_t)vnode_fsnode(vp)); | |||
| 3838 | mount_t mp; | |||
| 3839 | int error; | |||
| 3840 | resolver_result_t result; | |||
| 3841 | ||||
| 3842 | if ((error = nfs_node_set_busy(np, vfs_context_thread(ctx)))) { | |||
| 3843 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, RESOLVER_ERROR, error); | |||
| 3844 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3845 | NP(np, "nfs trigger UNRESOLVE: busy error %d, seq %d", error, np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger UNRESOLVE: busy error %d, seq %d" " %s\n", error, np->n_un7.nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname(__vname); } while (0); | |||
| 3846 | #endif | |||
| 3847 | return (result); | |||
| 3848 | } | |||
| 3849 | ||||
| 3850 | mp = vnode_mountedhere(vp); | |||
| 3851 | if (!mp) | |||
| 3852 | error = EINVAL22; | |||
| 3853 | if (!error) | |||
| 3854 | error = vfs_unmountbyfsid(&(vfs_statfs(mp)->f_fsid), flags, ctx); | |||
| 3855 | if (!error) | |||
| 3856 | np->n_trigseqn_un7.nd_trigseq++; | |||
| 3857 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, error ? RESOLVER_ERROR : RESOLVER_UNRESOLVED, error); | |||
| 3858 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3859 | NP(np, "nfs trigger UNRESOLVE: %s %d, seq %d",do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger UNRESOLVE: %s %d, seq %d" " %s\n", error ? "error" : "unresolved", error, np->n_un7 .nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0) | |||
| 3860 | error ? "error" : "unresolved", error, np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger UNRESOLVE: %s %d, seq %d" " %s\n", error ? "error" : "unresolved", error, np->n_un7 .nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0); | |||
| 3861 | #endif | |||
| 3862 | nfs_node_clear_busy(np); | |||
| 3863 | return (result); | |||
| 3864 | } | |||
| 3865 | ||||
| 3866 | resolver_result_t | |||
| 3867 | nfs_mirror_mount_trigger_rearm( | |||
| 3868 | vnode_t vp, | |||
| 3869 | __unused__attribute__((unused)) int flags, | |||
| 3870 | __unused__attribute__((unused)) void *data, | |||
| 3871 | vfs_context_t ctx) | |||
| 3872 | { | |||
| 3873 | nfsnode_t np = VTONFS(vp)((nfsnode_t)vnode_fsnode(vp)); | |||
| 3874 | int error; | |||
| 3875 | resolver_result_t result; | |||
| 3876 | ||||
| 3877 | if ((error = nfs_node_set_busy(np, vfs_context_thread(ctx)))) { | |||
| 3878 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, RESOLVER_ERROR, error); | |||
| 3879 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3880 | NP(np, "nfs trigger REARM: busy error %d, seq %d", error, np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger REARM: busy error %d, seq %d" " %s\n", error, np->n_un7.nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname(__vname); } while (0); | |||
| 3881 | #endif | |||
| 3882 | return (result); | |||
| 3883 | } | |||
| 3884 | ||||
| 3885 | np->n_trigseqn_un7.nd_trigseq++; | |||
| 3886 | result = vfs_resolver_result(np->n_trigseqn_un7.nd_trigseq, | |||
| 3887 | vnode_mountedhere(vp) ? RESOLVER_RESOLVED : RESOLVER_UNRESOLVED, 0); | |||
| 3888 | #ifdef NFS_TRIGGER_DEBUG | |||
| 3889 | NP(np, "nfs trigger REARM: %s, seq %d",do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger REARM: %s, seq %d" " %s\n" , vnode_mountedhere(vp) ? "resolved" : "unresolved", np->n_un7 .nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0) | |||
| 3890 | vnode_mountedhere(vp) ? "resolved" : "unresolved", np->n_trigseq)do { const char *__vname = (np) ? vnode_getname(((np)->n_vnode )) : ((void *)0); printf("nfs trigger REARM: %s, seq %d" " %s\n" , vnode_mountedhere(vp) ? "resolved" : "unresolved", np->n_un7 .nd_trigseq, __vname ? __vname : "???"); if (__vname) vnode_putname (__vname); } while (0); | |||
| 3891 | #endif | |||
| 3892 | nfs_node_clear_busy(np); | |||
| 3893 | return (result); | |||
| 3894 | } | |||
| 3895 | ||||
| 3896 | /* | |||
| 3897 | * Periodically attempt to unmount ephemeral (mirror) mounts in an attempt to limit | |||
| 3898 | * the number of unused mounts. | |||
| 3899 | */ | |||
| 3900 | ||||
| 3901 | #define NFS_EPHEMERAL_MOUNT_HARVEST_INTERVAL120 120 /* how often the harvester runs */ | |||
| 3902 | struct nfs_ephemeral_mount_harvester_info { | |||
| 3903 | fsid_t fsid; /* FSID that we need to try to unmount */ | |||
| 3904 | uint32_t mountcount; /* count of ephemeral mounts seen in scan */ | |||
| 3905 | }; | |||
| 3906 | /* various globals for the harvester */ | |||
| 3907 | static thread_call_t nfs_ephemeral_mount_harvester_timer = NULL((void *)0); | |||
| 3908 | static int nfs_ephemeral_mount_harvester_on = 0; | |||
| 3909 | ||||
| 3910 | kern_return_t thread_terminate(thread_t); | |||
| 3911 | ||||
| 3912 | static int | |||
| 3913 | nfs_ephemeral_mount_harvester_callback(mount_t mp, void *arg) | |||
| 3914 | { | |||
| 3915 | struct nfs_ephemeral_mount_harvester_info *hinfo = arg; | |||
| 3916 | struct nfsmount *nmp; | |||
| 3917 | struct timeval now; | |||
| 3918 | ||||
| 3919 | if (strcmp(mp->mnt_vfsstat.f_fstypename, "nfs")) | |||
| 3920 | return (VFS_RETURNED0); | |||
| 3921 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 3922 | if (!nmp || !NMFLAG(nmp, EPHEMERAL)(((uint32_t *)((nmp)->nm_flags))[(9)/32] & (1<<( (9)%32)))) | |||
| 3923 | return (VFS_RETURNED0); | |||
| 3924 | hinfo->mountcount++; | |||
| 3925 | ||||
| 3926 | /* avoid unmounting mounts that have been triggered within the last harvest interval */ | |||
| 3927 | microtime(&now); | |||
| 3928 | if ((nmp->nm_mounttimenm_un.v4.mounttime >> 32) > ((uint32_t)now.tv_sec - NFS_EPHEMERAL_MOUNT_HARVEST_INTERVAL120)) | |||
| 3929 | return (VFS_RETURNED0); | |||
| 3930 | ||||
| 3931 | if (hinfo->fsid.val[0] || hinfo->fsid.val[1]) { | |||
| 3932 | /* attempt to unmount previously-found ephemeral mount */ | |||
| 3933 | vfs_unmountbyfsid(&hinfo->fsid, 0, vfs_context_kernel()); | |||
| 3934 | hinfo->fsid.val[0] = hinfo->fsid.val[1] = 0; | |||
| 3935 | } | |||
| 3936 | ||||
| 3937 | /* | |||
| 3938 | * We can't call unmount here since we hold a mount iter ref | |||
| 3939 | * on mp so save its fsid for the next call iteration to unmount. | |||
| 3940 | */ | |||
| 3941 | hinfo->fsid.val[0] = mp->mnt_vfsstat.f_fsid.val[0]; | |||
| 3942 | hinfo->fsid.val[1] = mp->mnt_vfsstat.f_fsid.val[1]; | |||
| 3943 | ||||
| 3944 | return (VFS_RETURNED0); | |||
| 3945 | } | |||
| 3946 | ||||
| 3947 | /* | |||
| 3948 | * Spawn a thread to do the ephemeral mount harvesting. | |||
| 3949 | */ | |||
| 3950 | static void | |||
| 3951 | nfs_ephemeral_mount_harvester_timer_func(void) | |||
| 3952 | { | |||
| 3953 | thread_t thd; | |||
| 3954 | ||||
| 3955 | if (kernel_thread_start(nfs_ephemeral_mount_harvester, NULL((void *)0), &thd) == KERN_SUCCESS0) | |||
| 3956 | thread_deallocate(thd); | |||
| 3957 | } | |||
| 3958 | ||||
| 3959 | /* | |||
| 3960 | * Iterate all mounts looking for NFS ephemeral mounts to try to unmount. | |||
| 3961 | */ | |||
| 3962 | void | |||
| 3963 | nfs_ephemeral_mount_harvester(__unused__attribute__((unused)) void *arg, __unused__attribute__((unused)) wait_result_t wr) | |||
| 3964 | { | |||
| 3965 | struct nfs_ephemeral_mount_harvester_info hinfo; | |||
| 3966 | uint64_t deadline; | |||
| 3967 | ||||
| 3968 | hinfo.mountcount = 0; | |||
| 3969 | hinfo.fsid.val[0] = hinfo.fsid.val[1] = 0; | |||
| 3970 | vfs_iterate(VFS_ITERATE_TAIL_FIRST(1 << 0), nfs_ephemeral_mount_harvester_callback, &hinfo); | |||
| 3971 | if (hinfo.fsid.val[0] || hinfo.fsid.val[1]) { | |||
| 3972 | /* attempt to unmount last found ephemeral mount */ | |||
| 3973 | vfs_unmountbyfsid(&hinfo.fsid, 0, vfs_context_kernel()); | |||
| 3974 | } | |||
| 3975 | ||||
| 3976 | lck_mtx_lock(nfs_global_mutex); | |||
| 3977 | if (!hinfo.mountcount) { | |||
| 3978 | /* no more ephemeral mounts - don't need timer */ | |||
| 3979 | nfs_ephemeral_mount_harvester_on = 0; | |||
| 3980 | } else { | |||
| 3981 | /* re-arm the timer */ | |||
| 3982 | clock_interval_to_deadline(NFS_EPHEMERAL_MOUNT_HARVEST_INTERVAL120, NSEC_PER_SEC1000000000ull, &deadline); | |||
| 3983 | thread_call_enter_delayed(nfs_ephemeral_mount_harvester_timer, deadline); | |||
| 3984 | nfs_ephemeral_mount_harvester_on = 1; | |||
| 3985 | } | |||
| 3986 | lck_mtx_unlock(nfs_global_mutex); | |||
| 3987 | ||||
| 3988 | /* thread done */ | |||
| 3989 | thread_terminate(current_thread()); | |||
| 3990 | } | |||
| 3991 | ||||
| 3992 | /* | |||
| 3993 | * Make sure the NFS ephemeral mount harvester timer is running. | |||
| 3994 | */ | |||
| 3995 | void | |||
| 3996 | nfs_ephemeral_mount_harvester_start(void) | |||
| 3997 | { | |||
| 3998 | uint64_t deadline; | |||
| 3999 | ||||
| 4000 | lck_mtx_lock(nfs_global_mutex); | |||
| 4001 | if (nfs_ephemeral_mount_harvester_on) { | |||
| 4002 | lck_mtx_unlock(nfs_global_mutex); | |||
| 4003 | return; | |||
| 4004 | } | |||
| 4005 | if (nfs_ephemeral_mount_harvester_timer == NULL((void *)0)) | |||
| 4006 | nfs_ephemeral_mount_harvester_timer = thread_call_allocate((thread_call_func_t)nfs_ephemeral_mount_harvester_timer_func, NULL((void *)0)); | |||
| 4007 | clock_interval_to_deadline(NFS_EPHEMERAL_MOUNT_HARVEST_INTERVAL120, NSEC_PER_SEC1000000000ull, &deadline); | |||
| 4008 | thread_call_enter_delayed(nfs_ephemeral_mount_harvester_timer, deadline); | |||
| 4009 | nfs_ephemeral_mount_harvester_on = 1; | |||
| 4010 | lck_mtx_unlock(nfs_global_mutex); | |||
| 4011 | } | |||
| 4012 | ||||
| 4013 | #endif | |||
| 4014 | ||||
| 4015 | /* | |||
| 4016 | * Send a MOUNT protocol MOUNT request to the server to get the initial file handle (and security). | |||
| 4017 | */ | |||
| 4018 | int | |||
| 4019 | nfs3_mount_rpc(struct nfsmount *nmp, struct sockaddr *sa, int sotype, int nfsvers, char *path, vfs_context_t ctx, int timeo, fhandle_t *fh, struct nfs_sec *sec) | |||
| 4020 | { | |||
| 4021 | int error = 0, slen, mntproto; | |||
| 4022 | thread_t thd = vfs_context_thread(ctx); | |||
| 4023 | kauth_cred_t cred = vfs_context_ucred(ctx); | |||
| 4024 | uint64_t xid = 0; | |||
| 4025 | struct nfsm_chain nmreq, nmrep; | |||
| 4026 | mbuf_t mreq; | |||
| 4027 | uint32_t mntvers, mntport, val; | |||
| 4028 | struct sockaddr_storage ss; | |||
| 4029 | struct sockaddr *saddr = (struct sockaddr*)&ss; | |||
| 4030 | ||||
| 4031 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 4032 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 4033 | ||||
| 4034 | mntvers = (nfsvers == NFS_VER22) ? RPCMNT_VER11 : RPCMNT_VER33; | |||
| 4035 | mntproto = (NM_OMFLAG(nmp, MNTUDP)(((uint32_t *)((nmp)->nm_mflags))[(16)/32] & (1<< ((16)%32))) || (sotype == SOCK_DGRAM2)) ? IPPROTO_UDP17 : IPPROTO_TCP6; | |||
| 4036 | sec->count = 0; | |||
| 4037 | ||||
| 4038 | bcopy(sa, saddr, min(sizeof(ss), sa->sa_len)); | |||
| 4039 | if (saddr->sa_family == AF_INET2) { | |||
| 4040 | if (nmp->nm_mountport) | |||
| 4041 | ((struct sockaddr_in*)saddr)->sin_port = htons(nmp->nm_mountport)((__uint16_t)(__builtin_constant_p(nmp->nm_mountport) ? (( __uint16_t)((((__uint16_t)(nmp->nm_mountport) & 0xff00 ) >> 8) | (((__uint16_t)(nmp->nm_mountport) & 0x00ff ) << 8))) : _OSSwapInt16(nmp->nm_mountport))); | |||
| 4042 | mntport = ntohs(((struct sockaddr_in*)saddr)->sin_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in*)saddr )->sin_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in *)saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in*)saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)saddr)->sin_port ))); | |||
| 4043 | } else { | |||
| 4044 | if (nmp->nm_mountport) | |||
| 4045 | ((struct sockaddr_in6*)saddr)->sin6_port = htons(nmp->nm_mountport)((__uint16_t)(__builtin_constant_p(nmp->nm_mountport) ? (( __uint16_t)((((__uint16_t)(nmp->nm_mountport) & 0xff00 ) >> 8) | (((__uint16_t)(nmp->nm_mountport) & 0x00ff ) << 8))) : _OSSwapInt16(nmp->nm_mountport))); | |||
| 4046 | mntport = ntohs(((struct sockaddr_in6*)saddr)->sin6_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in6*)saddr )->sin6_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6 *)saddr)->sin6_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in6*)saddr)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)saddr)->sin6_port ))); | |||
| 4047 | } | |||
| 4048 | ||||
| 4049 | while (!mntport) { | |||
| 4050 | error = nfs_portmap_lookup(nmp, ctx, saddr, NULL((void *)0), RPCPROG_MNT100005, mntvers, mntproto, timeo); | |||
| 4051 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4052 | if (saddr->sa_family == AF_INET2) | |||
| 4053 | mntport = ntohs(((struct sockaddr_in*)saddr)->sin_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in*)saddr )->sin_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in *)saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in*)saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)saddr)->sin_port ))); | |||
| 4054 | else | |||
| 4055 | mntport = ntohs(((struct sockaddr_in6*)saddr)->sin6_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in6*)saddr )->sin6_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6 *)saddr)->sin6_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in6*)saddr)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)saddr)->sin6_port ))); | |||
| 4056 | if (!mntport) { | |||
| 4057 | /* if not found and TCP, then retry with UDP */ | |||
| 4058 | if (mntproto == IPPROTO_UDP17) { | |||
| 4059 | error = EPROGUNAVAIL74; | |||
| 4060 | break; | |||
| 4061 | } | |||
| 4062 | mntproto = IPPROTO_UDP17; | |||
| 4063 | bcopy(sa, saddr, min(sizeof(ss), sa->sa_len)); | |||
| 4064 | } | |||
| 4065 | } | |||
| 4066 | nfsmout_if(error || !mntport)do { if (error || !mntport) goto nfsmout; } while (0); | |||
| 4067 | ||||
| 4068 | /* MOUNT protocol MOUNT request */ | |||
| 4069 | slen = strlen(path); | |||
| 4070 | nfsm_chain_build_alloc_init(error, &nmreq, NFSX_UNSIGNED + nfsm_rndup(slen))do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((4 + (((slen)+3)&(~0x3)))) >= nfs_mbuf_minclsize) (( error)) = mbuf_mclget(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb )); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (& ncbimb)); } while (0); if (error) break; do { ((&nmreq))-> nmc_mhead = (ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq ))->nmc_mhead; ((&nmreq))->nmc_ptr = mbuf_data(((& nmreq))->nmc_mcur); ((&nmreq))->nmc_left = mbuf_trailingspace (((&nmreq))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while (0); } while (0); | |||
| 4071 | nfsm_chain_add_name(error, &nmreq, path, slen, nmp)do { if (error) break; if ((((uint32_t *)(((nmp))->nm_flags ))[(14)/32] & (1<<((14)%32)))) (error) = nfsm_chain_add_string_nfc ((&nmreq), (const uint8_t*)(path), (slen)); else do { do { do { if ((((error)))) break; if (((((&nmreq))))->nmc_left < (4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq )))), (4)); if (!((((error)))) && (((((&nmreq)))) ->nmc_left < (4))) ((((error)))) = 12; } } while (0); if (((error))) break; *((uint32_t*)(((&nmreq)))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)(((slen)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((slen)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((slen)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((slen)))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((slen)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((slen)))))); (((& nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4 ; } while (0); do { uint32_t rndlen = (((((slen)))+3)&(~0x3 )); if (((error))) break; if ((((&nmreq)))->nmc_left < rndlen) { (((error))) = nfsm_chain_add_opaque_f((((&nmreq ))), (const u_char*)(((path))), (((slen)))); break; } *(((uint32_t *)((((&nmreq)))->nmc_ptr))+((((((((slen))))+3)&(~0x3 ))>>2)-1)) = 0; bcopy((((path))), (((&nmreq)))-> nmc_ptr, (((slen)))); (((&nmreq)))->nmc_ptr += rndlen; (((&nmreq)))->nmc_left -= rndlen; } while (0); } while (0); } while (0); | |||
| 4072 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 4073 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4074 | error = nfsm_rpchead2(nmp, (mntproto == IPPROTO_UDP17) ? SOCK_DGRAM2 : SOCK_STREAM1, | |||
| 4075 | RPCPROG_MNT100005, mntvers, RPCMNT_MOUNT1, | |||
| 4076 | RPCAUTH_SYS1, cred, NULL((void *)0), nmreq.nmc_mhead, &xid, &mreq); | |||
| 4077 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4078 | nmreq.nmc_mhead = NULL((void *)0); | |||
| 4079 | error = nfs_aux_request(nmp, thd, saddr, NULL((void *)0), | |||
| 4080 | ((mntproto == IPPROTO_UDP17) ? SOCK_DGRAM2 : SOCK_STREAM1), | |||
| 4081 | mreq, R_XID32(xid)((xid) & 0xffffffff), 1, timeo, &nmrep); | |||
| 4082 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4083 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4084 | if (!error && val) | |||
| 4085 | error = val; | |||
| 4086 | nfsm_chain_get_fh(error, &nmrep, nfsvers, fh)do { if ((nfsvers) != 2) do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } ((fh)->fh_len ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); else (fh)->fh_len = 32; do { uint32_t rndlen; if ((error )) break; rndlen = ((((uint32_t)(fh)->fh_len)+3)&(~0x3 )); if (((&nmrep))->nmc_left >= rndlen) { u_char *__tmpptr = (u_char*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= rndlen; ((&nmrep))->nmc_ptr += rndlen; bcopy(__tmpptr , ((fh)->fh_data), ((uint32_t)(fh)->fh_len)); } else { ( (error)) = nfsm_chain_get_opaque_f(((&nmrep)), ((uint32_t )(fh)->fh_len), (u_char*)((fh)->fh_data)); } } while (0 ); if (error) (fh)->fh_len = 0; } while (0); | |||
| 4087 | if (!error && (nfsvers > NFS_VER22)) { | |||
| 4088 | sec->count = NX_MAX_SEC_FLAVORS5; | |||
| 4089 | error = nfsm_chain_get_secinfo(&nmrep, &sec->flavors[0], &sec->count); | |||
| 4090 | } | |||
| 4091 | nfsmout: | |||
| 4092 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4093 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4094 | return (error); | |||
| 4095 | } | |||
| 4096 | ||||
| 4097 | ||||
| 4098 | /* | |||
| 4099 | * Send a MOUNT protocol UNMOUNT request to tell the server we've unmounted it. | |||
| 4100 | */ | |||
| 4101 | void | |||
| 4102 | nfs3_umount_rpc(struct nfsmount *nmp, vfs_context_t ctx, int timeo) | |||
| 4103 | { | |||
| 4104 | int error = 0, slen, mntproto; | |||
| 4105 | thread_t thd = vfs_context_thread(ctx); | |||
| 4106 | kauth_cred_t cred = vfs_context_ucred(ctx); | |||
| 4107 | char *path; | |||
| 4108 | uint64_t xid = 0; | |||
| 4109 | struct nfsm_chain nmreq, nmrep; | |||
| 4110 | mbuf_t mreq; | |||
| 4111 | uint32_t mntvers, mntport; | |||
| 4112 | struct sockaddr_storage ss; | |||
| 4113 | struct sockaddr *saddr = (struct sockaddr*)&ss; | |||
| 4114 | ||||
| 4115 | if (!nmp->nm_saddr) | |||
| 4116 | return; | |||
| 4117 | ||||
| 4118 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 4119 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 4120 | ||||
| 4121 | mntvers = (nmp->nm_vers == NFS_VER22) ? RPCMNT_VER11 : RPCMNT_VER33; | |||
| 4122 | mntproto = (NM_OMFLAG(nmp, MNTUDP)(((uint32_t *)((nmp)->nm_mflags))[(16)/32] & (1<< ((16)%32))) || (nmp->nm_sotype == SOCK_DGRAM2)) ? IPPROTO_UDP17 : IPPROTO_TCP6; | |||
| 4123 | mntport = nmp->nm_mountport; | |||
| 4124 | ||||
| 4125 | bcopy(nmp->nm_saddr, saddr, min(sizeof(ss), nmp->nm_saddr->sa_len)); | |||
| 4126 | if (saddr->sa_family == AF_INET2) | |||
| 4127 | ((struct sockaddr_in*)saddr)->sin_port = htons(mntport)((__uint16_t)(__builtin_constant_p(mntport) ? ((__uint16_t)(( ((__uint16_t)(mntport) & 0xff00) >> 8) | (((__uint16_t )(mntport) & 0x00ff) << 8))) : _OSSwapInt16(mntport ))); | |||
| 4128 | else | |||
| 4129 | ((struct sockaddr_in6*)saddr)->sin6_port = htons(mntport)((__uint16_t)(__builtin_constant_p(mntport) ? ((__uint16_t)(( ((__uint16_t)(mntport) & 0xff00) >> 8) | (((__uint16_t )(mntport) & 0x00ff) << 8))) : _OSSwapInt16(mntport ))); | |||
| 4130 | ||||
| 4131 | while (!mntport) { | |||
| 4132 | error = nfs_portmap_lookup(nmp, ctx, saddr, NULL((void *)0), RPCPROG_MNT100005, mntvers, mntproto, timeo); | |||
| 4133 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4134 | if (saddr->sa_family == AF_INET2) | |||
| 4135 | mntport = ntohs(((struct sockaddr_in*)saddr)->sin_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in*)saddr )->sin_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in *)saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in*)saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)saddr)->sin_port ))); | |||
| 4136 | else | |||
| 4137 | mntport = ntohs(((struct sockaddr_in6*)saddr)->sin6_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in6*)saddr )->sin6_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6 *)saddr)->sin6_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in6*)saddr)->sin6_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)saddr)->sin6_port ))); | |||
| 4138 | /* if not found and mntvers > VER1, then retry with VER1 */ | |||
| 4139 | if (!mntport) { | |||
| 4140 | if (mntvers > RPCMNT_VER11) { | |||
| 4141 | mntvers = RPCMNT_VER11; | |||
| 4142 | } else if (mntproto == IPPROTO_TCP6) { | |||
| 4143 | mntproto = IPPROTO_UDP17; | |||
| 4144 | mntvers = (nmp->nm_vers == NFS_VER22) ? RPCMNT_VER11 : RPCMNT_VER33; | |||
| 4145 | } else { | |||
| 4146 | break; | |||
| 4147 | } | |||
| 4148 | bcopy(nmp->nm_saddr, saddr, min(sizeof(ss), nmp->nm_saddr->sa_len)); | |||
| 4149 | } | |||
| 4150 | } | |||
| 4151 | nfsmout_if(!mntport)do { if (!mntport) goto nfsmout; } while (0); | |||
| 4152 | ||||
| 4153 | /* MOUNT protocol UNMOUNT request */ | |||
| 4154 | path = &vfs_statfs(nmp->nm_mountp)->f_mntfromname[0]; | |||
| 4155 | while (*path && (*path != '/')) | |||
| 4156 | path++; | |||
| 4157 | slen = strlen(path); | |||
| 4158 | nfsm_chain_build_alloc_init(error, &nmreq, NFSX_UNSIGNED + nfsm_rndup(slen))do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((4 + (((slen)+3)&(~0x3)))) >= nfs_mbuf_minclsize) (( error)) = mbuf_mclget(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb )); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (& ncbimb)); } while (0); if (error) break; do { ((&nmreq))-> nmc_mhead = (ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq ))->nmc_mhead; ((&nmreq))->nmc_ptr = mbuf_data(((& nmreq))->nmc_mcur); ((&nmreq))->nmc_left = mbuf_trailingspace (((&nmreq))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while (0); } while (0); | |||
| 4159 | nfsm_chain_add_name(error, &nmreq, path, slen, nmp)do { if (error) break; if ((((uint32_t *)(((nmp))->nm_flags ))[(14)/32] & (1<<((14)%32)))) (error) = nfsm_chain_add_string_nfc ((&nmreq), (const uint8_t*)(path), (slen)); else do { do { do { if ((((error)))) break; if (((((&nmreq))))->nmc_left < (4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq )))), (4)); if (!((((error)))) && (((((&nmreq)))) ->nmc_left < (4))) ((((error)))) = 12; } } while (0); if (((error))) break; *((uint32_t*)(((&nmreq)))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)(((slen)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((slen)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((slen)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((slen)))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((slen)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((slen)))))); (((& nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4 ; } while (0); do { uint32_t rndlen = (((((slen)))+3)&(~0x3 )); if (((error))) break; if ((((&nmreq)))->nmc_left < rndlen) { (((error))) = nfsm_chain_add_opaque_f((((&nmreq ))), (const u_char*)(((path))), (((slen)))); break; } *(((uint32_t *)((((&nmreq)))->nmc_ptr))+((((((((slen))))+3)&(~0x3 ))>>2)-1)) = 0; bcopy((((path))), (((&nmreq)))-> nmc_ptr, (((slen)))); (((&nmreq)))->nmc_ptr += rndlen; (((&nmreq)))->nmc_left -= rndlen; } while (0); } while (0); } while (0); | |||
| 4160 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 4161 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4162 | error = nfsm_rpchead2(nmp, (mntproto == IPPROTO_UDP17) ? SOCK_DGRAM2 : SOCK_STREAM1, | |||
| 4163 | RPCPROG_MNT100005, RPCMNT_VER11, RPCMNT_UMOUNT3, | |||
| 4164 | RPCAUTH_SYS1, cred, NULL((void *)0), nmreq.nmc_mhead, &xid, &mreq); | |||
| 4165 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4166 | nmreq.nmc_mhead = NULL((void *)0); | |||
| 4167 | error = nfs_aux_request(nmp, thd, saddr, NULL((void *)0), | |||
| 4168 | ((mntproto == IPPROTO_UDP17) ? SOCK_DGRAM2 : SOCK_STREAM1), | |||
| 4169 | mreq, R_XID32(xid)((xid) & 0xffffffff), 1, timeo, &nmrep); | |||
| 4170 | nfsmout: | |||
| 4171 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4172 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4173 | } | |||
| 4174 | ||||
| 4175 | /* | |||
| 4176 | * unmount system call | |||
| 4177 | */ | |||
| 4178 | int | |||
| 4179 | nfs_vfs_unmount( | |||
| 4180 | mount_t mp, | |||
| 4181 | int mntflags, | |||
| 4182 | __unused__attribute__((unused)) vfs_context_t ctx) | |||
| 4183 | { | |||
| 4184 | struct nfsmount *nmp; | |||
| 4185 | vnode_t vp; | |||
| 4186 | int error, flags = 0; | |||
| 4187 | struct timespec ts = { 1, 0 }; | |||
| 4188 | ||||
| 4189 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 4190 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4191 | /* | |||
| 4192 | * Set the flag indicating that an unmount attempt is in progress. | |||
| 4193 | */ | |||
| 4194 | nmp->nm_state |= NFSSTA_UNMOUNTING0x00000100; | |||
| 4195 | /* | |||
| 4196 | * During a force unmount we want to... | |||
| 4197 | * Mark that we are doing a force unmount. | |||
| 4198 | * Make the mountpoint soft. | |||
| 4199 | */ | |||
| 4200 | if (mntflags & MNT_FORCE0x00080000) { | |||
| 4201 | flags |= FORCECLOSE0x0002; | |||
| 4202 | nmp->nm_state |= NFSSTA_FORCE0x00020000; | |||
| 4203 | NFS_BITMAP_SET(nmp->nm_flags, NFS_MFLAG_SOFT)(((uint32_t *)(nmp->nm_flags))[(0)/32] |= 1<<((0)%32 )); | |||
| 4204 | } | |||
| 4205 | /* | |||
| 4206 | * Wait for any in-progress monitored node scan to complete. | |||
| 4207 | */ | |||
| 4208 | while (nmp->nm_state & NFSSTA_MONITOR_SCAN0x00000080) | |||
| 4209 | msleep(&nmp->nm_state, &nmp->nm_lock, PZERO22-1, "nfswaitmonscan", &ts); | |||
| 4210 | /* | |||
| 4211 | * Goes something like this.. | |||
| 4212 | * - Call vflush() to clear out vnodes for this file system, | |||
| 4213 | * except for the swap files. Deal with them in 2nd pass. | |||
| 4214 | * - Decrement reference on the vnode representing remote root. | |||
| 4215 | * - Clean up the NFS mount structure. | |||
| 4216 | */ | |||
| 4217 | vp = NFSTOV(nmp->nm_dnp)((nmp->nm_dnp)->n_vnode); | |||
| 4218 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4219 | ||||
| 4220 | /* | |||
| 4221 | * vflush will check for busy vnodes on mountpoint. | |||
| 4222 | * Will do the right thing for MNT_FORCE. That is, we should | |||
| 4223 | * not get EBUSY back. | |||
| 4224 | */ | |||
| 4225 | error = vflush(mp, vp, SKIPSWAP0x0008 | flags); | |||
| 4226 | if (mntflags & MNT_FORCE0x00080000) { | |||
| 4227 | error = vflush(mp, NULLVP((struct vnode *)((void *)0)), flags); /* locks vp in the process */ | |||
| 4228 | } else { | |||
| 4229 | if (vnode_isinuse(vp, 1)) | |||
| 4230 | error = EBUSY16; | |||
| 4231 | else | |||
| 4232 | error = vflush(mp, vp, flags); | |||
| 4233 | } | |||
| 4234 | if (error) { | |||
| 4235 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4236 | nmp->nm_state &= ~NFSSTA_UNMOUNTING0x00000100; | |||
| 4237 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4238 | return (error); | |||
| 4239 | } | |||
| 4240 | ||||
| 4241 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4242 | nmp->nm_dnp = NULL((void *)0); | |||
| 4243 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4244 | ||||
| 4245 | /* | |||
| 4246 | * Release the root vnode reference held by mountnfs() | |||
| 4247 | */ | |||
| 4248 | error = vnode_get(vp); | |||
| 4249 | vnode_rele(vp); | |||
| 4250 | if (!error) | |||
| 4251 | vnode_put(vp); | |||
| 4252 | ||||
| 4253 | vflush(mp, NULLVP((struct vnode *)((void *)0)), FORCECLOSE0x0002); | |||
| 4254 | ||||
| 4255 | /* Wait for all other references to be released and free the mount */ | |||
| 4256 | nfs_mount_drain_and_cleanup(nmp); | |||
| 4257 | ||||
| 4258 | return (0); | |||
| 4259 | } | |||
| 4260 | ||||
| 4261 | /* | |||
| 4262 | * cleanup/destroy NFS fs locations structure | |||
| 4263 | */ | |||
| 4264 | void | |||
| 4265 | nfs_fs_locations_cleanup(struct nfs_fs_locations *nfslsp) | |||
| 4266 | { | |||
| 4267 | struct nfs_fs_location *fsl; | |||
| 4268 | struct nfs_fs_server *fss; | |||
| 4269 | struct nfs_fs_path *fsp; | |||
| 4270 | uint32_t loc, serv, addr, comp; | |||
| 4271 | ||||
| 4272 | /* free up fs locations */ | |||
| 4273 | if (!nfslsp->nl_numlocs || !nfslsp->nl_locations) | |||
| 4274 | return; | |||
| 4275 | ||||
| 4276 | for (loc = 0; loc < nfslsp->nl_numlocs; loc++) { | |||
| 4277 | fsl = nfslsp->nl_locations[loc]; | |||
| 4278 | if (!fsl) | |||
| 4279 | continue; | |||
| 4280 | if ((fsl->nl_servcount > 0) && fsl->nl_servers) { | |||
| 4281 | for (serv = 0; serv < fsl->nl_servcount; serv++) { | |||
| 4282 | fss = fsl->nl_servers[serv]; | |||
| 4283 | if (!fss) | |||
| 4284 | continue; | |||
| 4285 | if ((fss->ns_addrcount > 0) && fss->ns_addresses) { | |||
| 4286 | for (addr = 0; addr < fss->ns_addrcount; addr++) | |||
| 4287 | FREE(fss->ns_addresses[addr], M_TEMP)_FREE((void *)fss->ns_addresses[addr], 80); | |||
| 4288 | FREE(fss->ns_addresses, M_TEMP)_FREE((void *)fss->ns_addresses, 80); | |||
| 4289 | } | |||
| 4290 | FREE(fss->ns_name, M_TEMP)_FREE((void *)fss->ns_name, 80); | |||
| 4291 | FREE(fss, M_TEMP)_FREE((void *)fss, 80); | |||
| 4292 | } | |||
| 4293 | FREE(fsl->nl_servers, M_TEMP)_FREE((void *)fsl->nl_servers, 80); | |||
| 4294 | } | |||
| 4295 | fsp = &fsl->nl_path; | |||
| 4296 | if (fsp->np_compcount && fsp->np_components) { | |||
| 4297 | for (comp = 0; comp < fsp->np_compcount; comp++) | |||
| 4298 | if (fsp->np_components[comp]) | |||
| 4299 | FREE(fsp->np_components[comp], M_TEMP)_FREE((void *)fsp->np_components[comp], 80); | |||
| 4300 | FREE(fsp->np_components, M_TEMP)_FREE((void *)fsp->np_components, 80); | |||
| 4301 | } | |||
| 4302 | FREE(fsl, M_TEMP)_FREE((void *)fsl, 80); | |||
| 4303 | } | |||
| 4304 | FREE(nfslsp->nl_locations, M_TEMP)_FREE((void *)nfslsp->nl_locations, 80); | |||
| 4305 | nfslsp->nl_numlocs = 0; | |||
| 4306 | nfslsp->nl_locations = NULL((void *)0); | |||
| 4307 | } | |||
| 4308 | ||||
| 4309 | void | |||
| 4310 | nfs_mount_rele(struct nfsmount *nmp) | |||
| 4311 | { | |||
| 4312 | int wup = 0; | |||
| 4313 | ||||
| 4314 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4315 | if (nmp->nm_ref < 1) | |||
| 4316 | panic("nfs zombie mount underflow\n")(panic)("\"nfs zombie mount underflow\\n\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "4316"); | |||
| 4317 | nmp->nm_ref--; | |||
| 4318 | if (nmp->nm_ref == 0) | |||
| 4319 | wup = nmp->nm_state & NFSSTA_MOUNT_DRAIN0x80000000; | |||
| 4320 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4321 | if (wup) | |||
| 4322 | wakeup(&nmp->nm_ref); | |||
| 4323 | } | |||
| 4324 | ||||
| 4325 | void | |||
| 4326 | nfs_mount_drain_and_cleanup(struct nfsmount *nmp) | |||
| 4327 | { | |||
| 4328 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4329 | nmp->nm_state |= NFSSTA_MOUNT_DRAIN0x80000000; | |||
| 4330 | while (nmp->nm_ref > 0) { | |||
| 4331 | msleep(&nmp->nm_ref, &nmp->nm_lock, PZERO22-1, "nfs_mount_drain", NULL((void *)0)); | |||
| 4332 | } | |||
| 4333 | assert(nmp->nm_ref == 0)((void)0); | |||
| 4334 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4335 | nfs_mount_cleanup(nmp); | |||
| 4336 | } | |||
| 4337 | ||||
| 4338 | /* | |||
| 4339 | * nfs_mount_zombie | |||
| 4340 | */ | |||
| 4341 | void | |||
| 4342 | nfs_mount_zombie(struct nfsmount *nmp, int nm_state_flags) | |||
| 4343 | { | |||
| 4344 | struct nfsreq *req, *treq; | |||
| 4345 | struct nfs_reqqhead iodq, resendq; | |||
| 4346 | struct timespec ts = { 1, 0 }; | |||
| 4347 | struct nfs_open_owner *noop, *nextnoop; | |||
| 4348 | nfsnode_t np; | |||
| 4349 | int docallback; | |||
| 4350 | ||||
| 4351 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4352 | nmp->nm_state |= nm_state_flags; | |||
| 4353 | nmp->nm_ref++; | |||
| 4354 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4355 | ||||
| 4356 | /* stop callbacks */ | |||
| 4357 | if ((nmp->nm_vers >= NFS_VER44) && !NMFLAG(nmp, NOCALLBACK)(((uint32_t *)((nmp)->nm_flags))[(10)/32] & (1<< ((10)%32))) && nmp->nm_cbidnm_un.v4.cbid) | |||
| 4358 | nfs4_mount_callback_shutdown(nmp); | |||
| 4359 | ||||
| 4360 | /* Destroy any RPCSEC_GSS contexts */ | |||
| 4361 | nfs_gss_clnt_ctx_unmount(nmp); | |||
| 4362 | ||||
| 4363 | /* mark the socket for termination */ | |||
| 4364 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4365 | nmp->nm_sockflags |= NMSOCK_UNMOUNT0x0008; | |||
| 4366 | ||||
| 4367 | /* Have the socket thread send the unmount RPC, if requested/appropriate. */ | |||
| 4368 | if ((nmp->nm_vers < NFS_VER44) && (nmp->nm_state & NFSSTA_MOUNTED0x00004000) && | |||
| 4369 | !(nmp->nm_state & (NFSSTA_FORCE0x00020000|NFSSTA_DEAD0x04000000)) && NMFLAG(nmp, CALLUMNT)(((uint32_t *)((nmp)->nm_flags))[(5)/32] & (1<<( (5)%32)))) | |||
| 4370 | nfs_mount_sock_thread_wake(nmp); | |||
| 4371 | ||||
| 4372 | /* wait for the socket thread to terminate */ | |||
| 4373 | while (nmp->nm_sockthd && current_thread() != nmp->nm_sockthd) { | |||
| 4374 | wakeup(&nmp->nm_sockthd); | |||
| 4375 | msleep(&nmp->nm_sockthd, &nmp->nm_lock, PZERO22-1, "nfswaitsockthd", &ts); | |||
| 4376 | } | |||
| 4377 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4378 | ||||
| 4379 | /* tear down the socket */ | |||
| 4380 | nfs_disconnect(nmp); | |||
| 4381 | ||||
| 4382 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4383 | ||||
| 4384 | if ((nmp->nm_vers >= NFS_VER44) && !NMFLAG(nmp, NOCALLBACK)(((uint32_t *)((nmp)->nm_flags))[(10)/32] & (1<< ((10)%32))) && nmp->nm_cbidnm_un.v4.cbid) { | |||
| 4385 | /* clear out any pending delegation return requests */ | |||
| 4386 | while ((np = TAILQ_FIRST(&nmp->nm_dreturnq)((&nmp->nm_un.v4.dreturnq)->tqh_first))) { | |||
| 4387 | TAILQ_REMOVE(&nmp->nm_dreturnq, np, n_dreturn)do { if (((((np))->n_dreturn.tqe_next)) != ((void *)0)) (( (np))->n_dreturn.tqe_next)->n_dreturn.tqe_prev = (np)-> n_dreturn.tqe_prev; else { (&nmp->nm_un.v4.dreturnq)-> tqh_last = (np)->n_dreturn.tqe_prev; ; } *(np)->n_dreturn .tqe_prev = (((np))->n_dreturn.tqe_next); ; ; ; } while (0 ); | |||
| 4388 | np->n_dreturn.tqe_next = NFSNOLIST((void *)0x0badcafe); | |||
| 4389 | } | |||
| 4390 | } | |||
| 4391 | ||||
| 4392 | /* cancel any renew timer */ | |||
| 4393 | if ((nmp->nm_vers >= NFS_VER44) && nmp->nm_renew_timernm_un.v4.renew_timer) { | |||
| 4394 | thread_call_cancel(nmp->nm_renew_timernm_un.v4.renew_timer); | |||
| 4395 | thread_call_free(nmp->nm_renew_timernm_un.v4.renew_timer); | |||
| 4396 | } | |||
| 4397 | ||||
| 4398 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4399 | ||||
| 4400 | if (nmp->nm_state & NFSSTA_MOUNTED0x00004000) | |||
| 4401 | switch (nmp->nm_lockmode) { | |||
| 4402 | case NFS_LOCK_MODE_DISABLED1: | |||
| 4403 | case NFS_LOCK_MODE_LOCAL2: | |||
| 4404 | break; | |||
| 4405 | case NFS_LOCK_MODE_ENABLED0: | |||
| 4406 | default: | |||
| 4407 | if (nmp->nm_vers <= NFS_VER33) { | |||
| 4408 | nfs_lockd_mount_unregister(nmp); | |||
| 4409 | nmp->nm_lockmode = NFS_LOCK_MODE_DISABLED1; | |||
| 4410 | } | |||
| 4411 | break; | |||
| 4412 | } | |||
| 4413 | ||||
| 4414 | if ((nmp->nm_vers >= NFS_VER44) && nmp->nm_longidnm_un.v4.longid) { | |||
| 4415 | /* remove/deallocate the client ID data */ | |||
| 4416 | lck_mtx_lock(nfs_global_mutex); | |||
| 4417 | TAILQ_REMOVE(&nfsclientids, nmp->nm_longid, nci_link)do { if (((((nmp->nm_un.v4.longid))->nci_link.tqe_next) ) != ((void *)0)) (((nmp->nm_un.v4.longid))->nci_link.tqe_next )->nci_link.tqe_prev = (nmp->nm_un.v4.longid)->nci_link .tqe_prev; else { (&nfsclientids)->tqh_last = (nmp-> nm_un.v4.longid)->nci_link.tqe_prev; ; } *(nmp->nm_un.v4 .longid)->nci_link.tqe_prev = (((nmp->nm_un.v4.longid)) ->nci_link.tqe_next); ; ; ; } while (0); | |||
| 4418 | if (nmp->nm_longidnm_un.v4.longid->nci_id) | |||
| 4419 | FREE(nmp->nm_longid->nci_id, M_TEMP)_FREE((void *)nmp->nm_un.v4.longid->nci_id, 80); | |||
| 4420 | FREE(nmp->nm_longid, M_TEMP)_FREE((void *)nmp->nm_un.v4.longid, 80); | |||
| 4421 | lck_mtx_unlock(nfs_global_mutex); | |||
| 4422 | } | |||
| 4423 | ||||
| 4424 | /* | |||
| 4425 | * Be sure all requests for this mount are completed | |||
| 4426 | * and removed from the resend queue. | |||
| 4427 | */ | |||
| 4428 | TAILQ_INIT(&resendq)do { (((&resendq))->tqh_first) = ((void *)0); (&resendq )->tqh_last = &(((&resendq))->tqh_first); ; } while (0); | |||
| 4429 | lck_mtx_lock(nfs_request_mutex); | |||
| 4430 | TAILQ_FOREACH(req, &nfs_reqq, r_chain)for ((req) = (((&nfs_reqq))->tqh_first); (req); (req) = (((req))->r_chain.tqe_next)) { | |||
| 4431 | if (req->r_nmp == nmp) { | |||
| 4432 | lck_mtx_lock(&req->r_mtx); | |||
| 4433 | if (!req->r_error && req->r_nmrep.nmc_mhead == NULL((void *)0)) | |||
| 4434 | req->r_error = EIO5; | |||
| 4435 | if (req->r_flags & R_RESENDQ0x00004000) { | |||
| 4436 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4437 | req->r_flags &= ~R_RESENDQ0x00004000; | |||
| 4438 | if (req->r_rchain.tqe_next != NFSREQNOLIST((void *)0x0badcafe)) { | |||
| 4439 | TAILQ_REMOVE(&nmp->nm_resendq, req, r_rchain)do { if (((((req))->r_rchain.tqe_next)) != ((void *)0)) (( (req))->r_rchain.tqe_next)->r_rchain.tqe_prev = (req)-> r_rchain.tqe_prev; else { (&nmp->nm_resendq)->tqh_last = (req)->r_rchain.tqe_prev; ; } *(req)->r_rchain.tqe_prev = (((req))->r_rchain.tqe_next); ; ; ; } while (0); | |||
| 4440 | /* | |||
| 4441 | * Queue up the request so that we can unreference them | |||
| 4442 | * with out holding nfs_request_mutex | |||
| 4443 | */ | |||
| 4444 | TAILQ_INSERT_TAIL(&resendq, req, r_rchain)do { (((req))->r_rchain.tqe_next) = ((void *)0); (req)-> r_rchain.tqe_prev = (&resendq)->tqh_last; *(&resendq )->tqh_last = (req); (&resendq)->tqh_last = &(( (req))->r_rchain.tqe_next); ; ; } while (0); | |||
| 4445 | } | |||
| 4446 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4447 | } | |||
| 4448 | wakeup(req); | |||
| 4449 | lck_mtx_unlock(&req->r_mtx); | |||
| 4450 | } | |||
| 4451 | } | |||
| 4452 | lck_mtx_unlock(nfs_request_mutex); | |||
| 4453 | ||||
| 4454 | /* Since we've drop the request mutex we can now safely unreference the request */ | |||
| 4455 | TAILQ_FOREACH_SAFE(req, &resendq, r_rchain, treq)for ((req) = (((&resendq))->tqh_first); (req) && ((treq) = (((req))->r_rchain.tqe_next), 1); (req) = (treq )) { | |||
| 4456 | TAILQ_REMOVE(&resendq, req, r_rchain)do { if (((((req))->r_rchain.tqe_next)) != ((void *)0)) (( (req))->r_rchain.tqe_next)->r_rchain.tqe_prev = (req)-> r_rchain.tqe_prev; else { (&resendq)->tqh_last = (req) ->r_rchain.tqe_prev; ; } *(req)->r_rchain.tqe_prev = (( (req))->r_rchain.tqe_next); ; ; ; } while (0); | |||
| 4457 | nfs_request_rele(req); | |||
| 4458 | } | |||
| 4459 | ||||
| 4460 | /* | |||
| 4461 | * Now handle and outstanding async requests. We need to walk the | |||
| 4462 | * request queue again this time with the nfsiod_mutex held. No | |||
| 4463 | * other iods can grab our requests until we've put them on our own | |||
| 4464 | * local iod queue for processing. | |||
| 4465 | */ | |||
| 4466 | TAILQ_INIT(&iodq)do { (((&iodq))->tqh_first) = ((void *)0); (&iodq) ->tqh_last = &(((&iodq))->tqh_first); ; } while (0); | |||
| 4467 | lck_mtx_lock(nfs_request_mutex); | |||
| 4468 | lck_mtx_lock(nfsiod_mutex); | |||
| 4469 | TAILQ_FOREACH(req, &nfs_reqq, r_chain)for ((req) = (((&nfs_reqq))->tqh_first); (req); (req) = (((req))->r_chain.tqe_next)) { | |||
| 4470 | if (req->r_nmp == nmp) { | |||
| 4471 | lck_mtx_lock(&req->r_mtx); | |||
| 4472 | if (req->r_callback.rcb_func | |||
| 4473 | && !(req->r_flags & R_WAITSENT0x00000200) && !(req->r_flags & R_IOD0x00020000)) { | |||
| 4474 | /* | |||
| 4475 | * Since R_IOD is not set then we need to handle it. If | |||
| 4476 | * we're not on a list add it to our iod queue. Otherwise | |||
| 4477 | * we must already be on nm_iodq which is added to our | |||
| 4478 | * local queue below. | |||
| 4479 | * %%% We should really keep a back pointer to our iod queue | |||
| 4480 | * that we're on. | |||
| 4481 | */ | |||
| 4482 | req->r_flags |= R_IOD0x00020000; | |||
| 4483 | if (req->r_achain.tqe_next == NFSREQNOLIST((void *)0x0badcafe)) { | |||
| 4484 | TAILQ_INSERT_TAIL(&iodq, req, r_achain)do { (((req))->r_achain.tqe_next) = ((void *)0); (req)-> r_achain.tqe_prev = (&iodq)->tqh_last; *(&iodq)-> tqh_last = (req); (&iodq)->tqh_last = &(((req))-> r_achain.tqe_next); ; ; } while (0); | |||
| 4485 | } | |||
| 4486 | } | |||
| 4487 | lck_mtx_unlock(&req->r_mtx); | |||
| 4488 | } | |||
| 4489 | } | |||
| 4490 | ||||
| 4491 | /* finish any async I/O RPCs queued up */ | |||
| 4492 | if (nmp->nm_iodlink.tqe_next != NFSNOLIST((void *)0x0badcafe)) | |||
| 4493 | TAILQ_REMOVE(&nfsiodmounts, nmp, nm_iodlink)do { if (((((nmp))->nm_iodlink.tqe_next)) != ((void *)0)) ( ((nmp))->nm_iodlink.tqe_next)->nm_iodlink.tqe_prev = (nmp )->nm_iodlink.tqe_prev; else { (&nfsiodmounts)->tqh_last = (nmp)->nm_iodlink.tqe_prev; ; } *(nmp)->nm_iodlink.tqe_prev = (((nmp))->nm_iodlink.tqe_next); ; ; ; } while (0); | |||
| 4494 | TAILQ_CONCAT(&iodq, &nmp->nm_iodq, r_achain)do { if (!((&nmp->nm_iodq)->tqh_first == ((void *)0 ))) { *(&iodq)->tqh_last = (&nmp->nm_iodq)-> tqh_first; (&nmp->nm_iodq)->tqh_first->r_achain. tqe_prev = (&iodq)->tqh_last; (&iodq)->tqh_last = (&nmp->nm_iodq)->tqh_last; do { ((((&nmp-> nm_iodq)))->tqh_first) = ((void *)0); ((&nmp->nm_iodq ))->tqh_last = &((((&nmp->nm_iodq)))->tqh_first ); ; } while (0); ; ; } } while (0); | |||
| 4495 | lck_mtx_unlock(nfsiod_mutex); | |||
| 4496 | lck_mtx_unlock(nfs_request_mutex); | |||
| 4497 | ||||
| 4498 | TAILQ_FOREACH_SAFE(req, &iodq, r_achain, treq)for ((req) = (((&iodq))->tqh_first); (req) && ( (treq) = (((req))->r_achain.tqe_next), 1); (req) = (treq)) { | |||
| 4499 | TAILQ_REMOVE(&iodq, req, r_achain)do { if (((((req))->r_achain.tqe_next)) != ((void *)0)) (( (req))->r_achain.tqe_next)->r_achain.tqe_prev = (req)-> r_achain.tqe_prev; else { (&iodq)->tqh_last = (req)-> r_achain.tqe_prev; ; } *(req)->r_achain.tqe_prev = (((req) )->r_achain.tqe_next); ; ; ; } while (0); | |||
| 4500 | req->r_achain.tqe_next = NFSREQNOLIST((void *)0x0badcafe); | |||
| 4501 | lck_mtx_lock(&req->r_mtx); | |||
| 4502 | docallback = !(req->r_flags & R_WAITSENT0x00000200); | |||
| 4503 | lck_mtx_unlock(&req->r_mtx); | |||
| 4504 | if (docallback) | |||
| 4505 | req->r_callback.rcb_func(req); | |||
| 4506 | } | |||
| 4507 | ||||
| 4508 | /* clean up common state */ | |||
| 4509 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4510 | while ((np = LIST_FIRST(&nmp->nm_monlist)((&nmp->nm_monlist)->lh_first))) { | |||
| 4511 | LIST_REMOVE(np, n_monlink)do { ; ; if ((((np))->n_monlink.le_next) != ((void *)0)) ( ((np))->n_monlink.le_next)->n_monlink.le_prev = (np)-> n_monlink.le_prev; *(np)->n_monlink.le_prev = (((np))-> n_monlink.le_next); ; ; } while (0); | |||
| 4512 | np->n_monlink.le_next = NFSNOLIST((void *)0x0badcafe); | |||
| 4513 | } | |||
| 4514 | TAILQ_FOREACH_SAFE(noop, &nmp->nm_open_owners, noo_link, nextnoop)for ((noop) = (((&nmp->nm_open_owners))->tqh_first) ; (noop) && ((nextnoop) = (((noop))->noo_link.tqe_next ), 1); (noop) = (nextnoop)) { | |||
| 4515 | TAILQ_REMOVE(&nmp->nm_open_owners, noop, noo_link)do { if (((((noop))->noo_link.tqe_next)) != ((void *)0)) ( ((noop))->noo_link.tqe_next)->noo_link.tqe_prev = (noop )->noo_link.tqe_prev; else { (&nmp->nm_open_owners) ->tqh_last = (noop)->noo_link.tqe_prev; ; } *(noop)-> noo_link.tqe_prev = (((noop))->noo_link.tqe_next); ; ; ; } while (0); | |||
| 4516 | noop->noo_flags &= ~NFS_OPEN_OWNER_LINK0x1; | |||
| 4517 | if (noop->noo_refcnt) | |||
| 4518 | continue; | |||
| 4519 | nfs_open_owner_destroy(noop); | |||
| 4520 | } | |||
| 4521 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4522 | ||||
| 4523 | /* clean up NFSv4 state */ | |||
| 4524 | if (nmp->nm_vers >= NFS_VER44) { | |||
| 4525 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4526 | while ((np = TAILQ_FIRST(&nmp->nm_delegations)((&nmp->nm_un.v4.delegations)->tqh_first))) { | |||
| 4527 | TAILQ_REMOVE(&nmp->nm_delegations, np, n_dlink)do { if (((((np))->n_dlink.tqe_next)) != ((void *)0)) (((np ))->n_dlink.tqe_next)->n_dlink.tqe_prev = (np)->n_dlink .tqe_prev; else { (&nmp->nm_un.v4.delegations)->tqh_last = (np)->n_dlink.tqe_prev; ; } *(np)->n_dlink.tqe_prev = (((np))->n_dlink.tqe_next); ; ; ; } while (0); | |||
| 4528 | np->n_dlink.tqe_next = NFSNOLIST((void *)0x0badcafe); | |||
| 4529 | } | |||
| 4530 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4531 | } | |||
| 4532 | ||||
| 4533 | nfs_mount_rele(nmp); | |||
| 4534 | } | |||
| 4535 | ||||
| 4536 | /* | |||
| 4537 | * cleanup/destroy an nfsmount | |||
| 4538 | */ | |||
| 4539 | void | |||
| 4540 | nfs_mount_cleanup(struct nfsmount *nmp) | |||
| 4541 | { | |||
| 4542 | if (!nmp) | |||
| 4543 | return; | |||
| 4544 | ||||
| 4545 | nfs_mount_zombie(nmp, 0); | |||
| 4546 | ||||
| 4547 | NFS_VFS_DBG("Unmounting %s from %s\n",if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "Unmounting %s from %s\n", __func__, 4549 , vfs_statfs(nmp->nm_mountp)->f_mntfromname, vfs_statfs (nmp->nm_mountp)->f_mntonname) | |||
| 4548 | vfs_statfs(nmp->nm_mountp)->f_mntfromname,if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "Unmounting %s from %s\n", __func__, 4549 , vfs_statfs(nmp->nm_mountp)->f_mntfromname, vfs_statfs (nmp->nm_mountp)->f_mntonname) | |||
| 4549 | vfs_statfs(nmp->nm_mountp)->f_mntonname)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "Unmounting %s from %s\n", __func__, 4549 , vfs_statfs(nmp->nm_mountp)->f_mntfromname, vfs_statfs (nmp->nm_mountp)->f_mntonname); | |||
| 4550 | NFS_VFS_DBG("nfs state = 0x%8.8x\n", nmp->nm_state)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "nfs state = 0x%8.8x\n", __func__, 4550, nmp->nm_state); | |||
| 4551 | NFS_VFS_DBG("nfs socket flags = 0x%8.8x\n", nmp->nm_sockflags)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "nfs socket flags = 0x%8.8x\n", __func__ , 4551, nmp->nm_sockflags); | |||
| 4552 | NFS_VFS_DBG("nfs mount ref count is %d\n", nmp->nm_ref)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "nfs mount ref count is %d\n", __func__, 4552, nmp->nm_ref); | |||
| 4553 | NFS_VFS_DBG("mount ref count is %d\n", nmp->nm_mountp->mnt_count)if (__builtin_expect((nfs_debug_ctl & 0xf), 0)) nfs_printf (0x40, 7, "%s: %d: " "mount ref count is %d\n", __func__, 4553 , nmp->nm_mountp->mnt_count); | |||
| 4554 | ||||
| 4555 | if (nmp->nm_mountp) | |||
| 4556 | vfs_setfsprivate(nmp->nm_mountp, NULL((void *)0)); | |||
| 4557 | ||||
| 4558 | lck_mtx_lock(&nmp->nm_lock); | |||
| 4559 | if (nmp->nm_ref) | |||
| 4560 | panic("Some one has grabbed a ref %d state flags = 0x%8.8x\n", nmp->nm_ref, nmp->nm_state)(panic)("\"Some one has grabbed a ref %d state flags = 0x%8.8x\\n\"" "@" "/Users/vlad/tmp/xnu-3789.41.3/bsd/nfs/nfs_vfsops.c" ":" "4560", nmp->nm_ref, nmp->nm_state); | |||
| 4561 | ||||
| 4562 | if (nmp->nm_saddr) | |||
| 4563 | FREE(nmp->nm_saddr, M_SONAME)_FREE((void *)nmp->nm_saddr, 11); | |||
| 4564 | if ((nmp->nm_vers < NFS_VER44) && nmp->nm_rqsaddrnm_un.v3.rqsaddr) | |||
| 4565 | FREE(nmp->nm_rqsaddr, M_SONAME)_FREE((void *)nmp->nm_un.v3.rqsaddr, 11); | |||
| 4566 | ||||
| 4567 | if (IS_VALID_CRED(nmp->nm_mcred)((nmp->nm_mcred) != ((kauth_cred_t )0) && (nmp-> nm_mcred) != ((kauth_cred_t )-1))) | |||
| 4568 | kauth_cred_unref(&nmp->nm_mcred); | |||
| 4569 | ||||
| 4570 | nfs_fs_locations_cleanup(&nmp->nm_locations); | |||
| 4571 | ||||
| 4572 | if (nmp->nm_realm) | |||
| 4573 | FREE(nmp->nm_realm, M_TEMP)_FREE((void *)nmp->nm_realm, 80); | |||
| 4574 | if (nmp->nm_principal) | |||
| 4575 | FREE(nmp->nm_principal, M_TEMP)_FREE((void *)nmp->nm_principal, 80); | |||
| 4576 | if (nmp->nm_sprinc) | |||
| 4577 | FREE(nmp->nm_sprinc, M_TEMP)_FREE((void *)nmp->nm_sprinc, 80); | |||
| 4578 | ||||
| 4579 | if (nmp->nm_args) | |||
| 4580 | xb_free(nmp->nm_args); | |||
| 4581 | ||||
| 4582 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 4583 | ||||
| 4584 | lck_mtx_destroy(&nmp->nm_lock, nfs_mount_grp); | |||
| 4585 | if (nmp->nm_fh) | |||
| 4586 | FREE(nmp->nm_fh, M_TEMP)_FREE((void *)nmp->nm_fh, 80); | |||
| 4587 | FREE_ZONE((caddr_t)nmp, sizeof (struct nfsmount), M_NFSMNT)_FREE_ZONE((void *)(caddr_t)nmp, sizeof (struct nfsmount), 23 ); | |||
| 4588 | } | |||
| 4589 | ||||
| 4590 | /* | |||
| 4591 | * Return root of a filesystem | |||
| 4592 | */ | |||
| 4593 | int | |||
| 4594 | nfs_vfs_root(mount_t mp, vnode_t *vpp, __unused__attribute__((unused)) vfs_context_t ctx) | |||
| 4595 | { | |||
| 4596 | vnode_t vp; | |||
| 4597 | struct nfsmount *nmp; | |||
| 4598 | int error; | |||
| 4599 | u_int32_t vpid; | |||
| 4600 | ||||
| 4601 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 4602 | if (!nmp || !nmp->nm_dnp) | |||
| 4603 | return (ENXIO6); | |||
| 4604 | vp = NFSTOV(nmp->nm_dnp)((nmp->nm_dnp)->n_vnode); | |||
| 4605 | vpid = vnode_vid(vp); | |||
| 4606 | while ((error = vnode_getwithvid(vp, vpid))) { | |||
| 4607 | /* vnode_get() may return ENOENT if the dir changes. */ | |||
| 4608 | /* If that happens, just try it again, else return the error. */ | |||
| 4609 | if ((error != ENOENT2) || (vnode_vid(vp) == vpid)) | |||
| 4610 | return (error); | |||
| 4611 | vpid = vnode_vid(vp); | |||
| 4612 | } | |||
| 4613 | *vpp = vp; | |||
| 4614 | return (0); | |||
| 4615 | } | |||
| 4616 | ||||
| 4617 | /* | |||
| 4618 | * Do operations associated with quotas | |||
| 4619 | */ | |||
| 4620 | #if !QUOTA1 | |||
| 4621 | int | |||
| 4622 | nfs_vfs_quotactl( | |||
| 4623 | __unused__attribute__((unused)) mount_t mp, | |||
| 4624 | __unused__attribute__((unused)) int cmds, | |||
| 4625 | __unused__attribute__((unused)) uid_t uid, | |||
| 4626 | __unused__attribute__((unused)) caddr_t datap, | |||
| 4627 | __unused__attribute__((unused)) vfs_context_t context) | |||
| 4628 | { | |||
| 4629 | return (ENOTSUP45); | |||
| 4630 | } | |||
| 4631 | #else | |||
| 4632 | ||||
| 4633 | int | |||
| 4634 | nfs3_getquota(struct nfsmount *nmp, vfs_context_t ctx, uid_t id, int type, struct dqblk *dqb) | |||
| 4635 | { | |||
| 4636 | int error = 0, slen, timeo; | |||
| 4637 | int rqport = 0, rqproto, rqvers = (type == GRPQUOTA1) ? RPCRQUOTA_EXT_VER2 : RPCRQUOTA_VER1; | |||
| 4638 | thread_t thd = vfs_context_thread(ctx); | |||
| 4639 | kauth_cred_t cred = vfs_context_ucred(ctx); | |||
| 4640 | char *path; | |||
| 4641 | uint64_t xid = 0; | |||
| 4642 | struct nfsm_chain nmreq, nmrep; | |||
| 4643 | mbuf_t mreq; | |||
| 4644 | uint32_t val = 0, bsize = 0; | |||
| 4645 | struct sockaddr *rqsaddr; | |||
| 4646 | struct timeval now; | |||
| 4647 | ||||
| 4648 | if (!nmp->nm_saddr) | |||
| 4649 | return (ENXIO6); | |||
| 4650 | ||||
| 4651 | if (NMFLAG(nmp, NOQUOTA)(((uint32_t *)((nmp)->nm_flags))[(15)/32] & (1<< ((15)%32)))) | |||
| 4652 | return (ENOTSUP45); | |||
| 4653 | ||||
| 4654 | if (!nmp->nm_rqsaddrnm_un.v3.rqsaddr) | |||
| 4655 | MALLOC(nmp->nm_rqsaddr, struct sockaddr *, sizeof(struct sockaddr_storage), M_SONAME, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nmp->nm_un.v3.rqsaddr) = (struct sockaddr *)__MALLOC (sizeof(struct sockaddr_storage), 11, 0x0000|0x0004, &site ); }); | |||
| 4656 | if (!nmp->nm_rqsaddrnm_un.v3.rqsaddr) | |||
| 4657 | return (ENOMEM12); | |||
| 4658 | rqsaddr = nmp->nm_rqsaddrnm_un.v3.rqsaddr; | |||
| 4659 | if (rqsaddr->sa_family == AF_INET630) | |||
| 4660 | rqport = ntohs(((struct sockaddr_in6*)rqsaddr)->sin6_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in6*)rqsaddr )->sin6_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6 *)rqsaddr)->sin6_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in6*)rqsaddr)->sin6_port) & 0x00ff ) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)rqsaddr )->sin6_port))); | |||
| 4661 | else if (rqsaddr->sa_family == AF_INET2) | |||
| 4662 | rqport = ntohs(((struct sockaddr_in*)rqsaddr)->sin_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in*)rqsaddr )->sin_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in *)rqsaddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in*)rqsaddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)rqsaddr)->sin_port ))); | |||
| 4663 | ||||
| 4664 | timeo = NMFLAG(nmp, SOFT)(((uint32_t *)((nmp)->nm_flags))[(0)/32] & (1<<( (0)%32))) ? 10 : 60; | |||
| 4665 | rqproto = IPPROTO_UDP17; /* XXX should prefer TCP if mount is TCP */ | |||
| 4666 | ||||
| 4667 | /* check if we have a recently cached rquota port */ | |||
| 4668 | microuptime(&now); | |||
| 4669 | if (!rqport || ((nmp->nm_rqsaddrstampnm_un.v3.rqsaddrstamp + 60) >= (uint32_t)now.tv_sec)) { | |||
| 4670 | /* send portmap request to get rquota port */ | |||
| 4671 | bcopy(nmp->nm_saddr, rqsaddr, min(sizeof(struct sockaddr_storage), nmp->nm_saddr->sa_len)); | |||
| 4672 | error = nfs_portmap_lookup(nmp, ctx, rqsaddr, NULL((void *)0), RPCPROG_RQUOTA100011, rqvers, rqproto, timeo); | |||
| 4673 | if (error) | |||
| 4674 | return (error); | |||
| 4675 | if (rqsaddr->sa_family == AF_INET630) | |||
| 4676 | rqport = ntohs(((struct sockaddr_in6*)rqsaddr)->sin6_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in6*)rqsaddr )->sin6_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in6 *)rqsaddr)->sin6_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in6*)rqsaddr)->sin6_port) & 0x00ff ) << 8))) : _OSSwapInt16(((struct sockaddr_in6*)rqsaddr )->sin6_port))); | |||
| 4677 | else if (rqsaddr->sa_family == AF_INET2) | |||
| 4678 | rqport = ntohs(((struct sockaddr_in*)rqsaddr)->sin_port)((__uint16_t)(__builtin_constant_p(((struct sockaddr_in*)rqsaddr )->sin_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in *)rqsaddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t )(((struct sockaddr_in*)rqsaddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)rqsaddr)->sin_port ))); | |||
| 4679 | else | |||
| 4680 | return (EIO5); | |||
| 4681 | if (!rqport) | |||
| 4682 | return (ENOTSUP45); | |||
| 4683 | microuptime(&now); | |||
| 4684 | nmp->nm_rqsaddrstampnm_un.v3.rqsaddrstamp = now.tv_sec; | |||
| 4685 | } | |||
| 4686 | ||||
| 4687 | /* rquota request */ | |||
| 4688 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 4689 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 4690 | path = &vfs_statfs(nmp->nm_mountp)->f_mntfromname[0]; | |||
| 4691 | while (*path && (*path != '/')) | |||
| 4692 | path++; | |||
| 4693 | slen = strlen(path); | |||
| 4694 | nfsm_chain_build_alloc_init(error, &nmreq, 3 * NFSX_UNSIGNED + nfsm_rndup(slen))do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((3 * 4 + (((slen)+3)&(~0x3)))) >= nfs_mbuf_minclsize ) ((error)) = mbuf_mclget(MBUF_WAITOK, MBUF_TYPE_DATA, (& ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA , (&ncbimb)); } while (0); if (error) break; do { ((& nmreq))->nmc_mhead = (ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq))->nmc_mcur); ((&nmreq ))->nmc_flags = 0; } while (0); } while (0); | |||
| 4695 | nfsm_chain_add_name(error, &nmreq, path, slen, nmp)do { if (error) break; if ((((uint32_t *)(((nmp))->nm_flags ))[(14)/32] & (1<<((14)%32)))) (error) = nfsm_chain_add_string_nfc ((&nmreq), (const uint8_t*)(path), (slen)); else do { do { do { if ((((error)))) break; if (((((&nmreq))))->nmc_left < (4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq )))), (4)); if (!((((error)))) && (((((&nmreq)))) ->nmc_left < (4))) ((((error)))) = 12; } } while (0); if (((error))) break; *((uint32_t*)(((&nmreq)))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)(((slen)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((slen)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((slen)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((slen)))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((slen)))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(((slen)))))); (((& nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4 ; } while (0); do { uint32_t rndlen = (((((slen)))+3)&(~0x3 )); if (((error))) break; if ((((&nmreq)))->nmc_left < rndlen) { (((error))) = nfsm_chain_add_opaque_f((((&nmreq ))), (const u_char*)(((path))), (((slen)))); break; } *(((uint32_t *)((((&nmreq)))->nmc_ptr))+((((((((slen))))+3)&(~0x3 ))>>2)-1)) = 0; bcopy((((path))), (((&nmreq)))-> nmc_ptr, (((slen)))); (((&nmreq)))->nmc_ptr += rndlen; (((&nmreq)))->nmc_left -= rndlen; } while (0); } while (0); } while (0); | |||
| 4696 | if (type == GRPQUOTA1) | |||
| 4697 | nfsm_chain_add_32(error, &nmreq, type)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(type)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(type)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(type)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(type)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(type)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(type))) ); (&nmreq)->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while (0); | |||
| 4698 | nfsm_chain_add_32(error, &nmreq, id)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(id)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(id)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(id)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(id)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(id)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(id)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 4699 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 4700 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4701 | error = nfsm_rpchead2(nmp, (rqproto == IPPROTO_UDP17) ? SOCK_DGRAM2 : SOCK_STREAM1, | |||
| 4702 | RPCPROG_RQUOTA100011, rqvers, RPCRQUOTA_GET1, | |||
| 4703 | RPCAUTH_SYS1, cred, NULL((void *)0), nmreq.nmc_mhead, &xid, &mreq); | |||
| 4704 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4705 | nmreq.nmc_mhead = NULL((void *)0); | |||
| 4706 | error = nfs_aux_request(nmp, thd, rqsaddr, NULL((void *)0), | |||
| 4707 | (rqproto == IPPROTO_UDP17) ? SOCK_DGRAM2 : SOCK_STREAM1, | |||
| 4708 | mreq, R_XID32(xid)((xid) & 0xffffffff), 0, timeo, &nmrep); | |||
| 4709 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4710 | ||||
| 4711 | /* parse rquota response */ | |||
| 4712 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4713 | if (!error && (val != RQUOTA_STAT_OK1)) { | |||
| 4714 | if (val == RQUOTA_STAT_NOQUOTA2) | |||
| 4715 | error = ENOENT2; | |||
| 4716 | else if (val == RQUOTA_STAT_EPERM3) | |||
| 4717 | error = EPERM1; | |||
| 4718 | else | |||
| 4719 | error = EIO5; | |||
| 4720 | } | |||
| 4721 | nfsm_chain_get_32(error, &nmrep, bsize)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (bsize ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4722 | nfsm_chain_adv(error, &nmrep, NFSX_UNSIGNED)do { if (error) break; if ((&nmrep)->nmc_left >= (uint32_t )(4)) { (&nmrep)->nmc_left -= (4); (&nmrep)->nmc_ptr += (4); } else { (error) = nfsm_chain_advance((&nmrep), ( 4)); } } while (0); | |||
| 4723 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4724 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4725 | dqb->dqb_bhardlimit = (uint64_t)val * bsize; | |||
| 4726 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4727 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4728 | dqb->dqb_bsoftlimit = (uint64_t)val * bsize; | |||
| 4729 | nfsm_chain_get_32(error, &nmrep, val)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (val ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4730 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4731 | dqb->dqb_curbytes = (uint64_t)val * bsize; | |||
| 4732 | nfsm_chain_get_32(error, &nmrep, dqb->dqb_ihardlimit)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (dqb ->dqb_ihardlimit) = ((uint32_t)(__builtin_constant_p((uint32_t )(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4733 | nfsm_chain_get_32(error, &nmrep, dqb->dqb_isoftlimit)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (dqb ->dqb_isoftlimit) = ((uint32_t)(__builtin_constant_p((uint32_t )(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4734 | nfsm_chain_get_32(error, &nmrep, dqb->dqb_curinodes)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (dqb ->dqb_curinodes) = ((uint32_t)(__builtin_constant_p((uint32_t )(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4735 | nfsm_chain_get_32(error, &nmrep, dqb->dqb_btime)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (dqb ->dqb_btime) = ((uint32_t)(__builtin_constant_p((uint32_t) (*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4736 | nfsm_chain_get_32(error, &nmrep, dqb->dqb_itime)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (dqb ->dqb_itime) = ((uint32_t)(__builtin_constant_p((uint32_t) (*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (*__tmpptr)) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(*__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4737 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4738 | dqb->dqb_id = id; | |||
| 4739 | nfsmout: | |||
| 4740 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4741 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4742 | return (error); | |||
| 4743 | } | |||
| 4744 | ||||
| 4745 | int | |||
| 4746 | nfs4_getquota(struct nfsmount *nmp, vfs_context_t ctx, uid_t id, int type, struct dqblk *dqb) | |||
| 4747 | { | |||
| 4748 | nfsnode_t np; | |||
| 4749 | int error = 0, status, nfsvers, numops; | |||
| 4750 | u_int64_t xid; | |||
| 4751 | struct nfsm_chain nmreq, nmrep; | |||
| 4752 | uint32_t bitmap[NFS_ATTR_BITMAP_LEN2]; | |||
| 4753 | thread_t thd = vfs_context_thread(ctx); | |||
| 4754 | kauth_cred_t cred = vfs_context_ucred(ctx); | |||
| 4755 | struct nfsreq_secinfo_args si; | |||
| 4756 | ||||
| 4757 | if (type != USRQUOTA0) /* NFSv4 only supports user quotas */ | |||
| 4758 | return (ENOTSUP45); | |||
| 4759 | ||||
| 4760 | /* first check that the server supports any of the quota attributes */ | |||
| 4761 | if (!NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_HARD)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(38)/32] & (1<<((38)%32))) && | |||
| 4762 | !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_SOFT)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(39)/32] & (1<<((39)%32))) && | |||
| 4763 | !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_USED)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(40)/32] & (1<<((40)%32)))) | |||
| 4764 | return (ENOTSUP45); | |||
| 4765 | ||||
| 4766 | /* | |||
| 4767 | * The credential passed to the server needs to have | |||
| 4768 | * an effective uid that matches the given uid. | |||
| 4769 | */ | |||
| 4770 | if (id != kauth_cred_getuid(cred)) { | |||
| 4771 | struct posix_cred temp_pcred; | |||
| 4772 | posix_cred_t pcred = posix_cred_get(cred); | |||
| 4773 | bzero(&temp_pcred, sizeof(temp_pcred)); | |||
| 4774 | temp_pcred.cr_uid = id; | |||
| 4775 | temp_pcred.cr_ngroups = pcred->cr_ngroups; | |||
| 4776 | bcopy(pcred->cr_groups, temp_pcred.cr_groups, sizeof(temp_pcred.cr_groups)); | |||
| 4777 | cred = posix_cred_create(&temp_pcred); | |||
| 4778 | if (!IS_VALID_CRED(cred)((cred) != ((kauth_cred_t )0) && (cred) != ((kauth_cred_t )-1))) | |||
| 4779 | return (ENOMEM12); | |||
| 4780 | } else { | |||
| 4781 | kauth_cred_ref(cred); | |||
| 4782 | } | |||
| 4783 | ||||
| 4784 | nfsvers = nmp->nm_vers; | |||
| 4785 | np = nmp->nm_dnp; | |||
| 4786 | if (!np) | |||
| 4787 | error = ENXIO6; | |||
| 4788 | if (error || ((error = vnode_get(NFSTOV(np)((np)->n_vnode))))) { | |||
| 4789 | kauth_cred_unref(&cred); | |||
| 4790 | return(error); | |||
| 4791 | } | |||
| 4792 | ||||
| 4793 | NFSREQ_SECINFO_SET(&si, np, NULL, 0, NULL, 0)do { (&si)->rsia_np = (np); (&si)->rsia_fh = (( (void *)0)); (&si)->rsia_fhsize = (0); (&si)->rsia_name = (((void *)0)); (&si)->rsia_namelen = (0); } while ( 0); | |||
| 4794 | nfsm_chain_null(&nmreq)do { (&nmreq)->nmc_mhead = (&nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); | |||
| 4795 | nfsm_chain_null(&nmrep)do { (&nmrep)->nmc_mhead = (&nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); | |||
| 4796 | ||||
| 4797 | // PUTFH + GETATTR | |||
| 4798 | numops = 2; | |||
| 4799 | nfsm_chain_build_alloc_init(error, &nmreq, 15 * NFSX_UNSIGNED)do { mbuf_t ncbimb; do { *(&ncbimb) = ((void *)0); if ((size_t )((15 * 4)) >= nfs_mbuf_minclsize) ((error)) = mbuf_mclget (MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); else ((error)) = mbuf_get(MBUF_WAITOK, MBUF_TYPE_DATA, (&ncbimb)); } while (0); if (error) break; do { ((&nmreq))->nmc_mhead = ( ncbimb); ((&nmreq))->nmc_mcur = ((&nmreq))->nmc_mhead ; ((&nmreq))->nmc_ptr = mbuf_data(((&nmreq))->nmc_mcur ); ((&nmreq))->nmc_left = mbuf_trailingspace(((&nmreq ))->nmc_mcur); ((&nmreq))->nmc_flags = 0; } while ( 0); } while (0); | |||
| 4800 | nfsm_chain_add_compound_header(error, &nmreq, "quota", nmp->nm_minor_vers, numops)do { if (("quota") && strlen("quota")) { char __nfstag [12 +1]; snprintf(__nfstag, sizeof(__nfstag), "%-*s", 12, ("quota" )); do { do { if (((error))) break; if ((((&nmreq)))-> nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((& nmreq))), (4)); if (!(((error))) && ((((&nmreq))) ->nmc_left < (4))) (((error))) = 12; } } while (0); if ( (error)) break; *((uint32_t*)((&nmreq))->nmc_ptr) = (( __builtin_constant_p((uint32_t)(12)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(12)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(12)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(12)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(12)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(12)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq ))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((( 12)+3)&(~0x3)); if ((error)) break; if (((&nmreq))-> nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f(( (&nmreq)), (const u_char*)(__nfstag), (12)); break; } *(( (uint32_t*)(((&nmreq))->nmc_ptr))+((((((12))+3)&(~ 0x3))>>2)-1)) = 0; bcopy((__nfstag), ((&nmreq))-> nmc_ptr, (12)); ((&nmreq))->nmc_ptr += rndlen; ((& nmreq))->nmc_left -= rndlen; } while (0); } else { do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), ( 4)); if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break ; *((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); ((&nmreq))->nmc_ptr += 4; ((&nmreq))-> nmc_left -= 4; } while (0); } do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error))) = nfsm_chain_new_mbuf ((((&nmreq))), (4)); if (!(((error))) && ((((& nmreq)))->nmc_left < (4))) (((error))) = 12; } } while ( 0); if ((error)) break; *((uint32_t*)((&nmreq))->nmc_ptr ) = ((__builtin_constant_p((uint32_t)((nmp->nm_minor_vers) )) ? ((__uint32_t)((((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )((nmp->nm_minor_vers))) & 0x00ff0000) >> 8) | ( ((__uint32_t)((uint32_t)((nmp->nm_minor_vers))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((nmp->nm_minor_vers ))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((nmp->nm_minor_vers))))); ((&nmreq))->nmc_ptr += 4 ; ((&nmreq))->nmc_left -= 4; } while (0); do { do { if (((error))) break; if ((((&nmreq)))->nmc_left < (4 )) { (((error))) = nfsm_chain_new_mbuf((((&nmreq))), (4)) ; if (!(((error))) && ((((&nmreq)))->nmc_left < (4))) (((error))) = 12; } } while (0); if ((error)) break; * ((uint32_t*)((&nmreq))->nmc_ptr) = ((__builtin_constant_p ((uint32_t)((numops))) ? ((__uint32_t)((((__uint32_t)((uint32_t )((numops))) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)((numops))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((numops))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((numops))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((numops))))); ((&nmreq))->nmc_ptr += 4; (( &nmreq))->nmc_left -= 4; } while (0); } while (0); | |||
| 4801 | numops--; | |||
| 4802 | nfsm_chain_add_32(error, &nmreq, NFS_OP_PUTFH)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(22)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(22)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(22)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(22)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(22)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(22)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 4803 | nfsm_chain_add_fh(error, &nmreq, nfsvers, np->n_fhp, np->n_fhsize)do { if (error) break; if ((nfsvers) != 2) do { do { if (((error ))) break; if ((((&nmreq)))->nmc_left < (4)) { (((error ))) = nfsm_chain_new_mbuf((((&nmreq))), (4)); if (!(((error ))) && ((((&nmreq)))->nmc_left < (4))) (((error ))) = 12; } } while (0); if ((error)) break; *((uint32_t*)((& nmreq))->nmc_ptr) = ((__builtin_constant_p((uint32_t)((np-> n_fhsize))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((np-> n_fhsize))) & 0xff000000) >> 24) | (((__uint32_t)(( uint32_t)((np->n_fhsize))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((np->n_fhsize))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(( np->n_fhsize))))); ((&nmreq))->nmc_ptr += 4; ((& nmreq))->nmc_left -= 4; } while (0); do { uint32_t rndlen = ((((np->n_fhsize))+3)&(~0x3)); if ((error)) break; if (((&nmreq))->nmc_left < rndlen) { ((error)) = nfsm_chain_add_opaque_f (((&nmreq)), (const u_char*)((np->n_fhp)), ((np->n_fhsize ))); break; } *(((uint32_t*)(((&nmreq))->nmc_ptr))+((( ((((np->n_fhsize)))+3)&(~0x3))>>2)-1)) = 0; bcopy (((np->n_fhp)), ((&nmreq))->nmc_ptr, ((np->n_fhsize ))); ((&nmreq))->nmc_ptr += rndlen; ((&nmreq))-> nmc_left -= rndlen; } while (0); } while (0); | |||
| 4804 | numops--; | |||
| 4805 | nfsm_chain_add_32(error, &nmreq, NFS_OP_GETATTR)do { do { if ((error)) break; if (((&nmreq))->nmc_left < (4)) { ((error)) = nfsm_chain_new_mbuf(((&nmreq)), ( 4)); if (!((error)) && (((&nmreq))->nmc_left < (4))) ((error)) = 12; } } while (0); if (error) break; *((uint32_t *)(&nmreq)->nmc_ptr) = ((__builtin_constant_p((uint32_t )(9)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(9)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(9)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(9)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(9)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(9)))); (&nmreq )->nmc_ptr += 4; (&nmreq)->nmc_left -= 4; } while ( 0); | |||
| 4806 | NFS_CLEAR_ATTRIBUTES(bitmap)do { int __i; for (__i=0; __i < (2); __i++) ((uint32_t*)(( bitmap)))[__i] = 0; } while (0); | |||
| 4807 | NFS_BITMAP_SET(bitmap, NFS_FATTR_QUOTA_AVAIL_HARD)(((uint32_t *)(bitmap))[(38)/32] |= 1<<((38)%32)); | |||
| 4808 | NFS_BITMAP_SET(bitmap, NFS_FATTR_QUOTA_AVAIL_SOFT)(((uint32_t *)(bitmap))[(39)/32] |= 1<<((39)%32)); | |||
| 4809 | NFS_BITMAP_SET(bitmap, NFS_FATTR_QUOTA_USED)(((uint32_t *)(bitmap))[(40)/32] |= 1<<((40)%32)); | |||
| 4810 | nfsm_chain_add_bitmap_supported(error, &nmreq, bitmap, nmp, NULL)do { uint32_t __bitmap[2], *__bmp = (bitmap); int __nonamedattr = 0, __noacl = 0, __nomode = 0; if (!((nmp)->nm_fsattr.nfsa_flags & 0x00000400) || ((((void *)0)) && (((nfsnode_t) (((void *)0)))->n_flag & (0x04000|0x08000)))) __nonamedattr = 1; if (!((nmp)->nm_fsattr.nfsa_flags & 0x00000008)) __noacl = 1; if ((((uint32_t *)(((nmp))->nm_flags))[(13)/ 32] & (1<<((13)%32)))) __nomode = 1; if (__nonamedattr || __noacl || __nomode) { int __ii; do { int __i; for (__i=0 ; __i < (2); __i++) ((uint32_t*)((__bitmap)))[__i] = 0; } while (0); for (__ii=0; __ii < 2; __ii++) __bitmap[__ii] = (bitmap )[__ii]; if (__nonamedattr) (((uint32_t *)(__bitmap))[(7)/32] &= ~(1<<((7)%32))); if (__noacl) (((uint32_t *)(__bitmap ))[(12)/32] &= ~(1<<((12)%32))); if (__nomode) (((uint32_t *)(__bitmap))[(33)/32] &= ~(1<<((33)%32))); __bmp = __bitmap; } do { int __i; do { do { if ((((error)))) break; if (((((&nmreq))))->nmc_left < (4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq)))), (4)); if (!((((error )))) && (((((&nmreq))))->nmc_left < (4))) ( (((error)))) = 12; } } while (0); if (((error))) break; *((uint32_t *)(((&nmreq)))->nmc_ptr) = ((__builtin_constant_p((uint32_t )((2))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((2))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((2))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((2))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((2))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((2))))) ; (((&nmreq)))->nmc_ptr += 4; (((&nmreq)))->nmc_left -= 4; } while (0); for (__i=0; __i < (2); __i++) do { do { if ((((error)))) break; if (((((&nmreq))))->nmc_left < (4)) { ((((error)))) = nfsm_chain_new_mbuf(((((&nmreq))) ), (4)); if (!((((error)))) && (((((&nmreq))))-> nmc_left < (4))) ((((error)))) = 12; } } while (0); if ((( error))) break; *((uint32_t*)(((&nmreq)))->nmc_ptr) = ( (__builtin_constant_p((uint32_t)(((__bmp)[__i] & ((nmp)-> nm_fsattr.nfsa_supp_attr)[__i]))) ? ((__uint32_t)((((__uint32_t )((uint32_t)(((__bmp)[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr )[__i]))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(((__bmp)[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i ]))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(((__bmp)[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i ]))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(((__bmp)[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i ]))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(((__bmp)[__i] & ((nmp)->nm_fsattr.nfsa_supp_attr)[__i ]))))); (((&nmreq)))->nmc_ptr += 4; (((&nmreq)))-> nmc_left -= 4; } while (0); } while (0); } while (0); | |||
| 4811 | nfsm_chain_build_done(error, &nmreq)do { if ((error) || !(&nmreq)->nmc_mcur) break; mbuf_setlen ((&nmreq)->nmc_mcur, (&nmreq)->nmc_ptr - (caddr_t )mbuf_data((&nmreq)->nmc_mcur)); } while (0); | |||
| 4812 | nfsm_assert(error, (numops == 0), EPROTO)do { if (error) break; if (!((numops == 0))) (error) = (100); } while (0); | |||
| 4813 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4814 | error = nfs_request2(np, NULL((void *)0), &nmreq, NFSPROC4_COMPOUND1, thd, cred, &si, 0, &nmrep, &xid, &status); | |||
| 4815 | nfsm_chain_skip_tag(error, &nmrep)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (((&nmrep))->nmc_left >= (uint32_t)((((__val)+3)&(~0x3)))) { ((&nmrep)) ->nmc_left -= ((((__val)+3)&(~0x3))); ((&nmrep))-> nmc_ptr += ((((__val)+3)&(~0x3))); } else { ((error)) = nfsm_chain_advance (((&nmrep)), ((((__val)+3)&(~0x3)))); } } while (0); } while (0); | |||
| 4816 | nfsm_chain_get_32(error, &nmrep, numops)do { uint32_t __tmp32, *__tmpptr; if (error) break; if ((& nmrep)->nmc_left >= 4) { __tmpptr = (uint32_t*)(&nmrep )->nmc_ptr; (&nmrep)->nmc_left -= 4; (&nmrep)-> nmc_ptr += 4; } else { __tmpptr = &__tmp32; (error) = nfsm_chain_get_opaque_f ((&nmrep), 4, (u_char*)__tmpptr); if (error) break; } (numops ) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); | |||
| 4817 | nfsm_chain_op_check(error, &nmrep, NFS_OP_PUTFH)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (22)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 4818 | nfsm_chain_op_check(error, &nmrep, NFS_OP_GETATTR)do { uint32_t __val = 0; do { uint32_t __tmp32, *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))-> nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f(((&nmrep )), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = (( uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(*__tmpptr)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break; if (!(((__val == (9)) || (__val == 10044)))) ((error)) = (72); } while (0); do { uint32_t __tmp32 , *__tmpptr; if ((error)) break; if (((&nmrep))->nmc_left >= 4) { __tmpptr = (uint32_t*)((&nmrep))->nmc_ptr; ((&nmrep))->nmc_left -= 4; ((&nmrep))->nmc_ptr += 4; } else { __tmpptr = &__tmp32; ((error)) = nfsm_chain_get_opaque_f (((&nmrep)), 4, (u_char*)__tmpptr); if ((error)) break; } (__val) = ((uint32_t)(__builtin_constant_p((uint32_t)(*__tmpptr )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(*__tmpptr)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(*__tmpptr )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( *__tmpptr)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(*__tmpptr)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(*__tmpptr)))); } while (0); do { if ((error)) break ; if (!((__val == 0))) ((error)) = (__val); } while (0); } while (0); | |||
| 4819 | nfsm_assert(error, NFSTONMP(np), ENXIO)do { if (error) break; if (!(((vnode_mount(((np)->n_vnode) )) ? ((struct nfsmount *)vfs_fsprivate(vnode_mount(((np)-> n_vnode)))) : ((void *)0)))) (error) = (6); } while (0); | |||
| 4820 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4821 | error = nfs4_parsefattr(&nmrep, NULL((void *)0), NULL((void *)0), NULL((void *)0), dqb, NULL((void *)0)); | |||
| 4822 | nfsmout_if(error)do { if (error) goto nfsmout; } while (0); | |||
| 4823 | nfsm_assert(error, NFSTONMP(np), ENXIO)do { if (error) break; if (!(((vnode_mount(((np)->n_vnode) )) ? ((struct nfsmount *)vfs_fsprivate(vnode_mount(((np)-> n_vnode)))) : ((void *)0)))) (error) = (6); } while (0); | |||
| 4824 | nfsmout: | |||
| 4825 | nfsm_chain_cleanup(&nmreq)do { if (!(&nmreq)->nmc_mhead) break; mbuf_freem((& nmreq)->nmc_mhead); do { (&nmreq)->nmc_mhead = (& nmreq)->nmc_mcur = ((void *)0); (&nmreq)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4826 | nfsm_chain_cleanup(&nmrep)do { if (!(&nmrep)->nmc_mhead) break; mbuf_freem((& nmrep)->nmc_mhead); do { (&nmrep)->nmc_mhead = (& nmrep)->nmc_mcur = ((void *)0); (&nmrep)->nmc_ptr = ((void *)0); } while (0); } while (0); | |||
| 4827 | vnode_put(NFSTOV(np)((np)->n_vnode)); | |||
| 4828 | kauth_cred_unref(&cred); | |||
| 4829 | return (error); | |||
| 4830 | } | |||
| 4831 | ||||
| 4832 | int | |||
| 4833 | nfs_vfs_quotactl(mount_t mp, int cmds, uid_t uid, caddr_t datap, vfs_context_t ctx) | |||
| 4834 | { | |||
| 4835 | struct nfsmount *nmp; | |||
| 4836 | int cmd, type, error, nfsvers; | |||
| 4837 | uid_t euid = kauth_cred_getuid(vfs_context_ucred(ctx)); | |||
| 4838 | struct dqblk *dqb = (struct dqblk*)datap; | |||
| 4839 | ||||
| 4840 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 4841 | if (nfs_mount_gone(nmp)) | |||
| 4842 | return (ENXIO6); | |||
| 4843 | nfsvers = nmp->nm_vers; | |||
| 4844 | ||||
| 4845 | if (uid == ~0U) | |||
| 4846 | uid = euid; | |||
| 4847 | ||||
| 4848 | /* we can only support Q_GETQUOTA */ | |||
| 4849 | cmd = cmds >> SUBCMDSHIFT8; | |||
| 4850 | switch (cmd) { | |||
| 4851 | case Q_GETQUOTA0x0300: | |||
| 4852 | break; | |||
| 4853 | case Q_QUOTAON0x0100: | |||
| 4854 | case Q_QUOTAOFF0x0200: | |||
| 4855 | case Q_SETQUOTA0x0400: | |||
| 4856 | case Q_SETUSE0x0500: | |||
| 4857 | case Q_SYNC0x0600: | |||
| 4858 | case Q_QUOTASTAT0x0700: | |||
| 4859 | return (ENOTSUP45); | |||
| 4860 | default: | |||
| 4861 | return (EINVAL22); | |||
| 4862 | } | |||
| 4863 | ||||
| 4864 | type = cmds & SUBCMDMASK0x00ff; | |||
| 4865 | if ((u_int)type >= MAXQUOTAS2) | |||
| 4866 | return (EINVAL22); | |||
| 4867 | if ((uid != euid) && ((error = vfs_context_suser(ctx)))) | |||
| 4868 | return (error); | |||
| 4869 | ||||
| 4870 | if (vfs_busy(mp, LK_NOWAIT1)) | |||
| 4871 | return (0); | |||
| 4872 | bzero(dqb, sizeof(*dqb)); | |||
| 4873 | error = nmp->nm_funcs->nf_getquota(nmp, ctx, uid, type, dqb); | |||
| 4874 | vfs_unbusy(mp); | |||
| 4875 | return (error); | |||
| 4876 | } | |||
| 4877 | #endif | |||
| 4878 | ||||
| 4879 | /* | |||
| 4880 | * Flush out the buffer cache | |||
| 4881 | */ | |||
| 4882 | int nfs_sync_callout(vnode_t, void *); | |||
| 4883 | ||||
| 4884 | struct nfs_sync_cargs { | |||
| 4885 | vfs_context_t ctx; | |||
| 4886 | int waitfor; | |||
| 4887 | int error; | |||
| 4888 | }; | |||
| 4889 | ||||
| 4890 | int | |||
| 4891 | nfs_sync_callout(vnode_t vp, void *arg) | |||
| 4892 | { | |||
| 4893 | struct nfs_sync_cargs *cargs = (struct nfs_sync_cargs*)arg; | |||
| 4894 | nfsnode_t np = VTONFS(vp)((nfsnode_t)vnode_fsnode(vp)); | |||
| 4895 | int error; | |||
| 4896 | ||||
| 4897 | if (np->n_flag & NREVOKE0x00002) { | |||
| 4898 | vn_revoke(vp, REVOKEALL0x0001, cargs->ctx); | |||
| 4899 | return (VNODE_RETURNED0); | |||
| 4900 | } | |||
| 4901 | ||||
| 4902 | if (LIST_EMPTY(&np->n_dirtyblkhd)((&np->n_dirtyblkhd)->lh_first == ((void *)0))) | |||
| 4903 | return (VNODE_RETURNED0); | |||
| 4904 | if (np->n_wrbusyn_un5.nf_wrbusy > 0) | |||
| 4905 | return (VNODE_RETURNED0); | |||
| 4906 | if (np->n_bflag & (NBFLUSHINPROG0x0001|NBINVALINPROG0x0004)) | |||
| 4907 | return (VNODE_RETURNED0); | |||
| 4908 | ||||
| 4909 | error = nfs_flush(np, cargs->waitfor, vfs_context_thread(cargs->ctx), 0); | |||
| 4910 | if (error) | |||
| 4911 | cargs->error = error; | |||
| 4912 | ||||
| 4913 | return (VNODE_RETURNED0); | |||
| 4914 | } | |||
| 4915 | ||||
| 4916 | int | |||
| 4917 | nfs_vfs_sync(mount_t mp, int waitfor, vfs_context_t ctx) | |||
| 4918 | { | |||
| 4919 | struct nfs_sync_cargs cargs; | |||
| 4920 | ||||
| 4921 | cargs.waitfor = waitfor; | |||
| 4922 | cargs.ctx = ctx; | |||
| 4923 | cargs.error = 0; | |||
| 4924 | ||||
| 4925 | vnode_iterate(mp, 0, nfs_sync_callout, &cargs); | |||
| 4926 | ||||
| 4927 | return (cargs.error); | |||
| 4928 | } | |||
| 4929 | ||||
| 4930 | /* | |||
| 4931 | * NFS flat namespace lookup. | |||
| 4932 | * Currently unsupported. | |||
| 4933 | */ | |||
| 4934 | /*ARGSUSED*/ | |||
| 4935 | int | |||
| 4936 | nfs_vfs_vget( | |||
| 4937 | __unused__attribute__((unused)) mount_t mp, | |||
| 4938 | __unused__attribute__((unused)) ino64_t ino, | |||
| 4939 | __unused__attribute__((unused)) vnode_t *vpp, | |||
| 4940 | __unused__attribute__((unused)) vfs_context_t ctx) | |||
| 4941 | { | |||
| 4942 | ||||
| 4943 | return (ENOTSUP45); | |||
| 4944 | } | |||
| 4945 | ||||
| 4946 | /* | |||
| 4947 | * At this point, this should never happen | |||
| 4948 | */ | |||
| 4949 | /*ARGSUSED*/ | |||
| 4950 | int | |||
| 4951 | nfs_vfs_fhtovp( | |||
| 4952 | __unused__attribute__((unused)) mount_t mp, | |||
| 4953 | __unused__attribute__((unused)) int fhlen, | |||
| 4954 | __unused__attribute__((unused)) unsigned char *fhp, | |||
| 4955 | __unused__attribute__((unused)) vnode_t *vpp, | |||
| 4956 | __unused__attribute__((unused)) vfs_context_t ctx) | |||
| 4957 | { | |||
| 4958 | ||||
| 4959 | return (ENOTSUP45); | |||
| 4960 | } | |||
| 4961 | ||||
| 4962 | /* | |||
| 4963 | * Vnode pointer to File handle, should never happen either | |||
| 4964 | */ | |||
| 4965 | /*ARGSUSED*/ | |||
| 4966 | int | |||
| 4967 | nfs_vfs_vptofh( | |||
| 4968 | __unused__attribute__((unused)) vnode_t vp, | |||
| 4969 | __unused__attribute__((unused)) int *fhlenp, | |||
| 4970 | __unused__attribute__((unused)) unsigned char *fhp, | |||
| 4971 | __unused__attribute__((unused)) vfs_context_t ctx) | |||
| 4972 | { | |||
| 4973 | ||||
| 4974 | return (ENOTSUP45); | |||
| 4975 | } | |||
| 4976 | ||||
| 4977 | /* | |||
| 4978 | * Vfs start routine, a no-op. | |||
| 4979 | */ | |||
| 4980 | /*ARGSUSED*/ | |||
| 4981 | int | |||
| 4982 | nfs_vfs_start( | |||
| 4983 | __unused__attribute__((unused)) mount_t mp, | |||
| 4984 | __unused__attribute__((unused)) int flags, | |||
| 4985 | __unused__attribute__((unused)) vfs_context_t ctx) | |||
| 4986 | { | |||
| 4987 | ||||
| 4988 | return (0); | |||
| 4989 | } | |||
| 4990 | ||||
| 4991 | /* | |||
| 4992 | * Build the mount info buffer for NFS_MOUNTINFO. | |||
| 4993 | */ | |||
| 4994 | int | |||
| 4995 | nfs_mountinfo_assemble(struct nfsmount *nmp, struct xdrbuf *xb) | |||
| 4996 | { | |||
| 4997 | struct xdrbuf xbinfo, xborig; | |||
| 4998 | char sotype[6]; | |||
| 4999 | uint32_t origargsvers, origargslength; | |||
| 5000 | uint32_t infolength_offset, curargsopaquelength_offset, curargslength_offset, attrslength_offset, curargs_end_offset, end_offset; | |||
| 5001 | uint32_t miattrs[NFS_MIATTR_BITMAP_LEN1]; | |||
| 5002 | uint32_t miflags_mask[NFS_MIFLAG_BITMAP_LEN1]; | |||
| 5003 | uint32_t miflags[NFS_MIFLAG_BITMAP_LEN1]; | |||
| 5004 | uint32_t mattrs[NFS_MATTR_BITMAP_LEN1]; | |||
| 5005 | uint32_t mflags_mask[NFS_MFLAG_BITMAP_LEN1]; | |||
| 5006 | uint32_t mflags[NFS_MFLAG_BITMAP_LEN1]; | |||
| 5007 | uint32_t loc, serv, addr, comp; | |||
| 5008 | int i, timeo, error = 0; | |||
| 5009 | ||||
| 5010 | /* set up mount info attr and flag bitmaps */ | |||
| 5011 | NFS_BITMAP_ZERO(miattrs, NFS_MIATTR_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(miattrs ))[__i] = 0; } while (0); | |||
| 5012 | NFS_BITMAP_SET(miattrs, NFS_MIATTR_FLAGS)(((uint32_t *)(miattrs))[(0)/32] |= 1<<((0)%32)); | |||
| 5013 | NFS_BITMAP_SET(miattrs, NFS_MIATTR_ORIG_ARGS)(((uint32_t *)(miattrs))[(1)/32] |= 1<<((1)%32)); | |||
| 5014 | NFS_BITMAP_SET(miattrs, NFS_MIATTR_CUR_ARGS)(((uint32_t *)(miattrs))[(2)/32] |= 1<<((2)%32)); | |||
| 5015 | NFS_BITMAP_SET(miattrs, NFS_MIATTR_CUR_LOC_INDEX)(((uint32_t *)(miattrs))[(3)/32] |= 1<<((3)%32)); | |||
| 5016 | NFS_BITMAP_ZERO(miflags_mask, NFS_MIFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(miflags_mask ))[__i] = 0; } while (0); | |||
| 5017 | NFS_BITMAP_ZERO(miflags, NFS_MIFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(miflags ))[__i] = 0; } while (0); | |||
| 5018 | NFS_BITMAP_SET(miflags_mask, NFS_MIFLAG_DEAD)(((uint32_t *)(miflags_mask))[(0)/32] |= 1<<((0)%32)); | |||
| 5019 | NFS_BITMAP_SET(miflags_mask, NFS_MIFLAG_NOTRESP)(((uint32_t *)(miflags_mask))[(1)/32] |= 1<<((1)%32)); | |||
| 5020 | NFS_BITMAP_SET(miflags_mask, NFS_MIFLAG_RECOVERY)(((uint32_t *)(miflags_mask))[(2)/32] |= 1<<((2)%32)); | |||
| 5021 | if (nmp->nm_state & NFSSTA_DEAD0x04000000) | |||
| 5022 | NFS_BITMAP_SET(miflags, NFS_MIFLAG_DEAD)(((uint32_t *)(miflags))[(0)/32] |= 1<<((0)%32)); | |||
| 5023 | if ((nmp->nm_state & (NFSSTA_TIMEO0x00010000|NFSSTA_JUKEBOXTIMEO0x00001000)) || | |||
| 5024 | ((nmp->nm_state & NFSSTA_LOCKTIMEO0x00002000) && (nmp->nm_lockmode == NFS_LOCK_MODE_ENABLED0))) | |||
| 5025 | NFS_BITMAP_SET(miflags, NFS_MIFLAG_NOTRESP)(((uint32_t *)(miflags))[(1)/32] |= 1<<((1)%32)); | |||
| 5026 | if (nmp->nm_state & NFSSTA_RECOVER0x08000000) | |||
| 5027 | NFS_BITMAP_SET(miflags, NFS_MIFLAG_RECOVERY)(((uint32_t *)(miflags))[(2)/32] |= 1<<((2)%32)); | |||
| 5028 | ||||
| 5029 | /* get original mount args length */ | |||
| 5030 | xb_init_buffer(&xborig, nmp->nm_args, 2*XDRWORD4); | |||
| 5031 | xb_get_32(error, &xborig, origargsvers)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xborig), (char*)&__tmp, 4, 0); if (error) break; ( origargsvers) = ((uint32_t)(__builtin_constant_p((uint32_t)(__tmp )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(__tmp)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(__tmp)))); } while (0); /* version */ | |||
| 5032 | xb_get_32(error, &xborig, origargslength)do { uint32_t __tmp; if (error) break; (error) = xb_get_bytes ((&xborig), (char*)&__tmp, 4, 0); if (error) break; ( origargslength) = ((uint32_t)(__builtin_constant_p((uint32_t) (__tmp)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(__tmp)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(__tmp)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(__tmp )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( __tmp)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(__tmp)))); } while (0); /* args length */ | |||
| 5033 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 5034 | ||||
| 5035 | /* set up current mount attributes bitmap */ | |||
| 5036 | NFS_BITMAP_ZERO(mattrs, NFS_MATTR_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mattrs ))[__i] = 0; } while (0); | |||
| 5037 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FLAGS)(((uint32_t *)(mattrs))[(0)/32] |= 1<<((0)%32)); | |||
| 5038 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_VERSION)(((uint32_t *)(mattrs))[(1)/32] |= 1<<((1)%32)); | |||
| 5039 | if (nmp->nm_vers >= NFS_VER44) | |||
| 5040 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_MINOR_VERSION)(((uint32_t *)(mattrs))[(2)/32] |= 1<<((2)%32)); | |||
| 5041 | NFS_BITMAP_SET(mattrs, NFS_MATTR_READ_SIZE)(((uint32_t *)(mattrs))[(3)/32] |= 1<<((3)%32)); | |||
| 5042 | NFS_BITMAP_SET(mattrs, NFS_MATTR_WRITE_SIZE)(((uint32_t *)(mattrs))[(4)/32] |= 1<<((4)%32)); | |||
| 5043 | NFS_BITMAP_SET(mattrs, NFS_MATTR_READDIR_SIZE)(((uint32_t *)(mattrs))[(5)/32] |= 1<<((5)%32)); | |||
| 5044 | NFS_BITMAP_SET(mattrs, NFS_MATTR_READAHEAD)(((uint32_t *)(mattrs))[(6)/32] |= 1<<((6)%32)); | |||
| 5045 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_REG_MIN)(((uint32_t *)(mattrs))[(7)/32] |= 1<<((7)%32)); | |||
| 5046 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_REG_MAX)(((uint32_t *)(mattrs))[(8)/32] |= 1<<((8)%32)); | |||
| 5047 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MIN)(((uint32_t *)(mattrs))[(9)/32] |= 1<<((9)%32)); | |||
| 5048 | NFS_BITMAP_SET(mattrs, NFS_MATTR_ATTRCACHE_DIR_MAX)(((uint32_t *)(mattrs))[(10)/32] |= 1<<((10)%32)); | |||
| 5049 | NFS_BITMAP_SET(mattrs, NFS_MATTR_LOCK_MODE)(((uint32_t *)(mattrs))[(11)/32] |= 1<<((11)%32)); | |||
| 5050 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SECURITY)(((uint32_t *)(mattrs))[(12)/32] |= 1<<((12)%32)); | |||
| 5051 | if (nmp->nm_etype.selected < nmp->nm_etype.count) | |||
| 5052 | NFS_BITMAP_SET(mattrs, NFS_MATTR_KERB_ETYPE)(((uint32_t *)(mattrs))[(28)/32] |= 1<<((28)%32)); | |||
| 5053 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MAX_GROUP_LIST)(((uint32_t *)(mattrs))[(13)/32] |= 1<<((13)%32)); | |||
| 5054 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SOCKET_TYPE)(((uint32_t *)(mattrs))[(14)/32] |= 1<<((14)%32)); | |||
| 5055 | NFS_BITMAP_SET(mattrs, NFS_MATTR_NFS_PORT)(((uint32_t *)(mattrs))[(15)/32] |= 1<<((15)%32)); | |||
| 5056 | if ((nmp->nm_vers < NFS_VER44) && nmp->nm_mountport) | |||
| 5057 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MOUNT_PORT)(((uint32_t *)(mattrs))[(16)/32] |= 1<<((16)%32)); | |||
| 5058 | NFS_BITMAP_SET(mattrs, NFS_MATTR_REQUEST_TIMEOUT)(((uint32_t *)(mattrs))[(17)/32] |= 1<<((17)%32)); | |||
| 5059 | if (NMFLAG(nmp, SOFT)(((uint32_t *)((nmp)->nm_flags))[(0)/32] & (1<<( (0)%32)))) | |||
| 5060 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SOFT_RETRY_COUNT)(((uint32_t *)(mattrs))[(18)/32] |= 1<<((18)%32)); | |||
| 5061 | if (nmp->nm_deadtimeout) | |||
| 5062 | NFS_BITMAP_SET(mattrs, NFS_MATTR_DEAD_TIMEOUT)(((uint32_t *)(mattrs))[(19)/32] |= 1<<((19)%32)); | |||
| 5063 | if (nmp->nm_fh) | |||
| 5064 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FH)(((uint32_t *)(mattrs))[(20)/32] |= 1<<((20)%32)); | |||
| 5065 | NFS_BITMAP_SET(mattrs, NFS_MATTR_FS_LOCATIONS)(((uint32_t *)(mattrs))[(21)/32] |= 1<<((21)%32)); | |||
| 5066 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MNTFLAGS)(((uint32_t *)(mattrs))[(22)/32] |= 1<<((22)%32)); | |||
| 5067 | if (origargsvers < NFS_ARGSVERSION_XDR88) | |||
| 5068 | NFS_BITMAP_SET(mattrs, NFS_MATTR_MNTFROM)(((uint32_t *)(mattrs))[(23)/32] |= 1<<((23)%32)); | |||
| 5069 | if (nmp->nm_realm) | |||
| 5070 | NFS_BITMAP_SET(mattrs, NFS_MATTR_REALM)(((uint32_t *)(mattrs))[(24)/32] |= 1<<((24)%32)); | |||
| 5071 | if (nmp->nm_principal) | |||
| 5072 | NFS_BITMAP_SET(mattrs, NFS_MATTR_PRINCIPAL)(((uint32_t *)(mattrs))[(25)/32] |= 1<<((25)%32)); | |||
| 5073 | if (nmp->nm_sprinc) | |||
| 5074 | NFS_BITMAP_SET(mattrs, NFS_MATTR_SVCPRINCIPAL)(((uint32_t *)(mattrs))[(26)/32] |= 1<<((26)%32)); | |||
| 5075 | ||||
| 5076 | /* set up current mount flags bitmap */ | |||
| 5077 | /* first set the flags that we will be setting - either on OR off */ | |||
| 5078 | NFS_BITMAP_ZERO(mflags_mask, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags_mask ))[__i] = 0; } while (0); | |||
| 5079 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_SOFT)(((uint32_t *)(mflags_mask))[(0)/32] |= 1<<((0)%32)); | |||
| 5080 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_INTR)(((uint32_t *)(mflags_mask))[(1)/32] |= 1<<((1)%32)); | |||
| 5081 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags_mask))[(2)/32] |= 1<<((2)%32)); | |||
| 5082 | if (nmp->nm_sotype == SOCK_DGRAM2) | |||
| 5083 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NOCONNECT)(((uint32_t *)(mflags_mask))[(3)/32] |= 1<<((3)%32)); | |||
| 5084 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_DUMBTIMER)(((uint32_t *)(mflags_mask))[(4)/32] |= 1<<((4)%32)); | |||
| 5085 | if (nmp->nm_vers < NFS_VER44) | |||
| 5086 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_CALLUMNT)(((uint32_t *)(mflags_mask))[(5)/32] |= 1<<((5)%32)); | |||
| 5087 | if (nmp->nm_vers >= NFS_VER33) | |||
| 5088 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_RDIRPLUS)(((uint32_t *)(mflags_mask))[(6)/32] |= 1<<((6)%32)); | |||
| 5089 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NONEGNAMECACHE)(((uint32_t *)(mflags_mask))[(7)/32] |= 1<<((7)%32)); | |||
| 5090 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_MUTEJUKEBOX)(((uint32_t *)(mflags_mask))[(8)/32] |= 1<<((8)%32)); | |||
| 5091 | if (nmp->nm_vers >= NFS_VER44) { | |||
| 5092 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_EPHEMERAL)(((uint32_t *)(mflags_mask))[(9)/32] |= 1<<((9)%32)); | |||
| 5093 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NOCALLBACK)(((uint32_t *)(mflags_mask))[(10)/32] |= 1<<((10)%32)); | |||
| 5094 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NONAMEDATTR)(((uint32_t *)(mflags_mask))[(11)/32] |= 1<<((11)%32)); | |||
| 5095 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NOACL)(((uint32_t *)(mflags_mask))[(12)/32] |= 1<<((12)%32)); | |||
| 5096 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_ACLONLY)(((uint32_t *)(mflags_mask))[(13)/32] |= 1<<((13)%32)); | |||
| 5097 | } | |||
| 5098 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NFC)(((uint32_t *)(mflags_mask))[(14)/32] |= 1<<((14)%32)); | |||
| 5099 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_NOQUOTA)(((uint32_t *)(mflags_mask))[(15)/32] |= 1<<((15)%32)); | |||
| 5100 | if (nmp->nm_vers < NFS_VER44) | |||
| 5101 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_MNTUDP)(((uint32_t *)(mflags_mask))[(16)/32] |= 1<<((16)%32)); | |||
| 5102 | NFS_BITMAP_SET(mflags_mask, NFS_MFLAG_MNTQUICK)(((uint32_t *)(mflags_mask))[(17)/32] |= 1<<((17)%32)); | |||
| 5103 | /* now set the flags that should be set */ | |||
| 5104 | NFS_BITMAP_ZERO(mflags, NFS_MFLAG_BITMAP_LEN)do { int __i; for (__i=0; __i < (1); __i++) ((uint32_t*)(mflags ))[__i] = 0; } while (0); | |||
| 5105 | if (NMFLAG(nmp, SOFT)(((uint32_t *)((nmp)->nm_flags))[(0)/32] & (1<<( (0)%32)))) | |||
| 5106 | NFS_BITMAP_SET(mflags, NFS_MFLAG_SOFT)(((uint32_t *)(mflags))[(0)/32] |= 1<<((0)%32)); | |||
| 5107 | if (NMFLAG(nmp, INTR)(((uint32_t *)((nmp)->nm_flags))[(1)/32] & (1<<( (1)%32)))) | |||
| 5108 | NFS_BITMAP_SET(mflags, NFS_MFLAG_INTR)(((uint32_t *)(mflags))[(1)/32] |= 1<<((1)%32)); | |||
| 5109 | if (NMFLAG(nmp, RESVPORT)(((uint32_t *)((nmp)->nm_flags))[(2)/32] & (1<<( (2)%32)))) | |||
| 5110 | NFS_BITMAP_SET(mflags, NFS_MFLAG_RESVPORT)(((uint32_t *)(mflags))[(2)/32] |= 1<<((2)%32)); | |||
| 5111 | if ((nmp->nm_sotype == SOCK_DGRAM2) && NMFLAG(nmp, NOCONNECT)(((uint32_t *)((nmp)->nm_flags))[(3)/32] & (1<<( (3)%32)))) | |||
| 5112 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NOCONNECT)(((uint32_t *)(mflags))[(3)/32] |= 1<<((3)%32)); | |||
| 5113 | if (NMFLAG(nmp, DUMBTIMER)(((uint32_t *)((nmp)->nm_flags))[(4)/32] & (1<<( (4)%32)))) | |||
| 5114 | NFS_BITMAP_SET(mflags, NFS_MFLAG_DUMBTIMER)(((uint32_t *)(mflags))[(4)/32] |= 1<<((4)%32)); | |||
| 5115 | if ((nmp->nm_vers < NFS_VER44) && NMFLAG(nmp, CALLUMNT)(((uint32_t *)((nmp)->nm_flags))[(5)/32] & (1<<( (5)%32)))) | |||
| 5116 | NFS_BITMAP_SET(mflags, NFS_MFLAG_CALLUMNT)(((uint32_t *)(mflags))[(5)/32] |= 1<<((5)%32)); | |||
| 5117 | if ((nmp->nm_vers >= NFS_VER33) && NMFLAG(nmp, RDIRPLUS)(((uint32_t *)((nmp)->nm_flags))[(6)/32] & (1<<( (6)%32)))) | |||
| 5118 | NFS_BITMAP_SET(mflags, NFS_MFLAG_RDIRPLUS)(((uint32_t *)(mflags))[(6)/32] |= 1<<((6)%32)); | |||
| 5119 | if (NMFLAG(nmp, NONEGNAMECACHE)(((uint32_t *)((nmp)->nm_flags))[(7)/32] & (1<<( (7)%32)))) | |||
| 5120 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NONEGNAMECACHE)(((uint32_t *)(mflags))[(7)/32] |= 1<<((7)%32)); | |||
| 5121 | if (NMFLAG(nmp, MUTEJUKEBOX)(((uint32_t *)((nmp)->nm_flags))[(8)/32] & (1<<( (8)%32)))) | |||
| 5122 | NFS_BITMAP_SET(mflags, NFS_MFLAG_MUTEJUKEBOX)(((uint32_t *)(mflags))[(8)/32] |= 1<<((8)%32)); | |||
| 5123 | if (nmp->nm_vers >= NFS_VER44) { | |||
| 5124 | if (NMFLAG(nmp, EPHEMERAL)(((uint32_t *)((nmp)->nm_flags))[(9)/32] & (1<<( (9)%32)))) | |||
| 5125 | NFS_BITMAP_SET(mflags, NFS_MFLAG_EPHEMERAL)(((uint32_t *)(mflags))[(9)/32] |= 1<<((9)%32)); | |||
| 5126 | if (NMFLAG(nmp, NOCALLBACK)(((uint32_t *)((nmp)->nm_flags))[(10)/32] & (1<< ((10)%32)))) | |||
| 5127 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NOCALLBACK)(((uint32_t *)(mflags))[(10)/32] |= 1<<((10)%32)); | |||
| 5128 | if (NMFLAG(nmp, NONAMEDATTR)(((uint32_t *)((nmp)->nm_flags))[(11)/32] & (1<< ((11)%32)))) | |||
| 5129 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NONAMEDATTR)(((uint32_t *)(mflags))[(11)/32] |= 1<<((11)%32)); | |||
| 5130 | if (NMFLAG(nmp, NOACL)(((uint32_t *)((nmp)->nm_flags))[(12)/32] & (1<< ((12)%32)))) | |||
| 5131 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NOACL)(((uint32_t *)(mflags))[(12)/32] |= 1<<((12)%32)); | |||
| 5132 | if (NMFLAG(nmp, ACLONLY)(((uint32_t *)((nmp)->nm_flags))[(13)/32] & (1<< ((13)%32)))) | |||
| 5133 | NFS_BITMAP_SET(mflags, NFS_MFLAG_ACLONLY)(((uint32_t *)(mflags))[(13)/32] |= 1<<((13)%32)); | |||
| 5134 | } | |||
| 5135 | if (NMFLAG(nmp, NFC)(((uint32_t *)((nmp)->nm_flags))[(14)/32] & (1<< ((14)%32)))) | |||
| 5136 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NFC)(((uint32_t *)(mflags))[(14)/32] |= 1<<((14)%32)); | |||
| 5137 | if (NMFLAG(nmp, NOQUOTA)(((uint32_t *)((nmp)->nm_flags))[(15)/32] & (1<< ((15)%32))) || ((nmp->nm_vers >= NFS_VER44) && | |||
| 5138 | !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_HARD)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(38)/32] & (1<<((38)%32))) && | |||
| 5139 | !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_SOFT)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(39)/32] & (1<<((39)%32))) && | |||
| 5140 | !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_USED)(((uint32_t *)(nmp->nm_fsattr.nfsa_supp_attr))[(40)/32] & (1<<((40)%32))))) | |||
| 5141 | NFS_BITMAP_SET(mflags, NFS_MFLAG_NOQUOTA)(((uint32_t *)(mflags))[(15)/32] |= 1<<((15)%32)); | |||
| 5142 | if ((nmp->nm_vers < NFS_VER44) && NMFLAG(nmp, MNTUDP)(((uint32_t *)((nmp)->nm_flags))[(16)/32] & (1<< ((16)%32)))) | |||
| 5143 | NFS_BITMAP_SET(mflags, NFS_MFLAG_MNTUDP)(((uint32_t *)(mflags))[(16)/32] |= 1<<((16)%32)); | |||
| 5144 | if (NMFLAG(nmp, MNTQUICK)(((uint32_t *)((nmp)->nm_flags))[(17)/32] & (1<< ((17)%32)))) | |||
| 5145 | NFS_BITMAP_SET(mflags, NFS_MFLAG_MNTQUICK)(((uint32_t *)(mflags))[(17)/32] |= 1<<((17)%32)); | |||
| 5146 | ||||
| 5147 | /* assemble info buffer: */ | |||
| 5148 | xb_init_buffer(&xbinfo, NULL((void *)0), 0); | |||
| 5149 | xb_add_32(error, &xbinfo, NFS_MOUNT_INFO_VERSION)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5150 | infolength_offset = xb_offset(&xbinfo); | |||
| 5151 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5152 | xb_add_bitmap(error, &xbinfo, miattrs, NFS_MIATTR_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbinfo))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((miattrs))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((miattrs))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((miattrs))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((miattrs))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((miattrs))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((miattrs ))[__i])))); (((error))) = xb_add_bytes((((&xbinfo))), (void *)&__tmp, 4, 0); } while (0); } while (0); | |||
| 5153 | xb_add_bitmap(error, &xbinfo, miflags, NFS_MIFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbinfo))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((miflags))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((miflags))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((miflags))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((miflags))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((miflags))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((miflags ))[__i])))); (((error))) = xb_add_bytes((((&xbinfo))), (void *)&__tmp, 4, 0); } while (0); } while (0); | |||
| 5154 | xb_add_32(error, &xbinfo, origargslength)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(origargslength)) ? ((__uint32_t)((((__uint32_t)(( uint32_t)(origargslength)) & 0xff000000) >> 24) | ( ((__uint32_t)((uint32_t)(origargslength)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(origargslength)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(origargslength)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(origargslength )))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5155 | if (!error) | |||
| 5156 | error = xb_add_bytes(&xbinfo, nmp->nm_args, origargslength, 0); | |||
| 5157 | ||||
| 5158 | /* the opaque byte count for the current mount args values: */ | |||
| 5159 | curargsopaquelength_offset = xb_offset(&xbinfo); | |||
| 5160 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5161 | ||||
| 5162 | /* Encode current mount args values */ | |||
| 5163 | xb_add_32(error, &xbinfo, NFS_ARGSVERSION_XDR)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(88)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(88 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (88)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(88)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(88)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(88)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5164 | curargslength_offset = xb_offset(&xbinfo); | |||
| 5165 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5166 | xb_add_32(error, &xbinfo, NFS_XDRARGS_VERSION_0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5167 | xb_add_bitmap(error, &xbinfo, mattrs, NFS_MATTR_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbinfo))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((mattrs))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t) (((mattrs))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((mattrs))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((mattrs))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((mattrs ))[__i])))); (((error))) = xb_add_bytes((((&xbinfo))), (void *)&__tmp, 4, 0); } while (0); } while (0); | |||
| 5168 | attrslength_offset = xb_offset(&xbinfo); | |||
| 5169 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5170 | xb_add_bitmap(error, &xbinfo, mflags_mask, NFS_MFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbinfo))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((mflags_mask))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t )(((mflags_mask))[__i])) & 0xff000000) >> 24) | ((( __uint32_t)((uint32_t)(((mflags_mask))[__i])) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(((mflags_mask))[__i ])) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (((mflags_mask))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((mflags_mask))[__i])))); (((error))) = xb_add_bytes ((((&xbinfo))), (void*)&__tmp, 4, 0); } while (0); } while (0); | |||
| 5171 | xb_add_bitmap(error, &xbinfo, mflags, NFS_MFLAG_BITMAP_LEN)do { uint32_t __i; do { uint32_t __tmp; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t)(((1)))) ? ((__uint32_t )((((__uint32_t)((uint32_t)(((1)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(((1)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((1)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((1)))))); (((error))) = xb_add_bytes ((((&xbinfo))), (void*)&__tmp, 4, 0); } while (0); for (__i=0; __i < (uint32_t)((1)); __i++) do { uint32_t __tmp ; if (((error))) break; __tmp = ((__builtin_constant_p((uint32_t )(((mflags))[__i])) ? ((__uint32_t)((((__uint32_t)((uint32_t) (((mflags))[__i])) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(((mflags))[__i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((mflags))[__i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(((mflags))[__i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(((mflags ))[__i])))); (((error))) = xb_add_bytes((((&xbinfo))), (void *)&__tmp, 4, 0); } while (0); } while (0); | |||
| 5172 | xb_add_32(error, &xbinfo, nmp->nm_vers)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_vers)) ? ((__uint32_t)((((__uint32_t)( (uint32_t)(nmp->nm_vers)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_vers)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_vers)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp-> nm_vers)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(nmp->nm_vers)))); (error) = xb_add_bytes((&xbinfo), ( void*)&__tmp, 4, 0); } while (0); /* NFS_VERSION */ | |||
| 5173 | if (nmp->nm_vers >= NFS_VER44) | |||
| 5174 | xb_add_32(error, &xbinfo, nmp->nm_minor_vers)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_minor_vers)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_minor_vers)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_minor_vers)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_minor_vers)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_minor_vers)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_minor_vers)))); ( error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0) ; } while (0); /* NFS_MINOR_VERSION */ | |||
| 5175 | xb_add_32(error, &xbinfo, nmp->nm_rsize)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_rsize)) ? ((__uint32_t)((((__uint32_t) ((uint32_t)(nmp->nm_rsize)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_rsize)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_rsize)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp-> nm_rsize)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(nmp->nm_rsize)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* READ_SIZE */ | |||
| 5176 | xb_add_32(error, &xbinfo, nmp->nm_wsize)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_wsize)) ? ((__uint32_t)((((__uint32_t) ((uint32_t)(nmp->nm_wsize)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_wsize)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_wsize)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp-> nm_wsize)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(nmp->nm_wsize)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* WRITE_SIZE */ | |||
| 5177 | xb_add_32(error, &xbinfo, nmp->nm_readdirsize)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_readdirsize)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_readdirsize)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_readdirsize)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_readdirsize)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_readdirsize)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_readdirsize)))); ( error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0) ; } while (0); /* READDIR_SIZE */ | |||
| 5178 | xb_add_32(error, &xbinfo, nmp->nm_readahead)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_readahead)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_readahead)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_readahead)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_readahead)) & 0x0000ff00) << 8) | (((__uint32_t) ((uint32_t)(nmp->nm_readahead)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_readahead)))); (error ) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* READAHEAD */ | |||
| 5179 | xb_add_32(error, &xbinfo, nmp->nm_acregmin)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_acregmin)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_acregmin)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_acregmin)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_acregmin )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_acregmin)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_acregmin)))); (error) = xb_add_bytes(( &xbinfo), (void*)&__tmp, 4, 0); } while (0); /* ATTRCACHE_REG_MIN */ | |||
| 5180 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* ATTRCACHE_REG_MIN */ | |||
| 5181 | xb_add_32(error, &xbinfo, nmp->nm_acregmax)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_acregmax)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_acregmax)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_acregmax)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_acregmax )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_acregmax)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_acregmax)))); (error) = xb_add_bytes(( &xbinfo), (void*)&__tmp, 4, 0); } while (0); /* ATTRCACHE_REG_MAX */ | |||
| 5182 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* ATTRCACHE_REG_MAX */ | |||
| 5183 | xb_add_32(error, &xbinfo, nmp->nm_acdirmin)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_acdirmin)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_acdirmin)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_acdirmin)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_acdirmin )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_acdirmin)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_acdirmin)))); (error) = xb_add_bytes(( &xbinfo), (void*)&__tmp, 4, 0); } while (0); /* ATTRCACHE_DIR_MIN */ | |||
| 5184 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* ATTRCACHE_DIR_MIN */ | |||
| 5185 | xb_add_32(error, &xbinfo, nmp->nm_acdirmax)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_acdirmax)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_acdirmax)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_acdirmax)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_acdirmax )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_acdirmax)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_acdirmax)))); (error) = xb_add_bytes(( &xbinfo), (void*)&__tmp, 4, 0); } while (0); /* ATTRCACHE_DIR_MAX */ | |||
| 5186 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* ATTRCACHE_DIR_MAX */ | |||
| 5187 | xb_add_32(error, &xbinfo, nmp->nm_lockmode)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_lockmode)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_lockmode)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_lockmode)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_lockmode )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_lockmode)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_lockmode)))); (error) = xb_add_bytes(( &xbinfo), (void*)&__tmp, 4, 0); } while (0); /* LOCK_MODE */ | |||
| 5188 | if (nmp->nm_sec.count) { | |||
| 5189 | xb_add_32(error, &xbinfo, nmp->nm_sec.count)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_sec.count)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_sec.count)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_sec.count)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_sec.count)) & 0x0000ff00) << 8) | (((__uint32_t) ((uint32_t)(nmp->nm_sec.count)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_sec.count)))); (error ) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* SECURITY */ | |||
| 5190 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 5191 | for (i=0; i < nmp->nm_sec.count; i++) | |||
| 5192 | xb_add_32(error, &xbinfo, nmp->nm_sec.flavors[i])do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_sec.flavors[i])) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_sec.flavors[i])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_sec.flavors[i])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_sec.flavors[i])) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_sec.flavors[i])) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_sec.flavors[i]))) ); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4 , 0); } while (0); | |||
| 5193 | } else if (nmp->nm_servsec.count) { | |||
| 5194 | xb_add_32(error, &xbinfo, nmp->nm_servsec.count)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_servsec.count)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_servsec.count)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_servsec.count)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_servsec.count)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_servsec.count)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_servsec.count)))) ; (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* SECURITY */ | |||
| 5195 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 5196 | for (i=0; i < nmp->nm_servsec.count; i++) | |||
| 5197 | xb_add_32(error, &xbinfo, nmp->nm_servsec.flavors[i])do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_servsec.flavors[i])) ? ((__uint32_t)(( ((__uint32_t)((uint32_t)(nmp->nm_servsec.flavors[i])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp-> nm_servsec.flavors[i])) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(nmp->nm_servsec.flavors[i])) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(nmp->nm_servsec. flavors[i])) & 0x000000ff) << 24))) : _OSSwapInt32( (uint32_t)(nmp->nm_servsec.flavors[i])))); (error) = xb_add_bytes ((&xbinfo), (void*)&__tmp, 4, 0); } while (0); | |||
| 5198 | } else { | |||
| 5199 | xb_add_32(error, &xbinfo, 1)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(1)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(1)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(1 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 1)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (1)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(1)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* SECURITY */ | |||
| 5200 | xb_add_32(error, &xbinfo, nmp->nm_auth)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_auth)) ? ((__uint32_t)((((__uint32_t)( (uint32_t)(nmp->nm_auth)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_auth)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_auth)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp-> nm_auth)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(nmp->nm_auth)))); (error) = xb_add_bytes((&xbinfo), ( void*)&__tmp, 4, 0); } while (0); | |||
| 5201 | } | |||
| 5202 | if (nmp->nm_etype.selected < nmp->nm_etype.count) { | |||
| 5203 | xb_add_32(error, &xbinfo, nmp->nm_etype.count)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_etype.count)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_etype.count)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_etype.count)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_etype.count)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_etype.count)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_etype.count)))); ( error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0) ; } while (0); | |||
| 5204 | xb_add_32(error, &xbinfo, nmp->nm_etype.selected)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_etype.selected)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_etype.selected)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_etype.selected)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_etype.selected)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_etype.selected)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_etype.selected))) ); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4 , 0); } while (0); | |||
| 5205 | for (uint32_t j=0; j < nmp->nm_etype.count; j++) | |||
| 5206 | xb_add_32(error, &xbinfo, nmp->nm_etype.etypes[j])do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_etype.etypes[j])) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_etype.etypes[j])) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_etype.etypes[j])) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp ->nm_etype.etypes[j])) & 0x0000ff00) << 8) | ((( __uint32_t)((uint32_t)(nmp->nm_etype.etypes[j])) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_etype.etypes [j])))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5207 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 5208 | } | |||
| 5209 | xb_add_32(error, &xbinfo, nmp->nm_numgrps)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_numgrps)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_numgrps)) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)(nmp->nm_numgrps)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_numgrps) ) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp ->nm_numgrps)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_numgrps)))); (error) = xb_add_bytes((& xbinfo), (void*)&__tmp, 4, 0); } while (0); /* MAX_GROUP_LIST */ | |||
| 5210 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 5211 | snprintf(sotype, sizeof(sotype), "%s%s", (nmp->nm_sotype == SOCK_DGRAM2) ? "udp" : "tcp", | |||
| 5212 | nmp->nm_sofamily ? (nmp->nm_sofamily == AF_INET2) ? "4" : "6" : ""); | |||
| 5213 | xb_add_string(error, &xbinfo, sotype, strlen(sotype))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(sotype)))) ? ((__uint32_t)((((__uint32_t) ((uint32_t)((strlen(sotype)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(sotype)))) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)((strlen(sotype)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( sotype)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )((strlen(sotype)))))); ((error)) = xb_add_bytes(((&xbinfo )), (void*)&__tmp, 4, 0); } while (0); if (error) break; ( error) = xb_add_bytes((&xbinfo), (const char*)(sotype), ( strlen(sotype)), 0); } while (0); /* SOCKET_TYPE */ | |||
| 5214 | xb_add_32(error, &xbinfo, ntohs(((struct sockaddr_in*)nmp->nm_saddr)->sin_port))do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(((__uint16_t)(__builtin_constant_p(((struct sockaddr_in *)nmp->nm_saddr)->sin_port) ? ((__uint16_t)((((__uint16_t )(((struct sockaddr_in*)nmp->nm_saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)nmp ->nm_saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (((struct sockaddr_in*)nmp->nm_saddr)->sin_port))))) ? ( (__uint32_t)((((__uint32_t)((uint32_t)(((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)nmp->nm_saddr)->sin_port) ? ((__uint16_t )((((__uint16_t)(((struct sockaddr_in*)nmp->nm_saddr)-> sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)nmp->nm_saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)nmp->nm_saddr)-> sin_port))))) & 0xff000000) >> 24) | (((__uint32_t) ((uint32_t)(((__uint16_t)(__builtin_constant_p(((struct sockaddr_in *)nmp->nm_saddr)->sin_port) ? ((__uint16_t)((((__uint16_t )(((struct sockaddr_in*)nmp->nm_saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)nmp ->nm_saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (((struct sockaddr_in*)nmp->nm_saddr)->sin_port))))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(((__uint16_t )(__builtin_constant_p(((struct sockaddr_in*)nmp->nm_saddr )->sin_port) ? ((__uint16_t)((((__uint16_t)(((struct sockaddr_in *)nmp->nm_saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)nmp->nm_saddr)->sin_port ) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in *)nmp->nm_saddr)->sin_port))))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(((__uint16_t)(__builtin_constant_p (((struct sockaddr_in*)nmp->nm_saddr)->sin_port) ? ((__uint16_t )((((__uint16_t)(((struct sockaddr_in*)nmp->nm_saddr)-> sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)nmp->nm_saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16(((struct sockaddr_in*)nmp->nm_saddr)-> sin_port))))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(((__uint16_t)(__builtin_constant_p(((struct sockaddr_in *)nmp->nm_saddr)->sin_port) ? ((__uint16_t)((((__uint16_t )(((struct sockaddr_in*)nmp->nm_saddr)->sin_port) & 0xff00) >> 8) | (((__uint16_t)(((struct sockaddr_in*)nmp ->nm_saddr)->sin_port) & 0x00ff) << 8))) : _OSSwapInt16 (((struct sockaddr_in*)nmp->nm_saddr)->sin_port))))))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0 ); } while (0); /* NFS_PORT */ | |||
| 5215 | if ((nmp->nm_vers < NFS_VER44) && nmp->nm_mountport) | |||
| 5216 | xb_add_32(error, &xbinfo, nmp->nm_mountport)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_mountport)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_mountport)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_mountport)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_mountport)) & 0x0000ff00) << 8) | (((__uint32_t) ((uint32_t)(nmp->nm_mountport)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_mountport)))); (error ) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* MOUNT_PORT */ | |||
| 5217 | timeo = (nmp->nm_timeo * 10) / NFS_HZ(hz / nfs_ticks); | |||
| 5218 | xb_add_32(error, &xbinfo, timeo/10)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(timeo/10)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(timeo/10)) & 0xff000000) >> 24) | (((__uint32_t)( (uint32_t)(timeo/10)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(timeo/10)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(timeo/10)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(timeo/10)))); (error) = xb_add_bytes((&xbinfo ), (void*)&__tmp, 4, 0); } while (0); /* REQUEST_TIMEOUT */ | |||
| 5219 | xb_add_32(error, &xbinfo, (timeo%10)*100000000)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)((timeo%10)*100000000)) ? ((__uint32_t)((((__uint32_t )((uint32_t)((timeo%10)*100000000)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((timeo%10)*100000000)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((timeo%10 )*100000000)) & 0x0000ff00) << 8) | (((__uint32_t)( (uint32_t)((timeo%10)*100000000)) & 0x000000ff) << 24 ))) : _OSSwapInt32((uint32_t)((timeo%10)*100000000)))); (error ) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* REQUEST_TIMEOUT */ | |||
| 5220 | if (NMFLAG(nmp, SOFT)(((uint32_t *)((nmp)->nm_flags))[(0)/32] & (1<<( (0)%32)))) | |||
| 5221 | xb_add_32(error, &xbinfo, nmp->nm_retry)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_retry)) ? ((__uint32_t)((((__uint32_t) ((uint32_t)(nmp->nm_retry)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_retry)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_retry)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp-> nm_retry)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(nmp->nm_retry)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* SOFT_RETRY_COUNT */ | |||
| 5222 | if (nmp->nm_deadtimeout) { | |||
| 5223 | xb_add_32(error, &xbinfo, nmp->nm_deadtimeout)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_deadtimeout)) ? ((__uint32_t)((((__uint32_t )((uint32_t)(nmp->nm_deadtimeout)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_deadtimeout)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp-> nm_deadtimeout)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_deadtimeout)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_deadtimeout)))); ( error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0) ; } while (0); /* DEAD_TIMEOUT */ | |||
| 5224 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* DEAD_TIMEOUT */ | |||
| 5225 | } | |||
| 5226 | if (nmp->nm_fh) | |||
| 5227 | xb_add_fh(error, &xbinfo, &nmp->nm_fh->fh_data[0], nmp->nm_fh->fh_len)do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((nmp->nm_fh->fh_len))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((nmp->nm_fh->fh_len))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((nmp->nm_fh->fh_len))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((nmp ->nm_fh->fh_len))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((nmp->nm_fh->fh_len))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((nmp->nm_fh->fh_len))) )); ((error)) = xb_add_bytes(((&xbinfo)), (void*)&__tmp , 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbinfo), (char*)(&nmp->nm_fh->fh_data[0]), ( nmp->nm_fh->fh_len), 0); } while (0); /* FH */ | |||
| 5228 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_numlocs)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_numlocs)) ? ((__uint32_t) ((((__uint32_t)((uint32_t)(nmp->nm_locations.nl_numlocs)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp-> nm_locations.nl_numlocs)) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(nmp->nm_locations.nl_numlocs)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp-> nm_locations.nl_numlocs)) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)(nmp->nm_locations.nl_numlocs)))); (error) = xb_add_bytes ((&xbinfo), (void*)&__tmp, 4, 0); } while (0); /* FS_LOCATIONS */ | |||
| 5229 | for (loc = 0; !error && (loc < nmp->nm_locations.nl_numlocs); loc++) { | |||
| 5230 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servcount)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_locations[loc]->nl_servcount )) ? ((__uint32_t)((((__uint32_t)((uint32_t)(nmp->nm_locations .nl_locations[loc]->nl_servcount)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(nmp->nm_locations.nl_locations [loc]->nl_servcount)) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)(nmp->nm_locations.nl_locations[loc]->nl_servcount )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_locations.nl_locations[loc]->nl_servcount)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp-> nm_locations.nl_locations[loc]->nl_servcount)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0); } while (0); | |||
| 5231 | for (serv = 0; !error && (serv < nmp->nm_locations.nl_locations[loc]->nl_servcount); serv++) { | |||
| 5232 | xb_add_string(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_name,do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_servers[serv]->ns_name)))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_servers[serv]->ns_name)))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_name)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations. nl_locations[loc]->nl_servers[serv]->ns_name)))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_name)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((strlen (nmp->nm_locations.nl_locations[loc]->nl_servers[serv]-> ns_name)))))); ((error)) = xb_add_bytes(((&xbinfo)), (void *)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((&xbinfo), (const char*)(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_name), (strlen (nmp->nm_locations.nl_locations[loc]->nl_servers[serv]-> ns_name)), 0); } while (0) | |||
| 5233 | strlen(nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_name))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_servers[serv]->ns_name)))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_servers[serv]->ns_name)))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_name)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations. nl_locations[loc]->nl_servers[serv]->ns_name)))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_name)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((strlen (nmp->nm_locations.nl_locations[loc]->nl_servers[serv]-> ns_name)))))); ((error)) = xb_add_bytes(((&xbinfo)), (void *)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((&xbinfo), (const char*)(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_name), (strlen (nmp->nm_locations.nl_locations[loc]->nl_servers[serv]-> ns_name)), 0); } while (0); | |||
| 5234 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addrcount)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_locations[loc]->nl_servers [serv]->ns_addrcount)) ? ((__uint32_t)((((__uint32_t)((uint32_t )(nmp->nm_locations.nl_locations[loc]->nl_servers[serv] ->ns_addrcount)) & 0xff000000) >> 24) | (((__uint32_t )((uint32_t)(nmp->nm_locations.nl_locations[loc]->nl_servers [serv]->ns_addrcount)) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)(nmp->nm_locations.nl_locations[loc] ->nl_servers[serv]->ns_addrcount)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addrcount)) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_addrcount)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp, 4, 0 ); } while (0); | |||
| 5235 | for (addr = 0; !error && (addr < nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addrcount); addr++) | |||
| 5236 | xb_add_string(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addresses[addr],do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_servers[serv]->ns_addresses[addr])))) ? ((__uint32_t)(( ((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_addresses[addr ])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((strlen(nmp->nm_locations.nl_locations[loc]->nl_servers [serv]->ns_addresses[addr])))) & 0x0000ff00) << 8 ) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_addresses[addr ])))))); ((error)) = xb_add_bytes(((&xbinfo)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbinfo), (const char*)(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr]), (strlen(nmp ->nm_locations.nl_locations[loc]->nl_servers[serv]-> ns_addresses[addr])), 0); } while (0) | |||
| 5237 | strlen(nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addresses[addr]))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_servers[serv]->ns_addresses[addr])))) ? ((__uint32_t)(( ((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_addresses[addr ])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((strlen(nmp->nm_locations.nl_locations[loc]->nl_servers [serv]->ns_addresses[addr])))) & 0x0000ff00) << 8 ) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr])))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_servers[serv]->ns_addresses[addr ])))))); ((error)) = xb_add_bytes(((&xbinfo)), (void*)& __tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbinfo), (const char*)(nmp->nm_locations.nl_locations [loc]->nl_servers[serv]->ns_addresses[addr]), (strlen(nmp ->nm_locations.nl_locations[loc]->nl_servers[serv]-> ns_addresses[addr])), 0); } while (0); | |||
| 5238 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* empty server info */ | |||
| 5239 | } | |||
| 5240 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_locations[loc]->nl_path .np_compcount)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(nmp ->nm_locations.nl_locations[loc]->nl_path.np_compcount) ) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)( nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount )) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)( nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount )) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t) (nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount )))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5241 | for (comp = 0; !error && (comp < nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount); comp++) | |||
| 5242 | xb_add_string(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_path.np_components[comp],do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_path.np_components[comp])))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_path.np_components[comp])))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_path.np_components[comp])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations. nl_locations[loc]->nl_path.np_components[comp])))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_path.np_components[comp])))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_path.np_components[comp])))))); ((error )) = xb_add_bytes(((&xbinfo)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((&xbinfo ), (const char*)(nmp->nm_locations.nl_locations[loc]->nl_path .np_components[comp]), (strlen(nmp->nm_locations.nl_locations [loc]->nl_path.np_components[comp])), 0); } while (0) | |||
| 5243 | strlen(nmp->nm_locations.nl_locations[loc]->nl_path.np_components[comp]))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_path.np_components[comp])))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((strlen(nmp->nm_locations.nl_locations[loc]-> nl_path.np_components[comp])))) & 0xff000000) >> 24 ) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations.nl_locations [loc]->nl_path.np_components[comp])))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations. nl_locations[loc]->nl_path.np_components[comp])))) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_path.np_components[comp])))) & 0x000000ff ) << 24))) : _OSSwapInt32((uint32_t)((strlen(nmp->nm_locations .nl_locations[loc]->nl_path.np_components[comp])))))); ((error )) = xb_add_bytes(((&xbinfo)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes((&xbinfo ), (const char*)(nmp->nm_locations.nl_locations[loc]->nl_path .np_components[comp]), (strlen(nmp->nm_locations.nl_locations [loc]->nl_path.np_components[comp])), 0); } while (0); | |||
| 5244 | xb_add_32(error, &xbinfo, 0)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(0)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(0)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)(0 )) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)( 0)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t) (0)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(0)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); /* empty fs location info */ | |||
| 5245 | } | |||
| 5246 | xb_add_32(error, &xbinfo, vfs_flags(nmp->nm_mountp))do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(vfs_flags(nmp->nm_mountp))) ? ((__uint32_t)((( (__uint32_t)((uint32_t)(vfs_flags(nmp->nm_mountp))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)(vfs_flags(nmp-> nm_mountp))) & 0x00ff0000) >> 8) | (((__uint32_t)(( uint32_t)(vfs_flags(nmp->nm_mountp))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)(vfs_flags(nmp->nm_mountp)) ) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)( vfs_flags(nmp->nm_mountp))))); (error) = xb_add_bytes((& xbinfo), (void*)&__tmp, 4, 0); } while (0); /* MNTFLAGS */ | |||
| 5247 | if (origargsvers < NFS_ARGSVERSION_XDR88) | |||
| 5248 | xb_add_string(error, &xbinfo, vfs_statfs(nmp->nm_mountp)->f_mntfromname,do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname )))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((strlen(vfs_statfs (nmp->nm_mountp)->f_mntfromname)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(vfs_statfs(nmp->nm_mountp )->f_mntfromname)))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname )))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(( strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname)))))); ((error)) = xb_add_bytes(((&xbinfo)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbinfo), (const char*)(vfs_statfs(nmp->nm_mountp)-> f_mntfromname), (strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname )), 0); } while (0) | |||
| 5249 | strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname )))) ? ((__uint32_t)((((__uint32_t)((uint32_t)((strlen(vfs_statfs (nmp->nm_mountp)->f_mntfromname)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(vfs_statfs(nmp->nm_mountp )->f_mntfromname)))) & 0x00ff0000) >> 8) | (((__uint32_t )((uint32_t)((strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname )))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )((strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(( strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname)))))); ((error)) = xb_add_bytes(((&xbinfo)), (void*)&__tmp, 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbinfo), (const char*)(vfs_statfs(nmp->nm_mountp)-> f_mntfromname), (strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname )), 0); } while (0); /* MNTFROM */ | |||
| 5250 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_REALM)(((uint32_t *)(mattrs))[(24)/32] & (1<<((24)%32)))) | |||
| 5251 | xb_add_string(error, &xbinfo, nmp->nm_realm, strlen(nmp->nm_realm))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_realm)))) ? ((__uint32_t)((((__uint32_t )((uint32_t)((strlen(nmp->nm_realm)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_realm)))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)((strlen (nmp->nm_realm)))) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)((strlen(nmp->nm_realm)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((strlen(nmp->nm_realm)))) )); ((error)) = xb_add_bytes(((&xbinfo)), (void*)&__tmp , 4, 0); } while (0); if (error) break; (error) = xb_add_bytes ((&xbinfo), (const char*)(nmp->nm_realm), (strlen(nmp-> nm_realm)), 0); } while (0); | |||
| 5252 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_PRINCIPAL)(((uint32_t *)(mattrs))[(25)/32] & (1<<((25)%32)))) | |||
| 5253 | xb_add_string(error, &xbinfo, nmp->nm_principal, strlen(nmp->nm_principal))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_principal)))) ? ((__uint32_t)( (((__uint32_t)((uint32_t)((strlen(nmp->nm_principal)))) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t)((strlen (nmp->nm_principal)))) & 0x00ff0000) >> 8) | ((( __uint32_t)((uint32_t)((strlen(nmp->nm_principal)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen( nmp->nm_principal)))) & 0x000000ff) << 24))) : _OSSwapInt32 ((uint32_t)((strlen(nmp->nm_principal)))))); ((error)) = xb_add_bytes (((&xbinfo)), (void*)&__tmp, 4, 0); } while (0); if ( error) break; (error) = xb_add_bytes((&xbinfo), (const char *)(nmp->nm_principal), (strlen(nmp->nm_principal)), 0); } while (0); | |||
| 5254 | if (NFS_BITMAP_ISSET(mattrs, NFS_MATTR_SVCPRINCIPAL)(((uint32_t *)(mattrs))[(26)/32] & (1<<((26)%32)))) | |||
| 5255 | xb_add_string(error, &xbinfo, nmp->nm_sprinc, strlen(nmp->nm_sprinc))do { do { uint32_t __tmp; if ((error)) break; __tmp = ((__builtin_constant_p ((uint32_t)((strlen(nmp->nm_sprinc)))) ? ((__uint32_t)(((( __uint32_t)((uint32_t)((strlen(nmp->nm_sprinc)))) & 0xff000000 ) >> 24) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_sprinc )))) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )((strlen(nmp->nm_sprinc)))) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t)((strlen(nmp->nm_sprinc)))) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)((strlen (nmp->nm_sprinc)))))); ((error)) = xb_add_bytes(((&xbinfo )), (void*)&__tmp, 4, 0); } while (0); if (error) break; ( error) = xb_add_bytes((&xbinfo), (const char*)(nmp->nm_sprinc ), (strlen(nmp->nm_sprinc)), 0); } while (0); | |||
| 5256 | ||||
| 5257 | curargs_end_offset = xb_offset(&xbinfo); | |||
| 5258 | ||||
| 5259 | /* NFS_MIATTR_CUR_LOC_INDEX */ | |||
| 5260 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_flags)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_current.nli_flags)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(nmp->nm_locations.nl_current.nli_flags )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (nmp->nm_locations.nl_current.nli_flags)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_locations .nl_current.nli_flags)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_locations.nl_current.nli_flags)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp-> nm_locations.nl_current.nli_flags)))); (error) = xb_add_bytes ((&xbinfo), (void*)&__tmp, 4, 0); } while (0); | |||
| 5261 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_loc)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_current.nli_loc)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(nmp->nm_locations.nl_current.nli_loc )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (nmp->nm_locations.nl_current.nli_loc)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_locations.nl_current .nli_loc)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(nmp->nm_locations.nl_current.nli_loc)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp->nm_locations .nl_current.nli_loc)))); (error) = xb_add_bytes((&xbinfo) , (void*)&__tmp, 4, 0); } while (0); | |||
| 5262 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_serv)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_current.nli_serv)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(nmp->nm_locations.nl_current.nli_serv )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (nmp->nm_locations.nl_current.nli_serv)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_locations .nl_current.nli_serv)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_locations.nl_current.nli_serv)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp-> nm_locations.nl_current.nli_serv)))); (error) = xb_add_bytes( (&xbinfo), (void*)&__tmp, 4, 0); } while (0); | |||
| 5263 | xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_addr)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(nmp->nm_locations.nl_current.nli_addr)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(nmp->nm_locations.nl_current.nli_addr )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (nmp->nm_locations.nl_current.nli_addr)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(nmp->nm_locations .nl_current.nli_addr)) & 0x0000ff00) << 8) | (((__uint32_t )((uint32_t)(nmp->nm_locations.nl_current.nli_addr)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(nmp-> nm_locations.nl_current.nli_addr)))); (error) = xb_add_bytes( (&xbinfo), (void*)&__tmp, 4, 0); } while (0); | |||
| 5264 | ||||
| 5265 | xb_build_done(error, &xbinfo)do { if (error) break; xb_set_cur_buf_len(&xbinfo); } while (0); | |||
| 5266 | ||||
| 5267 | /* update opaque counts */ | |||
| 5268 | end_offset = xb_offset(&xbinfo); | |||
| 5269 | if (!error) { | |||
| 5270 | error = xb_seek(&xbinfo, attrslength_offset); | |||
| 5271 | xb_add_32(error, &xbinfo, curargs_end_offset - attrslength_offset - XDRWORD/*don't include length field*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(curargs_end_offset - attrslength_offset - 4)) ? ( (__uint32_t)((((__uint32_t)((uint32_t)(curargs_end_offset - attrslength_offset - 4)) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t )(curargs_end_offset - attrslength_offset - 4)) & 0x00ff0000 ) >> 8) | (((__uint32_t)((uint32_t)(curargs_end_offset - attrslength_offset - 4)) & 0x0000ff00) << 8) | ((( __uint32_t)((uint32_t)(curargs_end_offset - attrslength_offset - 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t )(curargs_end_offset - attrslength_offset - 4)))); (error) = xb_add_bytes ((&xbinfo), (void*)&__tmp, 4, 0); } while (0); | |||
| 5272 | } | |||
| 5273 | if (!error) { | |||
| 5274 | error = xb_seek(&xbinfo, curargslength_offset); | |||
| 5275 | xb_add_32(error, &xbinfo, curargs_end_offset - curargslength_offset + XDRWORD/*version*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(curargs_end_offset - curargslength_offset + 4)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(curargs_end_offset - curargslength_offset + 4)) & 0xff000000) >> 24) | ( ((__uint32_t)((uint32_t)(curargs_end_offset - curargslength_offset + 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(curargs_end_offset - curargslength_offset + 4)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(curargs_end_offset - curargslength_offset + 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(curargs_end_offset - curargslength_offset + 4)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5276 | } | |||
| 5277 | if (!error) { | |||
| 5278 | error = xb_seek(&xbinfo, curargsopaquelength_offset); | |||
| 5279 | xb_add_32(error, &xbinfo, curargs_end_offset - curargslength_offset + XDRWORD/*version*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(curargs_end_offset - curargslength_offset + 4)) ? ((__uint32_t)((((__uint32_t)((uint32_t)(curargs_end_offset - curargslength_offset + 4)) & 0xff000000) >> 24) | ( ((__uint32_t)((uint32_t)(curargs_end_offset - curargslength_offset + 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t )(curargs_end_offset - curargslength_offset + 4)) & 0x0000ff00 ) << 8) | (((__uint32_t)((uint32_t)(curargs_end_offset - curargslength_offset + 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(curargs_end_offset - curargslength_offset + 4)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5280 | } | |||
| 5281 | if (!error) { | |||
| 5282 | error = xb_seek(&xbinfo, infolength_offset); | |||
| 5283 | xb_add_32(error, &xbinfo, end_offset - infolength_offset + XDRWORD/*version*/)do { uint32_t __tmp; if (error) break; __tmp = ((__builtin_constant_p ((uint32_t)(end_offset - infolength_offset + 4)) ? ((__uint32_t )((((__uint32_t)((uint32_t)(end_offset - infolength_offset + 4 )) & 0xff000000) >> 24) | (((__uint32_t)((uint32_t) (end_offset - infolength_offset + 4)) & 0x00ff0000) >> 8) | (((__uint32_t)((uint32_t)(end_offset - infolength_offset + 4)) & 0x0000ff00) << 8) | (((__uint32_t)((uint32_t )(end_offset - infolength_offset + 4)) & 0x000000ff) << 24))) : _OSSwapInt32((uint32_t)(end_offset - infolength_offset + 4)))); (error) = xb_add_bytes((&xbinfo), (void*)&__tmp , 4, 0); } while (0); | |||
| 5284 | } | |||
| 5285 | nfsmerr_if(error)do { if (error) goto nfsmerr; } while (0); | |||
| 5286 | ||||
| 5287 | /* copy result xdrbuf to caller */ | |||
| 5288 | *xb = xbinfo; | |||
| 5289 | ||||
| 5290 | /* and mark the local copy as not needing cleanup */ | |||
| 5291 | xbinfo.xb_flags &= ~XB_CLEANUP0x0001; | |||
| 5292 | nfsmerr: | |||
| 5293 | xb_cleanup(&xbinfo); | |||
| 5294 | return (error); | |||
| 5295 | } | |||
| 5296 | ||||
| 5297 | /* | |||
| 5298 | * Do that sysctl thang... | |||
| 5299 | */ | |||
| 5300 | int | |||
| 5301 | nfs_vfs_sysctl(int *name, u_int namelen, user_addr_t oldp, size_t *oldlenp, | |||
| 5302 | user_addr_t newp, size_t newlen, vfs_context_t ctx) | |||
| 5303 | { | |||
| 5304 | int error = 0, val; | |||
| 5305 | int softnobrowse; | |||
| 5306 | struct sysctl_req *req = NULL((void *)0); | |||
| 5307 | union union_vfsidctl vc; | |||
| 5308 | mount_t mp; | |||
| 5309 | struct nfsmount *nmp = NULL((void *)0); | |||
| 5310 | struct vfsquery vq; | |||
| 5311 | struct nfsreq *rq; | |||
| 5312 | boolean_t is_64_bit; | |||
| 5313 | fsid_t fsid; | |||
| 5314 | struct xdrbuf xb; | |||
| 5315 | struct netfs_status *nsp = NULL((void *)0); | |||
| 5316 | int timeoutmask; | |||
| 5317 | uint pos, totlen, count, numThreads; | |||
| 5318 | #if NFSSERVER1 | |||
| 5319 | struct nfs_exportfs *nxfs; | |||
| 5320 | struct nfs_export *nx; | |||
| 5321 | struct nfs_active_user_list *ulist; | |||
| 5322 | struct nfs_export_stat_desc stat_desc; | |||
| 5323 | struct nfs_export_stat_rec statrec; | |||
| 5324 | struct nfs_user_stat_node *unode, *unode_next; | |||
| 5325 | struct nfs_user_stat_desc ustat_desc; | |||
| 5326 | struct nfs_user_stat_user_rec ustat_rec; | |||
| 5327 | struct nfs_user_stat_path_rec upath_rec; | |||
| 5328 | uint bytes_avail, bytes_total, recs_copied; | |||
| 5329 | uint numExports, numRecs; | |||
| 5330 | #endif /* NFSSERVER */ | |||
| 5331 | ||||
| 5332 | /* | |||
| 5333 | * All names at this level are terminal. | |||
| 5334 | */ | |||
| 5335 | if (namelen > 1) | |||
| ||||
| 5336 | return (ENOTDIR20); /* overloaded */ | |||
| 5337 | ||||
| 5338 | is_64_bit = vfs_context_is64bit(ctx); | |||
| 5339 | ||||
| 5340 | /* common code for "new style" VFS_CTL sysctl, get the mount. */ | |||
| 5341 | switch (name[0]) { | |||
| 5342 | case VFS_CTL_TIMEO0x00010005: | |||
| 5343 | case VFS_CTL_NOLOCKS0x00010006: | |||
| 5344 | case VFS_CTL_NSTATUS0x0001000A: | |||
| 5345 | case VFS_CTL_QUERY0x00010003: | |||
| 5346 | req = CAST_DOWN(struct sysctl_req *, oldp)( ((struct sysctl_req *)((uintptr_t) (oldp)/(sizeof(struct sysctl_req *) < sizeof(uintptr_t) ? 0 : 1))) ); | |||
| 5347 | if (req == NULL((void *)0)) { | |||
| 5348 | return EFAULT14; | |||
| 5349 | } | |||
| 5350 | error = SYSCTL_IN(req, &vc, is_64_bit? sizeof(vc.vc64):sizeof(vc.vc32))(req->newfunc)(req, &vc, is_64_bit? sizeof(vc.vc64):sizeof (vc.vc32)); | |||
| 5351 | if (error) | |||
| 5352 | return (error); | |||
| 5353 | mp = vfs_getvfs(&vc.vc32.vc_fsid); /* works for 32 and 64 */ | |||
| 5354 | if (mp == NULL((void *)0)) | |||
| 5355 | return (ENOENT2); | |||
| 5356 | nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)); | |||
| 5357 | if (!nmp) | |||
| 5358 | return (ENOENT2); | |||
| 5359 | bzero(&vq, sizeof(vq)); | |||
| 5360 | req->newidx = 0; | |||
| 5361 | if (is_64_bit) { | |||
| 5362 | req->newptr = vc.vc64.vc_ptr; | |||
| 5363 | req->newlen = (size_t)vc.vc64.vc_len; | |||
| 5364 | } else { | |||
| 5365 | req->newptr = CAST_USER_ADDR_T(vc.vc32.vc_ptr)((user_addr_t)((uintptr_t)(vc.vc32.vc_ptr))); | |||
| 5366 | req->newlen = vc.vc32.vc_len; | |||
| 5367 | } | |||
| 5368 | break; | |||
| 5369 | } | |||
| 5370 | ||||
| 5371 | switch(name[0]) { | |||
| 5372 | case NFS_NFSSTATS1: | |||
| 5373 | if (!oldp) { | |||
| 5374 | *oldlenp = sizeof nfsstats; | |||
| 5375 | return (0); | |||
| 5376 | } | |||
| 5377 | ||||
| 5378 | if (*oldlenp < sizeof nfsstats) { | |||
| 5379 | *oldlenp = sizeof nfsstats; | |||
| 5380 | return (ENOMEM12); | |||
| 5381 | } | |||
| 5382 | ||||
| 5383 | error = copyout(&nfsstats, oldp, sizeof nfsstats); | |||
| 5384 | if (error) | |||
| 5385 | return (error); | |||
| 5386 | ||||
| 5387 | if (newp && newlen != sizeof nfsstats) | |||
| 5388 | return (EINVAL22); | |||
| 5389 | ||||
| 5390 | if (newp) | |||
| 5391 | return copyin(newp, &nfsstats, sizeof nfsstats); | |||
| 5392 | return (0); | |||
| 5393 | case NFS_MOUNTINFO6: | |||
| 5394 | /* read in the fsid */ | |||
| 5395 | if (*oldlenp < sizeof(fsid)) | |||
| 5396 | return (EINVAL22); | |||
| 5397 | if ((error = copyin(oldp, &fsid, sizeof(fsid)))) | |||
| 5398 | return (error); | |||
| 5399 | /* swizzle it back to host order */ | |||
| 5400 | fsid.val[0] = ntohl(fsid.val[0])(__builtin_constant_p(fsid.val[0]) ? ((__uint32_t)((((__uint32_t )(fsid.val[0]) & 0xff000000) >> 24) | (((__uint32_t )(fsid.val[0]) & 0x00ff0000) >> 8) | (((__uint32_t) (fsid.val[0]) & 0x0000ff00) << 8) | (((__uint32_t)( fsid.val[0]) & 0x000000ff) << 24))) : _OSSwapInt32( fsid.val[0])); | |||
| 5401 | fsid.val[1] = ntohl(fsid.val[1])(__builtin_constant_p(fsid.val[1]) ? ((__uint32_t)((((__uint32_t )(fsid.val[1]) & 0xff000000) >> 24) | (((__uint32_t )(fsid.val[1]) & 0x00ff0000) >> 8) | (((__uint32_t) (fsid.val[1]) & 0x0000ff00) << 8) | (((__uint32_t)( fsid.val[1]) & 0x000000ff) << 24))) : _OSSwapInt32( fsid.val[1])); | |||
| 5402 | /* find mount and make sure it's NFS */ | |||
| 5403 | if (((mp = vfs_getvfs(&fsid))) == NULL((void *)0)) | |||
| 5404 | return (ENOENT2); | |||
| 5405 | if (strcmp(mp->mnt_vfsstat.f_fstypename, "nfs")) | |||
| 5406 | return (EINVAL22); | |||
| 5407 | if (((nmp = VFSTONFS(mp)((mp) ? ((struct nfsmount *)vfs_fsprivate(mp)) : ((void *)0)))) == NULL((void *)0)) | |||
| 5408 | return (ENOENT2); | |||
| 5409 | xb_init(&xb, 0); | |||
| 5410 | if ((error = nfs_mountinfo_assemble(nmp, &xb))) | |||
| 5411 | return (error); | |||
| 5412 | if (*oldlenp < xb.xb_u.xb_buffer.xbb_len) | |||
| 5413 | error = ENOMEM12; | |||
| 5414 | else | |||
| 5415 | error = copyout(xb_buffer_base(&xb), oldp, xb.xb_u.xb_buffer.xbb_len); | |||
| 5416 | *oldlenp = xb.xb_u.xb_buffer.xbb_len; | |||
| 5417 | xb_cleanup(&xb); | |||
| 5418 | break; | |||
| 5419 | #if NFSSERVER1 | |||
| 5420 | case NFS_EXPORTSTATS3: | |||
| 5421 | /* setup export stat descriptor */ | |||
| 5422 | stat_desc.rec_vers = NFS_EXPORT_STAT_REC_VERSION1; | |||
| 5423 | ||||
| 5424 | if (!nfsrv_is_initialized()) { | |||
| 5425 | stat_desc.rec_count = 0; | |||
| 5426 | if (oldp && (*oldlenp >= sizeof(struct nfs_export_stat_desc))) | |||
| 5427 | error = copyout(&stat_desc, oldp, sizeof(struct nfs_export_stat_desc)); | |||
| 5428 | *oldlenp = sizeof(struct nfs_export_stat_desc); | |||
| 5429 | return (error); | |||
| 5430 | } | |||
| 5431 | ||||
| 5432 | /* Count the number of exported directories */ | |||
| 5433 | lck_rw_lock_shared(&nfsrv_export_rwlock); | |||
| 5434 | numExports = 0; | |||
| 5435 | LIST_FOREACH(nxfs, &nfsrv_exports, nxfs_next)for ((nxfs) = (((&nfsrv_exports))->lh_first); (nxfs); ( nxfs) = (((nxfs))->nxfs_next.le_next)) | |||
| 5436 | LIST_FOREACH(nx, &nxfs->nxfs_exports, nx_next)for ((nx) = (((&nxfs->nxfs_exports))->lh_first); (nx ); (nx) = (((nx))->nx_next.le_next)) | |||
| 5437 | numExports += 1; | |||
| 5438 | ||||
| 5439 | /* update stat descriptor's export record count */ | |||
| 5440 | stat_desc.rec_count = numExports; | |||
| 5441 | ||||
| 5442 | /* calculate total size of required buffer */ | |||
| 5443 | totlen = sizeof(struct nfs_export_stat_desc) + (numExports * sizeof(struct nfs_export_stat_rec)); | |||
| 5444 | ||||
| 5445 | /* Check caller's buffer */ | |||
| 5446 | if (oldp == 0) { | |||
| 5447 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5448 | /* indicate required buffer len */ | |||
| 5449 | *oldlenp = totlen; | |||
| 5450 | return (0); | |||
| 5451 | } | |||
| 5452 | ||||
| 5453 | /* We require the caller's buffer to be at least large enough to hold the descriptor */ | |||
| 5454 | if (*oldlenp < sizeof(struct nfs_export_stat_desc)) { | |||
| 5455 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5456 | /* indicate required buffer len */ | |||
| 5457 | *oldlenp = totlen; | |||
| 5458 | return (ENOMEM12); | |||
| 5459 | } | |||
| 5460 | ||||
| 5461 | /* indicate required buffer len */ | |||
| 5462 | *oldlenp = totlen; | |||
| 5463 | ||||
| 5464 | /* check if export table is empty */ | |||
| 5465 | if (!numExports) { | |||
| 5466 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5467 | error = copyout(&stat_desc, oldp, sizeof(struct nfs_export_stat_desc)); | |||
| 5468 | return (error); | |||
| 5469 | } | |||
| 5470 | ||||
| 5471 | /* calculate how many actual export stat records fit into caller's buffer */ | |||
| 5472 | numRecs = (*oldlenp - sizeof(struct nfs_export_stat_desc)) / sizeof(struct nfs_export_stat_rec); | |||
| 5473 | ||||
| 5474 | if (!numRecs) { | |||
| 5475 | /* caller's buffer can only accomodate descriptor */ | |||
| 5476 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5477 | stat_desc.rec_count = 0; | |||
| 5478 | error = copyout(&stat_desc, oldp, sizeof(struct nfs_export_stat_desc)); | |||
| 5479 | return (error); | |||
| 5480 | } | |||
| 5481 | ||||
| 5482 | /* adjust to actual number of records to copyout to caller's buffer */ | |||
| 5483 | if (numRecs > numExports) | |||
| 5484 | numRecs = numExports; | |||
| 5485 | ||||
| 5486 | /* set actual number of records we are returning */ | |||
| 5487 | stat_desc.rec_count = numRecs; | |||
| 5488 | ||||
| 5489 | /* first copy out the stat descriptor */ | |||
| 5490 | pos = 0; | |||
| 5491 | error = copyout(&stat_desc, oldp + pos, sizeof(struct nfs_export_stat_desc)); | |||
| 5492 | if (error) { | |||
| 5493 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5494 | return (error); | |||
| 5495 | } | |||
| 5496 | pos += sizeof(struct nfs_export_stat_desc); | |||
| 5497 | ||||
| 5498 | /* Loop through exported directories */ | |||
| 5499 | count = 0; | |||
| 5500 | LIST_FOREACH(nxfs, &nfsrv_exports, nxfs_next)for ((nxfs) = (((&nfsrv_exports))->lh_first); (nxfs); ( nxfs) = (((nxfs))->nxfs_next.le_next)) { | |||
| 5501 | LIST_FOREACH(nx, &nxfs->nxfs_exports, nx_next)for ((nx) = (((&nxfs->nxfs_exports))->lh_first); (nx ); (nx) = (((nx))->nx_next.le_next)) { | |||
| 5502 | ||||
| 5503 | if (count >= numRecs) | |||
| 5504 | break; | |||
| 5505 | ||||
| 5506 | /* build exported filesystem path */ | |||
| 5507 | snprintf(statrec.path, sizeof(statrec.path), "%s%s%s", | |||
| 5508 | nxfs->nxfs_path, ((nxfs->nxfs_path[1] && nx->nx_path[0]) ? "/" : ""), | |||
| 5509 | nx->nx_path); | |||
| 5510 | ||||
| 5511 | /* build the 64-bit export stat counters */ | |||
| 5512 | statrec.ops = ((uint64_t)nx->nx_stats.ops.hi << 32) | | |||
| 5513 | nx->nx_stats.ops.lo; | |||
| 5514 | statrec.bytes_read = ((uint64_t)nx->nx_stats.bytes_read.hi << 32) | | |||
| 5515 | nx->nx_stats.bytes_read.lo; | |||
| 5516 | statrec.bytes_written = ((uint64_t)nx->nx_stats.bytes_written.hi << 32) | | |||
| 5517 | nx->nx_stats.bytes_written.lo; | |||
| 5518 | error = copyout(&statrec, oldp + pos, sizeof(statrec)); | |||
| 5519 | if (error) { | |||
| 5520 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5521 | return (error); | |||
| 5522 | } | |||
| 5523 | /* advance buffer position */ | |||
| 5524 | pos += sizeof(statrec); | |||
| 5525 | } | |||
| 5526 | } | |||
| 5527 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5528 | break; | |||
| 5529 | case NFS_USERSTATS4: | |||
| 5530 | /* init structures used for copying out of kernel */ | |||
| 5531 | ustat_desc.rec_vers = NFS_USER_STAT_REC_VERSION1; | |||
| 5532 | ustat_rec.rec_type = NFS_USER_STAT_USER_REC0; | |||
| 5533 | upath_rec.rec_type = NFS_USER_STAT_PATH_REC1; | |||
| 5534 | ||||
| 5535 | /* initialize counters */ | |||
| 5536 | bytes_total = sizeof(struct nfs_user_stat_desc); | |||
| 5537 | bytes_avail = *oldlenp; | |||
| 5538 | recs_copied = 0; | |||
| 5539 | ||||
| 5540 | if (!nfsrv_is_initialized()) /* NFS server not initialized, so no stats */ | |||
| 5541 | goto ustat_skip; | |||
| 5542 | ||||
| 5543 | /* reclaim old expired user nodes */ | |||
| 5544 | nfsrv_active_user_list_reclaim(); | |||
| 5545 | ||||
| 5546 | /* reserve space for the buffer descriptor */ | |||
| 5547 | if (bytes_avail >= sizeof(struct nfs_user_stat_desc)) | |||
| 5548 | bytes_avail -= sizeof(struct nfs_user_stat_desc); | |||
| 5549 | else | |||
| 5550 | bytes_avail = 0; | |||
| 5551 | ||||
| 5552 | /* put buffer position past the buffer descriptor */ | |||
| 5553 | pos = sizeof(struct nfs_user_stat_desc); | |||
| 5554 | ||||
| 5555 | /* Loop through exported directories */ | |||
| 5556 | lck_rw_lock_shared(&nfsrv_export_rwlock); | |||
| 5557 | LIST_FOREACH(nxfs, &nfsrv_exports, nxfs_next)for ((nxfs) = (((&nfsrv_exports))->lh_first); (nxfs); ( nxfs) = (((nxfs))->nxfs_next.le_next)) { | |||
| 5558 | LIST_FOREACH(nx, &nxfs->nxfs_exports, nx_next)for ((nx) = (((&nxfs->nxfs_exports))->lh_first); (nx ); (nx) = (((nx))->nx_next.le_next)) { | |||
| 5559 | /* copy out path */ | |||
| 5560 | if (bytes_avail >= sizeof(struct nfs_user_stat_path_rec)) { | |||
| 5561 | snprintf(upath_rec.path, sizeof(upath_rec.path), "%s%s%s", | |||
| 5562 | nxfs->nxfs_path, ((nxfs->nxfs_path[1] && nx->nx_path[0]) ? "/" : ""), | |||
| 5563 | nx->nx_path); | |||
| 5564 | ||||
| 5565 | error = copyout(&upath_rec, oldp + pos, sizeof(struct nfs_user_stat_path_rec)); | |||
| ||||
| 5566 | if (error) { | |||
| 5567 | /* punt */ | |||
| 5568 | goto ustat_done; | |||
| 5569 | } | |||
| 5570 | ||||
| 5571 | pos += sizeof(struct nfs_user_stat_path_rec); | |||
| 5572 | bytes_avail -= sizeof(struct nfs_user_stat_path_rec); | |||
| 5573 | recs_copied++; | |||
| 5574 | } | |||
| 5575 | else { | |||
| 5576 | /* Caller's buffer is exhausted */ | |||
| 5577 | bytes_avail = 0; | |||
| 5578 | } | |||
| 5579 | ||||
| 5580 | bytes_total += sizeof(struct nfs_user_stat_path_rec); | |||
| 5581 | ||||
| 5582 | /* Scan through all user nodes of this export */ | |||
| 5583 | ulist = &nx->nx_user_list; | |||
| 5584 | lck_mtx_lock(&ulist->user_mutex); | |||
| 5585 | for (unode = TAILQ_FIRST(&ulist->user_lru)((&ulist->user_lru)->tqh_first); unode; unode = unode_next) { | |||
| 5586 | unode_next = TAILQ_NEXT(unode, lru_link)((unode)->lru_link.tqe_next); | |||
| 5587 | ||||
| 5588 | /* copy out node if there is space */ | |||
| 5589 | if (bytes_avail >= sizeof(struct nfs_user_stat_user_rec)) { | |||
| 5590 | /* prepare a user stat rec for copying out */ | |||
| 5591 | ustat_rec.uid = unode->uid; | |||
| 5592 | bcopy(&unode->sock, &ustat_rec.sock, unode->sock.ss_len); | |||
| 5593 | ustat_rec.ops = unode->ops; | |||
| 5594 | ustat_rec.bytes_read = unode->bytes_read; | |||
| 5595 | ustat_rec.bytes_written = unode->bytes_written; | |||
| 5596 | ustat_rec.tm_start = unode->tm_start; | |||
| 5597 | ustat_rec.tm_last = unode->tm_last; | |||
| 5598 | ||||
| 5599 | error = copyout(&ustat_rec, oldp + pos, sizeof(struct nfs_user_stat_user_rec)); | |||
| 5600 | ||||
| 5601 | if (error) { | |||
| 5602 | /* punt */ | |||
| 5603 | lck_mtx_unlock(&ulist->user_mutex); | |||
| 5604 | goto ustat_done; | |||
| 5605 | } | |||
| 5606 | ||||
| 5607 | pos += sizeof(struct nfs_user_stat_user_rec); | |||
| 5608 | bytes_avail -= sizeof(struct nfs_user_stat_user_rec); | |||
| 5609 | recs_copied++; | |||
| 5610 | } | |||
| 5611 | else { | |||
| 5612 | /* Caller's buffer is exhausted */ | |||
| 5613 | bytes_avail = 0; | |||
| 5614 | } | |||
| 5615 | bytes_total += sizeof(struct nfs_user_stat_user_rec); | |||
| 5616 | } | |||
| 5617 | /* can unlock this export's list now */ | |||
| 5618 | lck_mtx_unlock(&ulist->user_mutex); | |||
| 5619 | } | |||
| 5620 | } | |||
| 5621 | ||||
| 5622 | ustat_done: | |||
| 5623 | /* unlock the export table */ | |||
| 5624 | lck_rw_done(&nfsrv_export_rwlock); | |||
| 5625 | ||||
| 5626 | ustat_skip: | |||
| 5627 | /* indicate number of actual records copied */ | |||
| 5628 | ustat_desc.rec_count = recs_copied; | |||
| 5629 | ||||
| 5630 | if (!error) { | |||
| 5631 | /* check if there was enough room for the buffer descriptor */ | |||
| 5632 | if (*oldlenp >= sizeof(struct nfs_user_stat_desc)) | |||
| 5633 | error = copyout(&ustat_desc, oldp, sizeof(struct nfs_user_stat_desc)); | |||
| 5634 | else | |||
| 5635 | error = ENOMEM12; | |||
| 5636 | ||||
| 5637 | /* always indicate required buffer size */ | |||
| 5638 | *oldlenp = bytes_total; | |||
| 5639 | } | |||
| 5640 | break; | |||
| 5641 | case NFS_USERCOUNT5: | |||
| 5642 | if (!oldp) { | |||
| 5643 | *oldlenp = sizeof(nfsrv_user_stat_node_count); | |||
| 5644 | return (0); | |||
| 5645 | } | |||
| 5646 | ||||
| 5647 | if (*oldlenp < sizeof(nfsrv_user_stat_node_count)) { | |||
| 5648 | *oldlenp = sizeof(nfsrv_user_stat_node_count); | |||
| 5649 | return (ENOMEM12); | |||
| 5650 | } | |||
| 5651 | ||||
| 5652 | if (nfsrv_is_initialized()) { | |||
| 5653 | /* reclaim old expired user nodes */ | |||
| 5654 | nfsrv_active_user_list_reclaim(); | |||
| 5655 | } | |||
| 5656 | ||||
| 5657 | error = copyout(&nfsrv_user_stat_node_count, oldp, sizeof(nfsrv_user_stat_node_count)); | |||
| 5658 | break; | |||
| 5659 | #endif /* NFSSERVER */ | |||
| 5660 | case VFS_CTL_NOLOCKS0x00010006: | |||
| 5661 | if (req->oldptr != USER_ADDR_NULL((user_addr_t) 0)) { | |||
| 5662 | lck_mtx_lock(&nmp->nm_lock); | |||
| 5663 | val = (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED1) ? 1 : 0; | |||
| 5664 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5665 | error = SYSCTL_OUT(req, &val, sizeof(val))(req->oldfunc)(req, &val, sizeof(val)); | |||
| 5666 | if (error) | |||
| 5667 | return (error); | |||
| 5668 | } | |||
| 5669 | if (req->newptr != USER_ADDR_NULL((user_addr_t) 0)) { | |||
| 5670 | error = SYSCTL_IN(req, &val, sizeof(val))(req->newfunc)(req, &val, sizeof(val)); | |||
| 5671 | if (error) | |||
| 5672 | return (error); | |||
| 5673 | lck_mtx_lock(&nmp->nm_lock); | |||
| 5674 | if (nmp->nm_lockmode == NFS_LOCK_MODE_LOCAL2) { | |||
| 5675 | /* can't toggle locks when using local locks */ | |||
| 5676 | error = EINVAL22; | |||
| 5677 | } else if ((nmp->nm_vers >= NFS_VER44) && val) { | |||
| 5678 | /* can't disable locks for NFSv4 */ | |||
| 5679 | error = EINVAL22; | |||
| 5680 | } else if (val) { | |||
| 5681 | if ((nmp->nm_vers <= NFS_VER33) && (nmp->nm_lockmode == NFS_LOCK_MODE_ENABLED0)) | |||
| 5682 | nfs_lockd_mount_unregister(nmp); | |||
| 5683 | nmp->nm_lockmode = NFS_LOCK_MODE_DISABLED1; | |||
| 5684 | nmp->nm_state &= ~NFSSTA_LOCKTIMEO0x00002000; | |||
| 5685 | } else { | |||
| 5686 | if ((nmp->nm_vers <= NFS_VER33) && (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED1)) | |||
| 5687 | nfs_lockd_mount_register(nmp); | |||
| 5688 | nmp->nm_lockmode = NFS_LOCK_MODE_ENABLED0; | |||
| 5689 | } | |||
| 5690 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5691 | } | |||
| 5692 | break; | |||
| 5693 | case VFS_CTL_QUERY0x00010003: | |||
| 5694 | lck_mtx_lock(&nmp->nm_lock); | |||
| 5695 | /* XXX don't allow users to know about/disconnect unresponsive, soft, nobrowse mounts */ | |||
| 5696 | softnobrowse = (NMFLAG(nmp, SOFT)(((uint32_t *)((nmp)->nm_flags))[(0)/32] & (1<<( (0)%32))) && (vfs_flags(nmp->nm_mountp) & MNT_DONTBROWSE0x00100000)); | |||
| 5697 | if (!softnobrowse && (nmp->nm_state & NFSSTA_TIMEO0x00010000)) | |||
| 5698 | vq.vq_flags |= VQ_NOTRESP0x0001; | |||
| 5699 | if (!softnobrowse && (nmp->nm_state & NFSSTA_JUKEBOXTIMEO0x00001000) && !NMFLAG(nmp, MUTEJUKEBOX)(((uint32_t *)((nmp)->nm_flags))[(8)/32] & (1<<( (8)%32)))) | |||
| 5700 | vq.vq_flags |= VQ_NOTRESP0x0001; | |||
| 5701 | if (!softnobrowse && (nmp->nm_state & NFSSTA_LOCKTIMEO0x00002000) && | |||
| 5702 | (nmp->nm_lockmode == NFS_LOCK_MODE_ENABLED0)) | |||
| 5703 | vq.vq_flags |= VQ_NOTRESP0x0001; | |||
| 5704 | if (nmp->nm_state & NFSSTA_DEAD0x04000000) | |||
| 5705 | vq.vq_flags |= VQ_DEAD0x0020; | |||
| 5706 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5707 | error = SYSCTL_OUT(req, &vq, sizeof(vq))(req->oldfunc)(req, &vq, sizeof(vq)); | |||
| 5708 | break; | |||
| 5709 | case VFS_CTL_TIMEO0x00010005: | |||
| 5710 | if (req->oldptr != USER_ADDR_NULL((user_addr_t) 0)) { | |||
| 5711 | lck_mtx_lock(&nmp->nm_lock); | |||
| 5712 | val = nmp->nm_tprintf_initial_delay; | |||
| 5713 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5714 | error = SYSCTL_OUT(req, &val, sizeof(val))(req->oldfunc)(req, &val, sizeof(val)); | |||
| 5715 | if (error) | |||
| 5716 | return (error); | |||
| 5717 | } | |||
| 5718 | if (req->newptr != USER_ADDR_NULL((user_addr_t) 0)) { | |||
| 5719 | error = SYSCTL_IN(req, &val, sizeof(val))(req->newfunc)(req, &val, sizeof(val)); | |||
| 5720 | if (error) | |||
| 5721 | return (error); | |||
| 5722 | lck_mtx_lock(&nmp->nm_lock); | |||
| 5723 | if (val < 0) | |||
| 5724 | nmp->nm_tprintf_initial_delay = 0; | |||
| 5725 | else | |||
| 5726 | nmp->nm_tprintf_initial_delay = val; | |||
| 5727 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5728 | } | |||
| 5729 | break; | |||
| 5730 | case VFS_CTL_NSTATUS0x0001000A: | |||
| 5731 | /* | |||
| 5732 | * Return the status of this mount. This is much more | |||
| 5733 | * information than VFS_CTL_QUERY. In addition to the | |||
| 5734 | * vq_flags return the significant mount options along | |||
| 5735 | * with the list of threads blocked on the mount and | |||
| 5736 | * how long the threads have been waiting. | |||
| 5737 | */ | |||
| 5738 | ||||
| 5739 | lck_mtx_lock(nfs_request_mutex); | |||
| 5740 | lck_mtx_lock(&nmp->nm_lock); | |||
| 5741 | ||||
| 5742 | /* | |||
| 5743 | * Count the number of requests waiting for a reply. | |||
| 5744 | * Note: there could be multiple requests from the same thread. | |||
| 5745 | */ | |||
| 5746 | numThreads = 0; | |||
| 5747 | TAILQ_FOREACH(rq, &nfs_reqq, r_chain)for ((rq) = (((&nfs_reqq))->tqh_first); (rq); (rq) = ( ((rq))->r_chain.tqe_next)) { | |||
| 5748 | if (rq->r_nmp == nmp) | |||
| 5749 | numThreads++; | |||
| 5750 | } | |||
| 5751 | ||||
| 5752 | /* Calculate total size of result buffer */ | |||
| 5753 | totlen = sizeof(struct netfs_status) + (numThreads * sizeof(uint64_t)); | |||
| 5754 | ||||
| 5755 | if (req->oldptr == USER_ADDR_NULL((user_addr_t) 0)) { // Caller is querying buffer size | |||
| 5756 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5757 | lck_mtx_unlock(nfs_request_mutex); | |||
| 5758 | return SYSCTL_OUT(req, NULL, totlen)(req->oldfunc)(req, ((void *)0), totlen); | |||
| 5759 | } | |||
| 5760 | if (req->oldlen < totlen) { // Check if caller's buffer is big enough | |||
| 5761 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5762 | lck_mtx_unlock(nfs_request_mutex); | |||
| 5763 | return (ERANGE34); | |||
| 5764 | } | |||
| 5765 | ||||
| 5766 | MALLOC(nsp, struct netfs_status *, totlen, M_TEMP, M_WAITOK|M_ZERO)({ static vm_allocation_site_t site __attribute__((section("__DATA, __data" ))); (nsp) = (struct netfs_status *)__MALLOC(totlen, 80, 0x0000 |0x0004, &site); }); | |||
| 5767 | if (nsp == NULL((void *)0)) { | |||
| 5768 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5769 | lck_mtx_unlock(nfs_request_mutex); | |||
| 5770 | return (ENOMEM12); | |||
| 5771 | } | |||
| 5772 | timeoutmask = NFSSTA_TIMEO0x00010000 | NFSSTA_LOCKTIMEO0x00002000 | NFSSTA_JUKEBOXTIMEO0x00001000; | |||
| 5773 | if (nmp->nm_state & timeoutmask) | |||
| 5774 | nsp->ns_status |= VQ_NOTRESP0x0001; | |||
| 5775 | if (nmp->nm_state & NFSSTA_DEAD0x04000000) | |||
| 5776 | nsp->ns_status |= VQ_DEAD0x0020; | |||
| 5777 | ||||
| 5778 | (void) nfs_mountopts(nmp, nsp->ns_mountopts, sizeof(nsp->ns_mountopts)); | |||
| 5779 | nsp->ns_threadcount = numThreads; | |||
| 5780 | ||||
| 5781 | /* | |||
| 5782 | * Get the thread ids of threads waiting for a reply | |||
| 5783 | * and find the longest wait time. | |||
| 5784 | */ | |||
| 5785 | if (numThreads > 0) { | |||
| 5786 | struct timeval now; | |||
| 5787 | time_t sendtime; | |||
| 5788 | ||||
| 5789 | microuptime(&now); | |||
| 5790 | count = 0; | |||
| 5791 | sendtime = now.tv_sec; | |||
| 5792 | TAILQ_FOREACH(rq, &nfs_reqq, r_chain)for ((rq) = (((&nfs_reqq))->tqh_first); (rq); (rq) = ( ((rq))->r_chain.tqe_next)) { | |||
| 5793 | if (rq->r_nmp == nmp) { | |||
| 5794 | if (rq->r_start < sendtime) | |||
| 5795 | sendtime = rq->r_start; | |||
| 5796 | // A thread_id of zero is used to represent an async I/O request. | |||
| 5797 | nsp->ns_threadids[count] = | |||
| 5798 | rq->r_thread ? thread_tid(rq->r_thread) : 0; | |||
| 5799 | if (++count >= numThreads) | |||
| 5800 | break; | |||
| 5801 | } | |||
| 5802 | } | |||
| 5803 | nsp->ns_waittime = now.tv_sec - sendtime; | |||
| 5804 | } | |||
| 5805 | ||||
| 5806 | lck_mtx_unlock(&nmp->nm_lock); | |||
| 5807 | lck_mtx_unlock(nfs_request_mutex); | |||
| 5808 | ||||
| 5809 | error = SYSCTL_OUT(req, nsp, totlen)(req->oldfunc)(req, nsp, totlen); | |||
| 5810 | FREE(nsp, M_TEMP)_FREE((void *)nsp, 80); | |||
| 5811 | break; | |||
| 5812 | default: | |||
| 5813 | return (ENOTSUP45); | |||
| 5814 | } | |||
| 5815 | return (error); | |||
| 5816 | } |