Lines Matching defs:nmp

354 nfs3_update_statfs(struct nfsmount *nmp, vfs_context_t ctx)
362 nfsvers = nmp->nm_vers;
363 np = nmp->nm_dnp;
387 lck_mtx_lock(&nmp->nm_lock);
388 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_TOTAL);
389 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_FREE);
390 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_AVAIL);
392 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_AVAIL);
393 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_TOTAL);
394 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_FREE);
395 nmp->nm_fsattr.nfsa_bsize = NFS_FABLKSIZE;
396 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_space_total);
397 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_space_free);
398 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_space_avail);
399 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_files_total);
400 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_files_free);
401 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_files_avail);
405 nfsm_chain_get_32(error, &nmrep, nmp->nm_fsattr.nfsa_bsize);
408 if (nmp->nm_fsattr.nfsa_bsize <= 0)
409 nmp->nm_fsattr.nfsa_bsize = NFS_FABLKSIZE;
410 nmp->nm_fsattr.nfsa_space_total = (uint64_t)val * nmp->nm_fsattr.nfsa_bsize;
413 nmp->nm_fsattr.nfsa_space_free = (uint64_t)val * nmp->nm_fsattr.nfsa_bsize;
416 nmp->nm_fsattr.nfsa_space_avail = (uint64_t)val * nmp->nm_fsattr.nfsa_bsize;
418 lck_mtx_unlock(&nmp->nm_lock);
427 nfs4_update_statfs(struct nfsmount *nmp, vfs_context_t ctx)
437 nfsvers = nmp->nm_vers;
438 np = nmp->nm_dnp;
460 nfsm_chain_add_bitmap_supported(error, &nmreq, bitmap, nmp, np);
471 lck_mtx_lock(&nmp->nm_lock);
472 error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, NULL, NULL, NULL);
473 lck_mtx_unlock(&nmp->nm_lock);
483 nmp->nm_fsattr.nfsa_bsize = NFS_FABLKSIZE;
501 struct nfsmount *nmp;
505 if (!(nmp = VFSTONFS(mp)))
507 nfsvers = nmp->nm_vers;
529 lck_mtx_lock(&nmp->nm_lock);
531 if (stamp != nmp->nm_fsattrstamp) {
533 nmp->nm_fsattrstamp = stamp;
537 lck_mtx_unlock(&nmp->nm_lock);
541 error = nmp->nm_funcs->nf_update_statfs(nmp, ctx);
547 lck_mtx_lock(&nmp->nm_lock);
549 VFSATTR_RETURN(fsap, f_bsize, nmp->nm_fsattr.nfsa_bsize);
550 bsize = nmp->nm_fsattr.nfsa_bsize;
551 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_TOTAL))
552 VFSATTR_RETURN(fsap, f_blocks, nmp->nm_fsattr.nfsa_space_total / bsize);
553 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_FREE))
554 VFSATTR_RETURN(fsap, f_bfree, nmp->nm_fsattr.nfsa_space_free / bsize);
555 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_AVAIL))
556 VFSATTR_RETURN(fsap, f_bavail, nmp->nm_fsattr.nfsa_space_avail / bsize);
557 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_TOTAL) &&
558 NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SPACE_FREE))
560 (nmp->nm_fsattr.nfsa_space_total / bsize) -
561 (nmp->nm_fsattr.nfsa_space_free / bsize));
562 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_TOTAL))
563 VFSATTR_RETURN(fsap, f_files, nmp->nm_fsattr.nfsa_files_total);
564 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_FILES_FREE))
565 VFSATTR_RETURN(fsap, f_ffree, nmp->nm_fsattr.nfsa_files_free);
566 lck_mtx_unlock(&nmp->nm_lock);
571 nfsnode_t np = nmp->nm_dnp;
576 lck_mtx_lock(&nmp->nm_lock);
588 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SYMLINK_SUPPORT)) {
590 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_SYMLINK)
593 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_LINK_SUPPORT)) {
595 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_LINK)
598 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_CASE_INSENSITIVE)) {
600 if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_CASE_INSENSITIVE))
603 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_CASE_PRESERVING)) {
605 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_CASE_PRESERVING)
609 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXFILESIZE)) {
611 if (nmp->nm_fsattr.nfsa_maxfilesize >= 0x100000000ULL)
676 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL)
679 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR)
683 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR)
687 } else if (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED) {
690 } else if (nmp->nm_state & NFSSTA_LOCKSWORK) {
738 lck_mtx_unlock(&nmp->nm_lock);
766 nfs3_fsinfo(struct nfsmount *nmp, nfsnode_t np, vfs_context_t ctx)
776 nfsm_chain_build_alloc_init(error, &nmreq, NFSX_FH(nmp->nm_vers));
777 nfsm_chain_add_fh(error, &nmreq, nmp->nm_vers, np->n_fhp, np->n_fhsize);
790 lck_mtx_lock(&nmp->nm_lock);
796 nmp->nm_fsattr.nfsa_maxread = maxsize;
797 if (prefsize < nmp->nm_rsize)
798 nmp->nm_rsize = (prefsize + NFS_FABLKSIZE - 1) &
800 if ((maxsize > 0) && (maxsize < nmp->nm_rsize)) {
801 nmp->nm_rsize = maxsize & ~(NFS_FABLKSIZE - 1);
802 if (nmp->nm_rsize == 0)
803 nmp->nm_rsize = maxsize;
810 nmp->nm_fsattr.nfsa_maxwrite = maxsize;
811 if (prefsize < nmp->nm_wsize)
812 nmp->nm_wsize = (prefsize + NFS_FABLKSIZE - 1) &
814 if ((maxsize > 0) && (maxsize < nmp->nm_wsize)) {
815 nmp->nm_wsize = maxsize & ~(NFS_FABLKSIZE - 1);
816 if (nmp->nm_wsize == 0)
817 nmp->nm_wsize = maxsize;
823 if ((prefsize > 0) && (prefsize < nmp->nm_readdirsize))
824 nmp->nm_readdirsize = prefsize;
825 if ((nmp->nm_fsattr.nfsa_maxread > 0) &&
826 (nmp->nm_fsattr.nfsa_maxread < nmp->nm_readdirsize))
827 nmp->nm_readdirsize = nmp->nm_fsattr.nfsa_maxread;
829 nfsm_chain_get_64(error, &nmrep, nmp->nm_fsattr.nfsa_maxfilesize);
837 nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_LINK;
839 nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_SYMLINK;
841 nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_HOMOGENEOUS;
843 nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_SET_TIME;
844 nmp->nm_state |= NFSSTA_GOTFSINFO;
845 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXREAD);
846 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXWRITE);
847 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXFILESIZE);
848 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_LINK_SUPPORT);
849 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_SYMLINK_SUPPORT);
850 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_HOMOGENEOUS);
851 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_CANSETTIME);
854 lck_mtx_unlock(&nmp->nm_lock);
1883 struct nfsmount *nmp,
1893 if (!nmp->nm_fh)
1900 error = nfs3_getattr_rpc(NULL, nmp->nm_mountp, nmp->nm_fh->fh_data, nmp->nm_fh->fh_len, 0,
1905 error = nfs_nget(nmp->nm_mountp, NULL, NULL, nmp->nm_fh->fh_data, nmp->nm_fh->fh_len,
1915 if (nmp->nm_vers == NFS_VER2) {
1916 NFS_BITMAP_SET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXNAME);
1917 nmp->nm_fsattr.nfsa_maxname = NFS_MAXNAMLEN;
1918 } else if (nmp->nm_vers == NFS_VER3) {
1920 error = nfs3_fsinfo(nmp, *npp, ctx);
1925 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_HOMOGENEOUS) &&
1926 (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_HOMOGENEOUS)) {
1930 lck_mtx_lock(&nmp->nm_lock);
1931 nfs3_pathconf_cache(nmp, &nfsa);
1932 lck_mtx_unlock(&nmp->nm_lock);
1952 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)
1988 error = nfs_request_async(NULL, nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND,
2095 struct nfsmount *nmp,
2113 TAILQ_INIT(&nmp->nm_open_owners);
2114 TAILQ_INIT(&nmp->nm_delegations);
2115 TAILQ_INIT(&nmp->nm_dreturnq);
2116 nmp->nm_stategenid = 1;
2129 if (!nmp->nm_sec.count)
2130 nmp->nm_state |= NFSSTA_NEEDSECINFO;
2133 nfsp = &nmp->nm_locations.nl_locations[nmp->nm_locations.nl_current.nli_loc]->nl_path;
2156 if (nmp->nm_fh) {
2157 dirfh.fh_len = nmp->nm_fh->fh_len;
2158 bcopy(nmp->nm_fh->fh_data, dirfh.fh_data, dirfh.fh_len);
2184 error = nfs_request_async(NULL, nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND,
2193 NFS_CLEAR_ATTRIBUTES(nmp->nm_fsattr.nfsa_bitmap);
2194 error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, &dirfh, NULL, NULL);
2246 fspath.np_components[comp], strlen(fspath.np_components[comp]), nmp);
2255 if (NMFLAG(nmp, NONAMEDATTR) || !strcmp(fspath.np_components[comp], ".zfs"))
2261 error = nfs_request_async(NULL, nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND,
2275 NFS_CLEAR_ATTRIBUTES(nmp->nm_fsattr.nfsa_bitmap);
2276 error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, NULL, NULL, &nfsls);
2284 error = nfs4_get_fs_locations(nmp, NULL, dirfh.fh_data, dirfh.fh_len, fspath.np_components[comp], ctx, &nfsls);
2294 nfs_disconnect(nmp);
2296 nfs_fs_locations_cleanup(&nmp->nm_locations);
2297 nmp->nm_locations = nfsls;
2300 error = nfs_mount_connect(nmp);
2301 if (!error && !(nmp->nm_locations.nl_current.nli_flags & NLI_VALID))
2305 nfsp = &nmp->nm_locations.nl_locations[nmp->nm_locations.nl_current.nli_loc]->nl_path;
2353 error = nfs4_mount_update_path_with_symlink(nmp, &fspath, comp, &dirfh, &depth, &fh, ctx);
2365 if ((nmp->nm_state & NFSSTA_NEEDSECINFO) && (comp == (fspath.np_compcount-1)) && !isdotdot) {
2372 error = nfs4_secinfo_rpc(nmp, &si, vfs_context_ucred(ctx), sec.flavors, &sec.count);
2379 nmp->nm_auth = sec.flavors[0];
2380 nmp->nm_state &= ~NFSSTA_NEEDSECINFO;
2393 numops = NMFLAG(nmp, NONAMEDATTR) ? 2 : 3; // PUTFH + GETATTR + OPENATTR
2404 if (NMFLAG(nmp, NONAMEDATTR) || ((fspath.np_compcount > 0) && !strcmp(fspath.np_components[fspath.np_compcount-1], ".zfs")))
2407 if (!NMFLAG(nmp, NONAMEDATTR)) {
2415 error = nfs_request_async(NULL, nmp->nm_mountp, &nmreq, NFSPROC4_COMPOUND,
2424 NFS_CLEAR_ATTRIBUTES(nmp->nm_fsattr.nfsa_bitmap);
2425 error = nfs4_parsefattr(&nmrep, &nmp->nm_fsattr, &nvattr, NULL, NULL, NULL);
2427 if (!NMFLAG(nmp, NONAMEDATTR)) {
2432 if (error || !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_NAMED_ATTR)) {
2433 nmp->nm_fsattr.nfsa_flags &= ~NFS_FSFLAG_NAMED_ATTR;
2435 nmp->nm_fsattr.nfsa_flags |= NFS_FSFLAG_NAMED_ATTR;
2438 nmp->nm_fsattr.nfsa_flags &= ~NFS_FSFLAG_NAMED_ATTR;
2440 if (NMFLAG(nmp, NOACL)) /* make sure ACL support is turned off */
2441 nmp->nm_fsattr.nfsa_flags &= ~NFS_FSFLAG_ACL;
2442 if (NMFLAG(nmp, ACLONLY) && !(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL))
2443 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_ACLONLY);
2444 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_FH_EXPIRE_TYPE)) {
2445 uint32_t fhtype = ((nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_FHTYPE_MASK) >> NFS_FSFLAG_FHTYPE_SHIFT);
2447 printf("nfs: warning: non-persistent file handles! for %s\n", vfs_statfs(nmp->nm_mountp)->f_mntfromname);
2457 nmp->nm_fsid = nvattr.nva_fsid;
2460 error = nfs_nget(nmp->nm_mountp, NULL, NULL, dirfh.fh_data, dirfh.fh_len, &nvattr, &xid, rq.r_auth, NG_MARKROOT, npp);
2463 if (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL)
2464 vfs_setextendedsecurity(nmp->nm_mountp);
2467 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXREAD) && (nmp->nm_fsattr.nfsa_maxread > 0)) {
2468 if (nmp->nm_fsattr.nfsa_maxread < (uint64_t)nmp->nm_rsize) {
2469 nmp->nm_rsize = nmp->nm_fsattr.nfsa_maxread & ~(NFS_FABLKSIZE - 1);
2470 if (nmp->nm_rsize == 0)
2471 nmp->nm_rsize = nmp->nm_fsattr.nfsa_maxread;
2474 if (NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_bitmap, NFS_FATTR_MAXWRITE) && (nmp->nm_fsattr.nfsa_maxwrite > 0)) {
2475 if (nmp->nm_fsattr.nfsa_maxwrite < (uint64_t)nmp->nm_wsize) {
2476 nmp->nm_wsize = nmp->nm_fsattr.nfsa_maxwrite & ~(NFS_FABLKSIZE - 1);
2477 if (nmp->nm_wsize == 0)
2478 nmp->nm_wsize = nmp->nm_fsattr.nfsa_maxwrite;
2483 nmp->nm_renew_timer = thread_call_allocate(nfs4_renew_timer, nmp);
2484 interval = nmp->nm_fsattr.nfsa_lease / 2;
2487 nfs_interval_timer_start(nmp->nm_renew_timer, interval * 1000);
2511 struct nfsmount *nmp = arg;
2512 int error = 0, savederror = 0, slpflag = (NMFLAG(nmp, INTR) ? PCATCH : 0);
2515 if (NM_OMFLAG(nmp, MNTQUICK)) {
2524 error = nfs_connect(nmp, 1, timeo);
2559 if ((error = nfs_sigintr(nmp, NULL, current_thread(), 0)))
2561 error = tsleep(nmp, PSOCK|slpflag, "nfs_mount_connect_retry", 2*hz);
2568 lck_mtx_lock(&nmp->nm_lock);
2569 if (!nmp->nm_mounterror)
2570 nmp->nm_mounterror = error;
2571 nmp->nm_state &= ~NFSSTA_MOUNT_THREAD;
2572 lck_mtx_unlock(&nmp->nm_lock);
2573 wakeup(&nmp->nm_nss);
2577 nfs_mount_connect(struct nfsmount *nmp)
2588 slpflag = NMFLAG(nmp, INTR) ? PCATCH : 0;
2589 lck_mtx_lock(&nmp->nm_lock);
2591 nmp->nm_state |= NFSSTA_MOUNT_THREAD;
2592 if (kernel_thread_start(nfs_mount_connect_thread, nmp, &thd) != KERN_SUCCESS) {
2593 nmp->nm_state &= ~NFSSTA_MOUNT_THREAD;
2594 nmp->nm_mounterror = EIO;
2595 printf("nfs mount %s start socket connect thread failed\n", vfs_statfs(nmp->nm_mountp)->f_mntfromname);
2601 while (nmp->nm_state & NFSSTA_MOUNT_THREAD) {
2602 error = msleep(&nmp->nm_nss, &nmp->nm_lock, slpflag|PSOCK, "nfsconnectthread", &ts);
2603 if ((error && (error != EWOULDBLOCK)) || ((error = nfs_sigintr(nmp, NULL, current_thread(), 1)))) {
2605 if (!nmp->nm_mounterror)
2606 nmp->nm_mounterror = error;
2608 nmp->nm_sockflags |= NMSOCK_UNMOUNT;
2609 if (nmp->nm_nss)
2610 wakeup(nmp->nm_nss);
2615 lck_mtx_unlock(&nmp->nm_lock);
2618 error = nmp->nm_mounterror;
2633 struct nfsmount *nmp;
2650 nmp = VFSTONFS(mp);
2656 MALLOC_ZONE(nmp, struct nfsmount *,
2658 if (!nmp) {
2662 bzero((caddr_t)nmp, sizeof (struct nfsmount));
2663 lck_mtx_init(&nmp->nm_lock, nfs_mount_grp, LCK_ATTR_NULL);
2664 TAILQ_INIT(&nmp->nm_resendq);
2665 TAILQ_INIT(&nmp->nm_iodq);
2666 TAILQ_INIT(&nmp->nm_gsscl);
2667 LIST_INIT(&nmp->nm_monlist);
2668 vfs_setfsprivate(mp, nmp);
2670 nmp->nm_mountp = mp;
2675 nmp->nm_args = xdrbuf;
2678 nmp->nm_vers = 0;
2679 nmp->nm_timeo = NFS_TIMEO;
2680 nmp->nm_retry = NFS_RETRANS;
2681 nmp->nm_sotype = 0;
2682 nmp->nm_sofamily = 0;
2683 nmp->nm_nfsport = 0;
2684 nmp->nm_wsize = NFS_WSIZE;
2685 nmp->nm_rsize = NFS_RSIZE;
2686 nmp->nm_readdirsize = NFS_READDIRSIZE;
2687 nmp->nm_numgrps = NFS_MAXGRPS;
2688 nmp->nm_readahead = NFS_DEFRAHEAD;
2689 nmp->nm_tprintf_delay = nfs_tprintf_delay;
2690 if (nmp->nm_tprintf_delay < 0)
2691 nmp->nm_tprintf_delay = 0;
2692 nmp->nm_tprintf_initial_delay = nfs_tprintf_initial_delay;
2693 if (nmp->nm_tprintf_initial_delay < 0)
2694 nmp->nm_tprintf_initial_delay = 0;
2695 nmp->nm_acregmin = NFS_MINATTRTIMO;
2696 nmp->nm_acregmax = NFS_MAXATTRTIMO;
2697 nmp->nm_acdirmin = NFS_MINDIRATTRTIMO;
2698 nmp->nm_acdirmax = NFS_MAXDIRATTRTIMO;
2699 nmp->nm_auth = RPCAUTH_SYS;
2700 nmp->nm_deadtimeout = 0;
2701 nmp->nm_curdeadtimeout = 0;
2702 NFS_BITMAP_SET(nmp->nm_flags, NFS_MFLAG_NOACL);
2705 mattrs = nmp->nm_mattrs;
2706 mflags = nmp->nm_mflags;
2707 mflags_mask = nmp->nm_mflags_mask;
2734 nmp->nm_flags[0] &= ~mflags_mask[0];
2735 nmp->nm_flags[0] |= (mflags_mask[0] & mflags[0]);
2747 nmp->nm_vers = NFS_VER2;
2750 nmp->nm_vers = NFS_VER3;
2755 nmp->nm_vers = NFS_VER4;
2771 xb_get_32(error, &xb, nmp->nm_rsize);
2773 xb_get_32(error, &xb, nmp->nm_wsize);
2775 xb_get_32(error, &xb, nmp->nm_readdirsize);
2777 xb_get_32(error, &xb, nmp->nm_readahead);
2779 xb_get_32(error, &xb, nmp->nm_acregmin);
2783 xb_get_32(error, &xb, nmp->nm_acregmax);
2787 xb_get_32(error, &xb, nmp->nm_acdirmin);
2791 xb_get_32(error, &xb, nmp->nm_acdirmax);
2800 if (nmp->nm_vers >= NFS_VER4) {
2807 nmp->nm_lockmode = val;
2820 nmp->nm_sec.count = seccnt;
2822 xb_get_32(error, &xb, nmp->nm_sec.flavors[i]);
2824 switch (nmp->nm_sec.flavors[i]) {
2836 nmp->nm_auth = nmp->nm_sec.flavors[0];
2839 xb_get_32(error, &xb, nmp->nm_numgrps);
2851 nmp->nm_sotype = SOCK_STREAM;
2853 nmp->nm_sotype = SOCK_DGRAM;
2855 nmp->nm_sotype = SOCK_STREAM;
2856 nmp->nm_sofamily = AF_INET;
2858 nmp->nm_sotype = SOCK_DGRAM;
2859 nmp->nm_sofamily = AF_INET;
2861 nmp->nm_sotype = SOCK_STREAM;
2862 nmp->nm_sofamily = AF_INET6;
2864 nmp->nm_sotype = SOCK_DGRAM;
2865 nmp->nm_sofamily = AF_INET6;
2867 nmp->nm_sofamily = AF_INET;
2869 nmp->nm_sofamily = AF_INET6;
2871 nmp->nm_sofamily = 0; /* ok */
2875 if (!error && (nmp->nm_vers >= NFS_VER4) && nmp->nm_sotype &&
2876 (nmp->nm_sotype != SOCK_STREAM))
2881 xb_get_32(error, &xb, nmp->nm_nfsport);
2883 xb_get_32(error, &xb, nmp->nm_mountport);
2886 xb_get_32(error, &xb, nmp->nm_timeo);
2892 nmp->nm_timeo *= 10;
2893 nmp->nm_timeo += (val+100000000-1)/100000000;
2895 nmp->nm_timeo = (nmp->nm_timeo * NFS_HZ + 5) / 10;
2900 nmp->nm_retry = val;
2903 xb_get_32(error, &xb, nmp->nm_deadtimeout);
2908 MALLOC(nmp->nm_fh, fhandle_t *, sizeof(fhandle_t), M_TEMP, M_WAITOK|M_ZERO);
2909 if (!nmp->nm_fh)
2911 xb_get_32(error, &xb, nmp->nm_fh->fh_len);
2913 error = xb_get_bytes(&xb, (char*)&nmp->nm_fh->fh_data[0], nmp->nm_fh->fh_len, 0);
2922 xb_get_32(error, &xb, nmp->nm_locations.nl_numlocs); /* fs location count */
2924 if (!error && ((nmp->nm_locations.nl_numlocs < 1) || (nmp->nm_locations.nl_numlocs > 256)))
2927 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);
2928 if (!nmp->nm_locations.nl_locations)
2930 for (loc = 0; loc < nmp->nm_locations.nl_numlocs; loc++) {
2935 nmp->nm_locations.nl_locations[loc] = fsl;
3047 if (nmp->nm_timeo < NFS_MINTIMEO)
3048 nmp->nm_timeo = NFS_MINTIMEO;
3049 else if (nmp->nm_timeo > NFS_MAXTIMEO)
3050 nmp->nm_timeo = NFS_MAXTIMEO;
3051 if (nmp->nm_retry > NFS_MAXREXMIT)
3052 nmp->nm_retry = NFS_MAXREXMIT;
3054 if (nmp->nm_numgrps > NFS_MAXGRPS)
3055 nmp->nm_numgrps = NFS_MAXGRPS;
3056 if (nmp->nm_readahead > NFS_MAXRAHEAD)
3057 nmp->nm_readahead = NFS_MAXRAHEAD;
3058 if (nmp->nm_acregmin > nmp->nm_acregmax)
3059 nmp->nm_acregmin = nmp->nm_acregmax;
3060 if (nmp->nm_acdirmin > nmp->nm_acdirmax)
3061 nmp->nm_acdirmin = nmp->nm_acdirmax;
3064 if (nmp->nm_locations.nl_numlocs < 1)
3069 if (!NM_OMATTR_GIVEN(nmp, MNTFROM))
3070 nfs_location_mntfromname(&nmp->nm_locations, firstloc,
3074 nmp->nm_mcred = vfs_context_ucred(ctx);
3075 if (IS_VALID_CRED(nmp->nm_mcred))
3076 kauth_cred_ref(nmp->nm_mcred);
3083 if (NMFLAG(nmp, RESVPORT) && !vfs_iskernelmount(mp))
3084 error = priv_check_cred(nmp->nm_mcred, PRIV_NETINET_RESERVEDPORT, 0);
3088 error = nfs_mount_connect(nmp);
3092 if (nmp->nm_vers < NFS_VER4)
3093 nmp->nm_funcs = &nfs3_funcs;
3095 nmp->nm_funcs = &nfs4_funcs;
3098 if (nmp->nm_vers == NFS_VER2) /* ignore RDIRPLUS on NFSv2 */
3099 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_RDIRPLUS);
3100 if (nmp->nm_vers >= NFS_VER4) {
3101 if (NFS_BITMAP_ISSET(nmp->nm_flags, NFS_MFLAG_ACLONLY)) /* aclonly trumps noacl */
3102 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NOACL);
3103 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_CALLUMNT);
3104 if (nmp->nm_lockmode != NFS_LOCK_MODE_ENABLED)
3108 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NOCALLBACK);
3109 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NONAMEDATTR);
3110 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_NOACL);
3111 NFS_BITMAP_CLR(nmp->nm_flags, NFS_MFLAG_ACLONLY);
3112 if (IS_VALID_CRED(nmp->nm_mcred))
3113 kauth_cred_unref(&nmp->nm_mcred);
3117 if (nmp->nm_sotype == SOCK_DGRAM) {
3120 nmp->nm_rsize = NFS_DGRAM_RSIZE;
3122 nmp->nm_wsize = NFS_DGRAM_WSIZE;
3126 nmp->nm_rsize &= ~(NFS_FABLKSIZE - 1);
3127 if (nmp->nm_rsize <= 0)
3128 nmp->nm_rsize = NFS_FABLKSIZE;
3129 nmp->nm_wsize &= ~(NFS_FABLKSIZE - 1);
3130 if (nmp->nm_wsize <= 0)
3131 nmp->nm_wsize = NFS_FABLKSIZE;
3134 maxio = (nmp->nm_vers == NFS_VER2) ? NFS_V2MAXDATA :
3135 (nmp->nm_sotype == SOCK_DGRAM) ? NFS_MAXDGRAMDATA : NFS_MAXDATA;
3138 if (nmp->nm_rsize > maxio)
3139 nmp->nm_rsize = maxio;
3140 if (nmp->nm_wsize > maxio)
3141 nmp->nm_wsize = maxio;
3143 if (nmp->nm_readdirsize > maxio)
3144 nmp->nm_readdirsize = maxio;
3145 if (nmp->nm_readdirsize > nmp->nm_rsize)
3146 nmp->nm_readdirsize = nmp->nm_rsize;
3149 if (nmp->nm_sotype == SOCK_DGRAM)
3150 TAILQ_INIT(&nmp->nm_cwndq);
3156 error = nmp->nm_funcs->nf_mount(nmp, ctx, &np);
3165 nmp->nm_dnp = np;
3178 if ((error = nmp->nm_funcs->nf_update_statfs(nmp, ctx))) {
3187 sbp->f_bsize = nmp->nm_fsattr.nfsa_bsize;
3188 sbp->f_blocks = nmp->nm_fsattr.nfsa_space_total / sbp->f_bsize;
3189 sbp->f_bfree = nmp->nm_fsattr.nfsa_space_free / sbp->f_bsize;
3190 sbp->f_bavail = nmp->nm_fsattr.nfsa_space_avail / sbp->f_bsize;
3191 sbp->f_bused = (nmp->nm_fsattr.nfsa_space_total / sbp->f_bsize) -
3192 (nmp->nm_fsattr.nfsa_space_free / sbp->f_bsize);
3193 sbp->f_files = nmp->nm_fsattr.nfsa_files_total;
3194 sbp->f_ffree = nmp->nm_fsattr.nfsa_files_free;
3206 iosize = max(nmp->nm_rsize, nmp->nm_wsize);
3209 nmp->nm_biosize = trunc_page_32(iosize);
3212 if (nmp->nm_vers > NFS_VER2)
3215 switch (nmp->nm_lockmode) {
3219 vfs_setlocklocal(nmp->nm_mountp);
3223 if (nmp->nm_vers <= NFS_VER3)
3224 nfs_lockd_mount_register(nmp);
3229 lck_mtx_lock(&nmp->nm_lock);
3230 nmp->nm_state |= NFSSTA_MOUNTED;
3231 lck_mtx_unlock(&nmp->nm_lock);
3234 nfs_mount_cleanup(nmp);
3252 struct nfsmount *nmp = NFSTONMP(np);
3273 if (!nmp || (nmp->nm_state & NFSSTA_FORCE))
3303 nlen = strlcpy(mntfromname, vfs_statfs(nmp->nm_mountp)->f_mntfromname, MAXPATHLEN);
3309 nlen = strlcat(mntfromname, path + strlen(vfs_statfs(nmp->nm_mountp)->f_mntonname), MAXPATHLEN);
3336 error = nfs4_get_fs_locations(nmp, dnp, NULL, 0, vname, ctx, &nfsls);
3364 xb_init_buffer(&xb, nmp->nm_args, 2*XDRWORD);
3367 xb_init_buffer(&xb, nmp->nm_args, argslength);
3801 struct nfsmount *nmp;
3806 nmp = VFSTONFS(mp);
3807 if (!nmp || !NMFLAG(nmp, EPHEMERAL))
3813 if ((nmp->nm_mounttime >> 32) > ((uint32_t)now.tv_sec - NFS_EPHEMERAL_MOUNT_HARVEST_INTERVAL))
3904 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)
3920 mntproto = (NM_OMFLAG(nmp, MNTUDP) || (sotype == SOCK_DGRAM)) ? IPPROTO_UDP : IPPROTO_TCP;
3925 if (nmp->nm_mountport)
3926 ((struct sockaddr_in*)saddr)->sin_port = htons(nmp->nm_mountport);
3929 if (nmp->nm_mountport)
3930 ((struct sockaddr_in6*)saddr)->sin6_port = htons(nmp->nm_mountport);
3935 error = nfs_portmap_lookup(nmp, ctx, saddr, NULL, RPCPROG_MNT, mntvers, mntproto, timeo);
3956 nfsm_chain_add_name(error, &nmreq, path, slen, nmp);
3959 error = nfsm_rpchead2(nmp, (mntproto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM,
3964 error = nfs_aux_request(nmp, thd, saddr, NULL,
3987 nfs3_umount_rpc(struct nfsmount *nmp, vfs_context_t ctx, int timeo)
4000 if (!nmp->nm_saddr)
4006 mntvers = (nmp->nm_vers == NFS_VER2) ? RPCMNT_VER1 : RPCMNT_VER3;
4007 mntproto = (NM_OMFLAG(nmp, MNTUDP) || (nmp->nm_sotype == SOCK_DGRAM)) ? IPPROTO_UDP : IPPROTO_TCP;
4008 mntport = nmp->nm_mountport;
4010 bcopy(nmp->nm_saddr, saddr, min(sizeof(ss), nmp->nm_saddr->sa_len));
4017 error = nfs_portmap_lookup(nmp, ctx, saddr, NULL, RPCPROG_MNT, mntvers, mntproto, timeo);
4029 mntvers = (nmp->nm_vers == NFS_VER2) ? RPCMNT_VER1 : RPCMNT_VER3;
4033 bcopy(nmp->nm_saddr, saddr, min(sizeof(ss), nmp->nm_saddr->sa_len));
4039 path = &vfs_statfs(nmp->nm_mountp)->f_mntfromname[0];
4044 nfsm_chain_add_name(error, &nmreq, path, slen, nmp);
4047 error = nfsm_rpchead2(nmp, (mntproto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM,
4052 error = nfs_aux_request(nmp, thd, saddr, NULL,
4069 struct nfsmount *nmp;
4074 nmp = VFSTONFS(mp);
4075 lck_mtx_lock(&nmp->nm_lock);
4079 nmp->nm_state |= NFSSTA_UNMOUNTING;
4087 nmp->nm_state |= NFSSTA_FORCE;
4088 NFS_BITMAP_SET(nmp->nm_flags, NFS_MFLAG_SOFT);
4093 while (nmp->nm_state & NFSSTA_MONITOR_SCAN)
4094 msleep(&nmp->nm_state, &nmp->nm_lock, PZERO-1, "nfswaitmonscan", &ts);
4102 vp = NFSTOV(nmp->nm_dnp);
4103 lck_mtx_unlock(&nmp->nm_lock);
4120 lck_mtx_lock(&nmp->nm_lock);
4121 nmp->nm_state &= ~NFSSTA_UNMOUNTING;
4122 lck_mtx_unlock(&nmp->nm_lock);
4126 lck_mtx_lock(&nmp->nm_lock);
4127 nmp->nm_dnp = NULL;
4128 lck_mtx_unlock(&nmp->nm_lock);
4140 nfs_mount_cleanup(nmp);
4196 nfs_mount_cleanup(struct nfsmount *nmp)
4206 if ((nmp->nm_vers >= NFS_VER4) && !NMFLAG(nmp, NOCALLBACK) && nmp->nm_cbid)
4207 nfs4_mount_callback_shutdown(nmp);
4210 if (!TAILQ_EMPTY(&nmp->nm_gsscl))
4211 nfs_gss_clnt_ctx_unmount(nmp);
4214 lck_mtx_lock(&nmp->nm_lock);
4215 nmp->nm_sockflags |= NMSOCK_UNMOUNT;
4218 if ((nmp->nm_vers < NFS_VER4) && (nmp->nm_state & NFSSTA_MOUNTED) &&
4219 !(nmp->nm_state & NFSSTA_FORCE) && NMFLAG(nmp, CALLUMNT))
4220 nfs_mount_sock_thread_wake(nmp);
4223 while (nmp->nm_sockthd) {
4224 wakeup(&nmp->nm_sockthd);
4225 msleep(&nmp->nm_sockthd, &nmp->nm_lock, PZERO-1, "nfswaitsockthd", &ts);
4228 lck_mtx_unlock(&nmp->nm_lock);
4231 nfs_disconnect(nmp);
4233 if (nmp->nm_mountp)
4234 vfs_setfsprivate(nmp->nm_mountp, NULL);
4236 lck_mtx_lock(&nmp->nm_lock);
4238 if ((nmp->nm_vers >= NFS_VER4) && !NMFLAG(nmp, NOCALLBACK) && nmp->nm_cbid) {
4240 while ((np = TAILQ_FIRST(&nmp->nm_dreturnq))) {
4241 TAILQ_REMOVE(&nmp->nm_dreturnq, np, n_dreturn);
4247 if ((nmp->nm_vers >= NFS_VER4) && nmp->nm_renew_timer) {
4248 thread_call_cancel(nmp->nm_renew_timer);
4249 thread_call_free(nmp->nm_renew_timer);
4252 if (nmp->nm_saddr)
4253 FREE(nmp->nm_saddr, M_SONAME);
4254 if ((nmp->nm_vers < NFS_VER4) && nmp->nm_rqsaddr)
4255 FREE(nmp->nm_rqsaddr, M_SONAME);
4256 lck_mtx_unlock(&nmp->nm_lock);
4258 if (nmp->nm_state & NFSSTA_MOUNTED)
4259 switch (nmp->nm_lockmode) {
4265 if (nmp->nm_vers <= NFS_VER3)
4266 nfs_lockd_mount_unregister(nmp);
4270 if ((nmp->nm_vers >= NFS_VER4) && nmp->nm_longid) {
4273 TAILQ_REMOVE(&nfsclientids, nmp->nm_longid, nci_link);
4274 if (nmp->nm_longid->nci_id)
4275 FREE(nmp->nm_longid->nci_id, M_TEMP);
4276 FREE(nmp->nm_longid, M_TEMP);
4287 if (req->r_nmp == nmp) {
4299 lck_mtx_lock(&nmp->nm_lock);
4302 TAILQ_REMOVE(&nmp->nm_resendq, req, r_rchain);
4307 lck_mtx_unlock(&nmp->nm_lock);
4316 TAILQ_CONCAT(&iodq, &nmp->nm_iodq, r_achain);
4330 lck_mtx_lock(&nmp->nm_lock);
4331 while ((np = LIST_FIRST(&nmp->nm_monlist))) {
4335 TAILQ_FOREACH_SAFE(noop, &nmp->nm_open_owners, noo_link, nextnoop) {
4336 TAILQ_REMOVE(&nmp->nm_open_owners, noop, noo_link);
4342 lck_mtx_unlock(&nmp->nm_lock);
4345 if (nmp->nm_vers >= NFS_VER4) {
4346 lck_mtx_lock(&nmp->nm_lock);
4347 while ((np = TAILQ_FIRST(&nmp->nm_delegations))) {
4348 TAILQ_REMOVE(&nmp->nm_delegations, np, n_dlink);
4351 lck_mtx_unlock(&nmp->nm_lock);
4353 if (IS_VALID_CRED(nmp->nm_mcred))
4354 kauth_cred_unref(&nmp->nm_mcred);
4356 nfs_fs_locations_cleanup(&nmp->nm_locations);
4358 if (nmp->nm_args)
4359 xb_free(nmp->nm_args);
4360 lck_mtx_destroy(&nmp->nm_lock, nfs_mount_grp);
4361 if (nmp->nm_fh)
4362 FREE(nmp->nm_fh, M_TEMP);
4363 FREE_ZONE((caddr_t)nmp, sizeof (struct nfsmount), M_NFSMNT);
4373 struct nfsmount *nmp;
4377 nmp = VFSTONFS(mp);
4378 if (!nmp || !nmp->nm_dnp)
4380 vp = NFSTOV(nmp->nm_dnp);
4410 nfs3_getquota(struct nfsmount *nmp, vfs_context_t ctx, uid_t id, int type, struct dqblk *dqb)
4424 if (!nmp->nm_saddr)
4427 if (NMFLAG(nmp, NOQUOTA))
4430 if (!nmp->nm_rqsaddr)
4431 MALLOC(nmp->nm_rqsaddr, struct sockaddr *, sizeof(struct sockaddr_storage), M_SONAME, M_WAITOK|M_ZERO);
4432 if (!nmp->nm_rqsaddr)
4434 rqsaddr = nmp->nm_rqsaddr;
4440 timeo = NMFLAG(nmp, SOFT) ? 10 : 60;
4445 if (!rqport || ((nmp->nm_rqsaddrstamp + 60) >= (uint32_t)now.tv_sec)) {
4447 bcopy(nmp->nm_saddr, rqsaddr, min(sizeof(struct sockaddr_storage), nmp->nm_saddr->sa_len));
4448 error = nfs_portmap_lookup(nmp, ctx, rqsaddr, NULL, RPCPROG_RQUOTA, rqvers, rqproto, timeo);
4460 nmp->nm_rqsaddrstamp = now.tv_sec;
4466 path = &vfs_statfs(nmp->nm_mountp)->f_mntfromname[0];
4471 nfsm_chain_add_name(error, &nmreq, path, slen, nmp);
4477 error = nfsm_rpchead2(nmp, (rqproto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM,
4482 error = nfs_aux_request(nmp, thd, rqsaddr, NULL,
4522 nfs4_getquota(struct nfsmount *nmp, vfs_context_t ctx, uid_t id, int type, struct dqblk *dqb)
4537 if (!NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_HARD) &&
4538 !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_SOFT) &&
4539 !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_USED))
4560 nfsvers = nmp->nm_vers;
4561 np = nmp->nm_dnp;
4586 nfsm_chain_add_bitmap_supported(error, &nmreq, bitmap, nmp, NULL);
4611 struct nfsmount *nmp;
4616 if (!(nmp = VFSTONFS(mp)))
4618 nfsvers = nmp->nm_vers;
4648 error = nmp->nm_funcs->nf_getquota(nmp, ctx, uid, type, dqb);
4770 nfs_mountinfo_assemble(struct nfsmount *nmp, struct xdrbuf *xb)
4796 if (nmp->nm_state & NFSSTA_DEAD)
4798 if ((nmp->nm_state & (NFSSTA_TIMEO|NFSSTA_JUKEBOXTIMEO)) ||
4799 ((nmp->nm_state & NFSSTA_LOCKTIMEO) && (nmp->nm_lockmode == NFS_LOCK_MODE_ENABLED)))
4801 if (nmp->nm_state & NFSSTA_RECOVER)
4805 xb_init_buffer(&xborig, nmp->nm_args, 2*XDRWORD);
4814 if (nmp->nm_vers >= NFS_VER4)
4829 if ((nmp->nm_vers < NFS_VER4) && nmp->nm_mountport)
4832 if (NMFLAG(nmp, SOFT))
4834 if (nmp->nm_deadtimeout)
4836 if (nmp->nm_fh)
4849 if (nmp->nm_sotype == SOCK_DGRAM)
4852 if (nmp->nm_vers < NFS_VER4)
4854 if (nmp->nm_vers >= NFS_VER3)
4858 if (nmp->nm_vers >= NFS_VER4) {
4867 if (nmp->nm_vers < NFS_VER4)
4872 if (NMFLAG(nmp, SOFT))
4874 if (NMFLAG(nmp, INTR))
4876 if (NMFLAG(nmp, RESVPORT))
4878 if ((nmp->nm_sotype == SOCK_DGRAM) && NMFLAG(nmp, NOCONNECT))
4880 if (NMFLAG(nmp, DUMBTIMER))
4882 if ((nmp->nm_vers < NFS_VER4) && NMFLAG(nmp, CALLUMNT))
4884 if ((nmp->nm_vers >= NFS_VER3) && NMFLAG(nmp, RDIRPLUS))
4886 if (NMFLAG(nmp, NONEGNAMECACHE))
4888 if (NMFLAG(nmp, MUTEJUKEBOX))
4890 if (nmp->nm_vers >= NFS_VER4) {
4891 if (NMFLAG(nmp, EPHEMERAL))
4893 if (NMFLAG(nmp, NOCALLBACK))
4895 if (NMFLAG(nmp, NONAMEDATTR))
4897 if (NMFLAG(nmp, NOACL))
4899 if (NMFLAG(nmp, ACLONLY))
4902 if (NMFLAG(nmp, NFC))
4904 if (NMFLAG(nmp, NOQUOTA) || ((nmp->nm_vers >= NFS_VER4) &&
4905 !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_HARD) &&
4906 !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_AVAIL_SOFT) &&
4907 !NFS_BITMAP_ISSET(nmp->nm_fsattr.nfsa_supp_attr, NFS_FATTR_QUOTA_USED)))
4909 if ((nmp->nm_vers < NFS_VER4) && NMFLAG(nmp, MNTUDP))
4911 if (NMFLAG(nmp, MNTQUICK))
4923 error = xb_add_bytes(&xbinfo, nmp->nm_args, origargslength, 0);
4939 xb_add_32(error, &xbinfo, nmp->nm_vers); /* NFS_VERSION */
4940 if (nmp->nm_vers >= NFS_VER4)
4942 xb_add_32(error, &xbinfo, nmp->nm_rsize); /* READ_SIZE */
4943 xb_add_32(error, &xbinfo, nmp->nm_wsize); /* WRITE_SIZE */
4944 xb_add_32(error, &xbinfo, nmp->nm_readdirsize); /* READDIR_SIZE */
4945 xb_add_32(error, &xbinfo, nmp->nm_readahead); /* READAHEAD */
4946 xb_add_32(error, &xbinfo, nmp->nm_acregmin); /* ATTRCACHE_REG_MIN */
4948 xb_add_32(error, &xbinfo, nmp->nm_acregmax); /* ATTRCACHE_REG_MAX */
4950 xb_add_32(error, &xbinfo, nmp->nm_acdirmin); /* ATTRCACHE_DIR_MIN */
4952 xb_add_32(error, &xbinfo, nmp->nm_acdirmax); /* ATTRCACHE_DIR_MAX */
4954 xb_add_32(error, &xbinfo, nmp->nm_lockmode); /* LOCK_MODE */
4955 if (nmp->nm_sec.count) {
4956 xb_add_32(error, &xbinfo, nmp->nm_sec.count); /* SECURITY */
4958 for (i=0; i < nmp->nm_sec.count; i++)
4959 xb_add_32(error, &xbinfo, nmp->nm_sec.flavors[i]);
4960 } else if (nmp->nm_servsec.count) {
4961 xb_add_32(error, &xbinfo, nmp->nm_servsec.count); /* SECURITY */
4963 for (i=0; i < nmp->nm_servsec.count; i++)
4964 xb_add_32(error, &xbinfo, nmp->nm_servsec.flavors[i]);
4967 xb_add_32(error, &xbinfo, nmp->nm_auth);
4969 xb_add_32(error, &xbinfo, nmp->nm_numgrps); /* MAX_GROUP_LIST */
4971 snprintf(sotype, sizeof(sotype), "%s%s", (nmp->nm_sotype == SOCK_DGRAM) ? "udp" : "tcp",
4972 nmp->nm_sofamily ? (nmp->nm_sofamily == AF_INET) ? "4" : "6" : "");
4974 xb_add_32(error, &xbinfo, ntohs(((struct sockaddr_in*)nmp->nm_saddr)->sin_port)); /* NFS_PORT */
4975 if ((nmp->nm_vers < NFS_VER4) && nmp->nm_mountport)
4976 xb_add_32(error, &xbinfo, nmp->nm_mountport); /* MOUNT_PORT */
4977 timeo = (nmp->nm_timeo * 10) / NFS_HZ;
4980 if (NMFLAG(nmp, SOFT))
4981 xb_add_32(error, &xbinfo, nmp->nm_retry); /* SOFT_RETRY_COUNT */
4982 if (nmp->nm_deadtimeout) {
4983 xb_add_32(error, &xbinfo, nmp->nm_deadtimeout); /* DEAD_TIMEOUT */
4986 if (nmp->nm_fh)
4987 xb_add_fh(error, &xbinfo, &nmp->nm_fh->fh_data[0], nmp->nm_fh->fh_len); /* FH */
4988 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_numlocs); /* FS_LOCATIONS */
4989 for (loc = 0; !error && (loc < nmp->nm_locations.nl_numlocs); loc++) {
4990 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servcount);
4991 for (serv = 0; !error && (serv < nmp->nm_locations.nl_locations[loc]->nl_servcount); serv++) {
4992 xb_add_string(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_name,
4993 strlen(nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_name));
4994 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addrcount);
4995 for (addr = 0; !error && (addr < nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addrcount); addr++)
4996 xb_add_string(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addresses[addr],
4997 strlen(nmp->nm_locations.nl_locations[loc]->nl_servers[serv]->ns_addresses[addr]));
5000 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount);
5001 for (comp = 0; !error && (comp < nmp->nm_locations.nl_locations[loc]->nl_path.np_compcount); comp++)
5002 xb_add_string(error, &xbinfo, nmp->nm_locations.nl_locations[loc]->nl_path.np_components[comp],
5003 strlen(nmp->nm_locations.nl_locations[loc]->nl_path.np_components[comp]));
5006 xb_add_32(error, &xbinfo, vfs_flags(nmp->nm_mountp)); /* MNTFLAGS */
5008 xb_add_string(error, &xbinfo, vfs_statfs(nmp->nm_mountp)->f_mntfromname,
5009 strlen(vfs_statfs(nmp->nm_mountp)->f_mntfromname)); /* MNTFROM */
5013 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_flags);
5014 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_loc);
5015 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_serv);
5016 xb_add_32(error, &xbinfo, nmp->nm_locations.nl_current.nli_addr);
5061 struct nfsmount *nmp = NULL;
5100 nmp = VFSTONFS(mp);
5101 if (nmp == NULL)
5150 if (((nmp = VFSTONFS(mp))) == NULL)
5153 if ((error = nfs_mountinfo_assemble(nmp, &xb)))
5405 lck_mtx_lock(&nmp->nm_lock);
5406 val = (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED) ? 1 : 0;
5407 lck_mtx_unlock(&nmp->nm_lock);
5416 lck_mtx_lock(&nmp->nm_lock);
5417 if (nmp->nm_lockmode == NFS_LOCK_MODE_LOCAL) {
5420 } else if ((nmp->nm_vers >= NFS_VER4) && val) {
5424 if ((nmp->nm_vers <= NFS_VER3) && (nmp->nm_lockmode == NFS_LOCK_MODE_ENABLED))
5425 nfs_lockd_mount_unregister(nmp);
5426 nmp->nm_lockmode = NFS_LOCK_MODE_DISABLED;
5427 nmp->nm_state &= ~NFSSTA_LOCKTIMEO;
5429 if ((nmp->nm_vers <= NFS_VER3) && (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED))
5430 nfs_lockd_mount_register(nmp);
5431 nmp->nm_lockmode = NFS_LOCK_MODE_ENABLED;
5433 lck_mtx_unlock(&nmp->nm_lock);
5437 lck_mtx_lock(&nmp->nm_lock);
5439 softnobrowse = (NMFLAG(nmp, SOFT) && (vfs_flags(nmp->nm_mountp) & MNT_DONTBROWSE));
5440 if (!softnobrowse && (nmp->nm_state & NFSSTA_TIMEO))
5442 if (!softnobrowse && (nmp->nm_state & NFSSTA_JUKEBOXTIMEO) && !NMFLAG(nmp, MUTEJUKEBOX))
5444 if (!softnobrowse && (nmp->nm_state & NFSSTA_LOCKTIMEO) &&
5445 (nmp->nm_lockmode == NFS_LOCK_MODE_ENABLED))
5447 if (nmp->nm_state & NFSSTA_DEAD)
5449 lck_mtx_unlock(&nmp->nm_lock);
5454 lck_mtx_lock(&nmp->nm_lock);
5455 val = nmp->nm_tprintf_initial_delay;
5456 lck_mtx_unlock(&nmp->nm_lock);
5465 lck_mtx_lock(&nmp->nm_lock);
5467 nmp->nm_tprintf_initial_delay = 0;
5469 nmp->nm_tprintf_initial_delay = val;
5470 lck_mtx_unlock(&nmp->nm_lock);