Lines Matching refs:mp
142 void enablequotas(struct mount *mp, vfs_context_t ctx);
143 static int getfsstat_callback(mount_t mp, void * arg);
147 static int munge_statfs(struct mount *mp, struct vfsstatfs *sfsp,
150 static int statfs64_common(struct mount *mp, struct vfsstatfs *sfsp, user_addr_t bufp);
233 struct mount *mp;
277 mp = vp->v_mount;
280 mount_lock(mp);
281 if (mp->mnt_lflag & MNT_LUNMOUNT) {
282 mount_unlock(mp);
286 mount_unlock(mp);
287 lck_rw_lock_exclusive(&mp->mnt_rwlock);
294 ((mp->mnt_flag & MNT_RDONLY) == 0)) {
302 if (mp->mnt_vfsstat.f_owner != kauth_cred_getuid(vfs_context_ucred(ctx)) &&
307 error = mac_mount_check_remount(ctx, mp);
309 lck_rw_done(&mp->mnt_rwlock);
319 if (mp->mnt_flag & MNT_NOEXEC)
322 flag = mp->mnt_flag;
324 mp->mnt_flag |=
327 vfsp = mp->mnt_vtable;
389 MALLOC_ZONE(mp, struct mount *, (u_long)sizeof(struct mount),
391 bzero((char *)mp, (u_long)sizeof(struct mount));
395 mp->mnt_maxreadcnt = mp->mnt_maxwritecnt = MAXPHYS;
396 mp->mnt_segreadcnt = mp->mnt_segwritecnt = 32;
397 mp->mnt_maxsegreadsize = mp->mnt_maxreadcnt;
398 mp->mnt_maxsegwritesize = mp->mnt_maxwritecnt;
399 mp->mnt_devblocksize = DEV_BSIZE;
400 mp->mnt_alignmentmask = PAGE_MASK;
401 mp->mnt_ioflags = 0;
402 mp->mnt_realrootvp = NULLVP;
403 mp->mnt_authcache_ttl = CACHED_LOOKUP_RIGHT_TTL;
405 TAILQ_INIT(&mp->mnt_vnodelist);
406 TAILQ_INIT(&mp->mnt_workerqueue);
407 TAILQ_INIT(&mp->mnt_newvnodes);
408 mount_lock_init(mp);
409 lck_rw_lock_exclusive(&mp->mnt_rwlock);
411 mp->mnt_op = vfsp->vfc_vfsops;
412 mp->mnt_vtable = vfsp;
416 //mp->mnt_stat.f_type = vfsp->vfc_typenum;
417 mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
418 strncpy(mp->mnt_vfsstat.f_fstypename, vfsp->vfc_name, MFSTYPENAMELEN);
419 strncpy(mp->mnt_vfsstat.f_mntonname, nd.ni_cnd.cn_pnbuf, MAXPATHLEN);
420 mp->mnt_vnodecovered = vp;
421 mp->mnt_vfsstat.f_owner = kauth_cred_getuid(vfs_context_ucred(ctx));
422 mp->mnt_devbsdunit = LOWPRI_MAX_NUM_DEV - 1;
425 vfs_setowner(mp, KAUTH_UID_NONE, KAUTH_GID_NONE);
432 mp->mnt_flag |= MNT_RDONLY;
433 else if (mp->mnt_flag & MNT_RDONLY)
434 mp->mnt_kern_flag |= MNTK_WANTRDWR;
435 mp->mnt_flag &= ~(MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
439 mp->mnt_flag |= uap->flags & (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
450 mp->mnt_flag |= MNT_MULTILABEL;
474 strncpy(mp->mnt_vfsstat.f_mntfromname, nd1.ni_cnd.cn_pnbuf, MAXPATHLEN);
493 if ((mp->mnt_flag & MNT_RDONLY) == 0)
511 if (vcount(devvp) > 1 && !(vfs_flags(mp) & MNT_ROOTFS)) {
522 ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
533 mp->mnt_devvp = devvp;
536 if ((mp->mnt_flag & MNT_RDONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
541 device_vnode = mp->mnt_devvp;
553 mac_mount_label_init(mp);
554 mac_mount_label_associate(ctx, mp);
563 ctx, mp);
589 error = mac_mount_label_internalize(mp->mnt_mntlabel, labelstr);
596 VNOP_IOCTL(device_vnode, DKIOCGETBSDUNIT, (caddr_t)&mp->mnt_devbsdunit, 0, NULL);
597 mp->mnt_devbsdunit %= LOWPRI_MAX_NUM_DEV;
603 error = VFS_MOUNT(mp, device_vnode, fsmountargs, ctx);
606 if (mp->mnt_kern_flag & MNTK_WANTRDWR)
607 mp->mnt_flag &= ~MNT_RDONLY;
608 mp->mnt_flag &=~
610 mp->mnt_kern_flag &=~ MNTK_WANTRDWR;
612 mp->mnt_flag = flag;
614 lck_rw_done(&mp->mnt_rwlock);
617 enablequotas(mp, ctx);
626 if (vfs_flags(mp) & MNT_MULTILABEL) {
627 error = VFS_ROOT(mp, &rvp, ctx);
634 error = vnode_label(mp, NULL, rvp, NULL, 0, ctx);
642 vp->v_mountedhere = mp;
668 (void)VFS_START(mp, 0, ctx);
670 mount_list_add(mp);
671 lck_rw_done(&mp->mnt_rwlock);
678 if (strncmp(mp->mnt_vfsstat.f_fstypename, "webdav", sizeof("webdav")) != 0 &&
679 vfs_getattr(mp, &vfsattr, ctx) == 0 &&
683 mp->mnt_kern_flag |= MNTK_EXTENDED_ATTRS;
688 mp->mnt_kern_flag |= MNTK_NAMED_STREAMS;
694 mp->mnt_kern_flag |= MNTK_PATH_FROM_ID;
695 } else if (mp->mnt_flag & MNT_DOVOLFS) {
697 mp->mnt_kern_flag |= MNTK_PATH_FROM_ID;
700 if (mp->mnt_vtable->vfc_vfsflags & VFC_VFSNATIVEXATTR) {
701 mp->mnt_kern_flag |= MNTK_EXTENDED_ATTRS;
703 if (mp->mnt_vtable->vfc_vfsflags & VFC_VFSPREFLIGHT) {
704 mp->mnt_kern_flag |= MNTK_UNMOUNT_PREFLIGHT;
708 enablequotas(mp, ctx);
719 vfs_init_io_attributes(device_vnode, mp);
729 mp->mnt_vtable->vfc_refcount--;
736 lck_rw_done(&mp->mnt_rwlock);
738 mount_lock_destroy(mp);
740 mac_mount_label_destroy(mp);
742 FREE_ZONE((caddr_t)mp, sizeof (struct mount), M_MOUNT);
756 (void)VFS_UNMOUNT(mp, MNT_FORCE, ctx);
758 VNOP_CLOSE(device_vnode, mp->mnt_flag & MNT_RDONLY ? FREAD : FREAD|FWRITE,
775 lck_rw_done(&mp->mnt_rwlock);
779 mac_mount_label_destroy(mp);
784 FREE_ZONE((caddr_t)mp, sizeof (struct mount), M_MOUNT);
793 enablequotas(struct mount *mp, vfs_context_t ctx)
803 if ((strncmp(mp->mnt_vfsstat.f_fstypename, "hfs", sizeof("hfs")) != 0 )
804 && (strncmp( mp->mnt_vfsstat.f_fstypename, "ufs", sizeof("ufs")) != 0))
812 snprintf(qfpath, sizeof(qfpath), "%s/%s.%s", mp->mnt_vfsstat.f_mntonname, qfopsname, qfextension[type]);
818 snprintf(qfpath, sizeof(qfpath), "%s/%s.%s", mp->mnt_vfsstat.f_mntonname, qfname, qfextension[type]);
820 (void) VFS_QUOTACTL(mp, QCMD(Q_QUOTAON, type), 0, qfpath, ctx);
936 struct mount *mp;
947 mp = vp->v_mount;
951 error = mac_mount_check_umount(ctx, mp);
964 mount_ref(mp, 0);
967 return (safedounmount(mp, uap->flags, ctx));
973 mount_t mp;
975 mp = mount_list_lookupby_fsid(fsid, 0, 1);
976 if (mp == (mount_t)0) {
979 mount_ref(mp, 0);
980 mount_iterdrop(mp);
982 return(safedounmount(mp, flags, ctx));
991 safedounmount(struct mount *mp, int flags, vfs_context_t ctx)
1000 if ((mp->mnt_vfsstat.f_owner != kauth_cred_getuid(kauth_cred_get())) &&
1007 if (mp->mnt_flag & MNT_ROOTFS) {
1012 return (dounmount(mp, flags, 1, ctx));
1015 mount_drop(mp, 0);
1023 dounmount(struct mount *mp, int flags, int withref, vfs_context_t ctx)
1034 mount_lock(mp);
1037 mp->mnt_kern_flag |= MNTK_FRCUNMOUNT;
1038 mp->mnt_lflag |= MNT_LFORCE;
1040 if (mp->mnt_lflag & MNT_LUNMOUNT) {
1041 mp->mnt_lflag |= MNT_LWAIT;
1043 mount_drop(mp, 1);
1044 msleep((caddr_t)mp, &mp->mnt_mlock, (PVFS | PDROP), "dounmount", NULL);
1047 * Do not dereference mp here - returning EBUSY is safest.
1051 mp->mnt_kern_flag |= MNTK_UNMOUNT;
1052 mp->mnt_lflag |= MNT_LUNMOUNT;
1053 mp->mnt_flag &=~ MNT_ASYNC;
1060 mp->mnt_realrootvp = NULLVP;
1061 mount_unlock(mp);
1076 lck_rw_lock_exclusive(&mp->mnt_rwlock);
1078 mount_drop(mp, 0);
1080 fsevent_unmount(mp); /* has to come first! */
1084 ubc_umount(mp); /* release cached vnodes */
1085 if ((mp->mnt_flag & MNT_RDONLY) == 0) {
1086 error = VFS_SYNC(mp, MNT_WAIT, ctx);
1088 mount_lock(mp);
1089 mp->mnt_kern_flag &= ~MNTK_UNMOUNT;
1090 mp->mnt_lflag &= ~MNT_LUNMOUNT;
1091 mp->mnt_lflag &= ~MNT_LFORCE;
1099 error = vflush(mp, NULLVP, SKIPSWAP | SKIPSYSTEM | SKIPROOT | lflags);
1101 mount_lock(mp);
1102 mp->mnt_kern_flag &= ~MNTK_UNMOUNT;
1103 mp->mnt_lflag &= ~MNT_LUNMOUNT;
1104 mp->mnt_lflag &= ~MNT_LFORCE;
1109 mount_iterdrain(mp);
1111 error = VFS_UNMOUNT(mp, flags, ctx);
1113 mount_iterreset(mp);
1114 mount_lock(mp);
1115 mp->mnt_kern_flag &= ~MNTK_UNMOUNT;
1116 mp->mnt_lflag &= ~MNT_LUNMOUNT;
1117 mp->mnt_lflag &= ~MNT_LFORCE;
1125 if ( mp->mnt_devvp && mp->mnt_vtable->vfc_vfsflags & VFC_VFSLOCALARGS) {
1127 devvp = mp->mnt_devvp;
1131 VNOP_CLOSE(devvp, mp->mnt_flag & MNT_RDONLY ? FREAD : FREAD|FWRITE,
1135 lck_rw_done(&mp->mnt_rwlock);
1136 mount_list_remove(mp);
1137 lck_rw_lock_exclusive(&mp->mnt_rwlock);
1140 if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
1149 mp->mnt_vtable->vfc_refcount--;
1152 cache_purgevfs(mp); /* remove cache entries for this file sys */
1154 mount_lock(mp);
1155 mp->mnt_lflag |= MNT_LDEAD;
1157 if (mp->mnt_lflag & MNT_LWAIT) {
1165 mp->mnt_lflag &= ~MNT_LWAIT;
1166 wakeup((caddr_t)mp);
1168 mount_refdrain(mp);
1170 if (mp->mnt_lflag & MNT_LWAIT) {
1171 mp->mnt_lflag &= ~MNT_LWAIT;
1174 mount_unlock(mp);
1175 lck_rw_done(&mp->mnt_rwlock);
1178 wakeup((caddr_t)mp);
1184 if(mp->mnt_crossref == 0) {
1186 mount_lock_destroy(mp);
1188 mac_mount_label_destroy(mp);
1190 FREE_ZONE((caddr_t)mp, sizeof (struct mount), M_MOUNT);
1196 } else if (mp->mnt_flag & MNT_ROOTFS) {
1197 mount_lock_destroy(mp);
1199 mac_mount_label_destroy(mp);
1201 FREE_ZONE((caddr_t)mp, sizeof (struct mount), M_MOUNT);
1209 mount_dropcrossref(mount_t mp, vnode_t dp, int need_put)
1212 mp->mnt_crossref--;
1213 if (mp->mnt_crossref < 0)
1215 if (((dp->v_lflag & VL_MOUNTDEAD) == VL_MOUNTDEAD) && (mp->mnt_crossref == 0)) {
1220 mount_lock_destroy(mp);
1222 mac_mount_label_destroy(mp);
1224 FREE_ZONE((caddr_t)mp, sizeof (struct mount), M_MOUNT);
1244 sync_callback(mount_t mp, __unused void * arg)
1248 if ((mp->mnt_flag & MNT_RDONLY) == 0) {
1249 asyncflag = mp->mnt_flag & MNT_ASYNC;
1250 mp->mnt_flag &= ~MNT_ASYNC;
1251 VFS_SYNC(mp, MNT_NOWAIT, vfs_context_current());
1253 mp->mnt_flag |= MNT_ASYNC;
1303 struct mount *mp;
1318 mp = nd.ni_vp->v_mount;
1361 error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, datap, ctx);
1414 struct mount *mp;
1427 mp = vp->v_mount;
1428 sp = &mp->mnt_vfsstat;
1431 error = vfs_update_vfsstat(mp, ctx, VFS_USER_EVENT);
1436 error = munge_statfs(mp, sp, uap->buf, NULL, IS_64BIT_PROCESS(p), TRUE);
1448 struct mount *mp;
1459 mp = vp->v_mount;
1460 if (!mp) {
1464 sp = &mp->mnt_vfsstat;
1465 if ((error = vfs_update_vfsstat(mp,vfs_context_current(),VFS_USER_EVENT)) != 0) {
1471 error = munge_statfs(mp, sp, uap->buf, NULL, IS_64BIT_PROCESS(p), TRUE);
1480 statfs64_common(struct mount *mp, struct vfsstatfs *sfsp, user_addr_t bufp)
1496 sfs.f_type = mp->mnt_vtable->vfc_typenum;
1497 sfs.f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
1514 struct mount *mp;
1527 mp = vp->v_mount;
1528 sp = &mp->mnt_vfsstat;
1531 error = vfs_update_vfsstat(mp, ctxp, VFS_USER_EVENT);
1536 error = statfs64_common(mp, sp, uap->buf);
1548 struct mount *mp;
1559 mp = vp->v_mount;
1560 if (!mp) {
1564 sp = &mp->mnt_vfsstat;
1565 if ((error = vfs_update_vfsstat(mp, vfs_context_current(), VFS_USER_EVENT)) != 0) {
1571 error = statfs64_common(mp, sp, uap->buf);
1578 user_addr_t *mp;
1587 getfsstat_callback(mount_t mp, void * arg)
1596 sp = &mp->mnt_vfsstat;
1602 (error = vfs_update_vfsstat(mp, ctx,
1611 error = munge_statfs(mp, sp, fstp->sfsp, &my_size, IS_64BIT_PROCESS(vfs_context_proc(ctx)), FALSE);
1618 if (fstp->mp) {
1619 error = mac_mount_label_get(mp, *fstp->mp);
1624 fstp->mp++;
1652 user_addr_t *mp;
1665 mp = NULL;
1684 MALLOC(mp, user_addr_t *, count * sizeof(user_addr_t), M_MACTEMP, M_WAITOK);
1687 mp[i] = ((user_addr_t *)mp0)[i];
1689 mp[i] = (user_addr_t)mp0[i];
1697 fst.mp = mp;
1706 if (mp)
1707 FREE(mp, M_MACTEMP);
1722 getfsstat64_callback(mount_t mp, void * arg)
1729 sp = &mp->mnt_vfsstat;
1735 (error = vfs_update_vfsstat(mp, vfs_context_current(), VFS_USER_EVENT))) {
1740 error = statfs64_common(mp, sp, fstp->sfsp);
1805 struct mount *mp;
1852 while (!error && (mp = vp->v_mountedhere) != NULL) {
1853 if (vfs_busy(mp, LK_NOWAIT)) {
1857 error = VFS_ROOT(mp, &tdp, ctx);
1858 vfs_unbusy(mp);
5166 struct mount *mp;
5170 mp = fvp->v_mountedhere;
5172 if (vfs_busy(mp, LK_NOWAIT)) {
5181 pathend = &mp->mnt_vfsstat.f_mntonname[0];
5192 maxlen = MAXPATHLEN - (pathend - mp->mnt_vfsstat.f_mntonname);
5198 vfs_unbusy(mp);
6843 munge_statfs(struct mount *mp, struct vfsstatfs *sfsp,
6854 sfs.f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
6855 sfs.f_type = mp->mnt_vtable->vfc_typenum;
6880 sfs.f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
6881 sfs.f_type = mp->mnt_vtable->vfc_typenum;