vfs_mount.c (138077) | vfs_mount.c (138087) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 45 unchanged lines hidden (view full) --- 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 */ 60 61#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 45 unchanged lines hidden (view full) --- 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 */ 60 61#include <sys/cdefs.h> |
62__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 138077 2004-11-25 09:47:51Z phk $"); | 62__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 138087 2004-11-25 12:06:43Z phk $"); |
63 64#include <sys/param.h> 65#include <sys/conf.h> 66#include <sys/cons.h> 67#include <sys/jail.h> 68#include <sys/kernel.h> 69#include <sys/linker.h> 70#include <sys/mac.h> --- 500 unchanged lines hidden (view full) --- 571 * variables will fit in our mp buffers, including the 572 * terminating NUL. 573 */ 574 if (fstypelen >= MFSNAMELEN - 1 || fspathlen >= MNAMELEN - 1) { 575 error = ENAMETOOLONG; 576 goto bail; 577 } 578 | 63 64#include <sys/param.h> 65#include <sys/conf.h> 66#include <sys/cons.h> 67#include <sys/jail.h> 68#include <sys/kernel.h> 69#include <sys/linker.h> 70#include <sys/mac.h> --- 500 unchanged lines hidden (view full) --- 571 * variables will fit in our mp buffers, including the 572 * terminating NUL. 573 */ 574 if (fstypelen >= MFSNAMELEN - 1 || fspathlen >= MNAMELEN - 1) { 575 error = ENAMETOOLONG; 576 goto bail; 577 } 578 |
579 mtx_lock(&Giant); |
|
579 error = vfs_domount(td, fstype, fspath, fsflags, optlist, 0); | 580 error = vfs_domount(td, fstype, fspath, fsflags, optlist, 0); |
581 mtx_unlock(&Giant); |
|
580bail: 581 if (error) 582 vfs_freeopts(optlist); 583 return (error); 584} 585 586/* 587 * Old mount API. --- 26 unchanged lines hidden (view full) --- 614 615 /* 616 * vfs_mount() actually takes a kernel string for `type' and 617 * `path' now, so extract them. 618 */ 619 error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL); 620 if (error == 0) 621 error = copyinstr(uap->path, fspath, MNAMELEN, NULL); | 582bail: 583 if (error) 584 vfs_freeopts(optlist); 585 return (error); 586} 587 588/* 589 * Old mount API. --- 26 unchanged lines hidden (view full) --- 616 617 /* 618 * vfs_mount() actually takes a kernel string for `type' and 619 * `path' now, so extract them. 620 */ 621 error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL); 622 if (error == 0) 623 error = copyinstr(uap->path, fspath, MNAMELEN, NULL); |
622 if (error == 0) | 624 if (error == 0) { 625 mtx_lock(&Giant); |
623 error = vfs_domount(td, fstype, fspath, uap->flags, 624 uap->data, 1); | 626 error = vfs_domount(td, fstype, fspath, uap->flags, 627 uap->data, 1); |
628 mtx_unlock(&Giant); 629 } |
|
625 free(fstype, M_TEMP); 626 free(fspath, M_TEMP); 627 return (error); 628} 629 630/* 631 * vfs_mount(): actually attempt a filesystem mount. 632 * --- 5 unchanged lines hidden (view full) --- 638int 639vfs_mount(td, fstype, fspath, fsflags, fsdata) 640 struct thread *td; 641 const char *fstype; 642 char *fspath; 643 int fsflags; 644 void *fsdata; 645{ | 630 free(fstype, M_TEMP); 631 free(fspath, M_TEMP); 632 return (error); 633} 634 635/* 636 * vfs_mount(): actually attempt a filesystem mount. 637 * --- 5 unchanged lines hidden (view full) --- 643int 644vfs_mount(td, fstype, fspath, fsflags, fsdata) 645 struct thread *td; 646 const char *fstype; 647 char *fspath; 648 int fsflags; 649 void *fsdata; 650{ |
651 int error; |
|
646 | 652 |
647 return (vfs_domount(td, fstype, fspath, fsflags, fsdata, 1)); | 653 mtx_lock(&Giant); 654 error = vfs_domount(td, fstype, fspath, fsflags, fsdata, 1); 655 mtx_unlock(&Giant); 656 return (error); |
648} 649 650/* 651 * vfs_domount(): actually attempt a filesystem mount. 652 */ 653static int 654vfs_domount( 655 struct thread *td, /* Flags common to all filesystems. */ --- 7 unchanged lines hidden (view full) --- 663 linker_file_t lf; 664 struct vnode *vp; 665 struct mount *mp; 666 struct vfsconf *vfsp; 667 int error, flag = 0, kern_flag = 0; 668 struct vattr va; 669 struct nameidata nd; 670 | 657} 658 659/* 660 * vfs_domount(): actually attempt a filesystem mount. 661 */ 662static int 663vfs_domount( 664 struct thread *td, /* Flags common to all filesystems. */ --- 7 unchanged lines hidden (view full) --- 672 linker_file_t lf; 673 struct vnode *vp; 674 struct mount *mp; 675 struct vfsconf *vfsp; 676 int error, flag = 0, kern_flag = 0; 677 struct vattr va; 678 struct nameidata nd; 679 |
680 mtx_assert(&Giant, MA_OWNED); 681 |
|
671 /* 672 * Be ultra-paranoid about making sure the type and fspath 673 * variables will fit in our mp buffers, including the 674 * terminating NUL. 675 */ 676 if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN) 677 return (ENAMETOOLONG); 678 --- 383 unchanged lines hidden (view full) --- 1062 if (error) 1063 return (error); 1064 1065 /* 1066 * Don't allow unmounting the root filesystem. 1067 */ 1068 if (mp->mnt_flag & MNT_ROOTFS) 1069 return (EINVAL); | 682 /* 683 * Be ultra-paranoid about making sure the type and fspath 684 * variables will fit in our mp buffers, including the 685 * terminating NUL. 686 */ 687 if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN) 688 return (ENAMETOOLONG); 689 --- 383 unchanged lines hidden (view full) --- 1073 if (error) 1074 return (error); 1075 1076 /* 1077 * Don't allow unmounting the root filesystem. 1078 */ 1079 if (mp->mnt_flag & MNT_ROOTFS) 1080 return (EINVAL); |
1070 return (dounmount(mp, uap->flags, td)); | 1081 mtx_lock(&Giant); 1082 error = dounmount(mp, uap->flags, td); 1083 mtx_unlock(&Giant); 1084 return (error); |
1071} 1072 1073/* 1074 * Do the actual filesystem unmount. 1075 */ 1076int 1077dounmount(mp, flags, td) 1078 struct mount *mp; 1079 int flags; 1080 struct thread *td; 1081{ 1082 struct vnode *coveredvp, *fsrootvp; 1083 int error; 1084 int async_flag; 1085 | 1085} 1086 1087/* 1088 * Do the actual filesystem unmount. 1089 */ 1090int 1091dounmount(mp, flags, td) 1092 struct mount *mp; 1093 int flags; 1094 struct thread *td; 1095{ 1096 struct vnode *coveredvp, *fsrootvp; 1097 int error; 1098 int async_flag; 1099 |
1100 mtx_assert(&Giant, MA_OWNED); 1101 |
|
1086 mtx_lock(&mountlist_mtx); 1087 if (mp->mnt_kern_flag & MNTK_UNMOUNT) { 1088 mtx_unlock(&mountlist_mtx); 1089 return (EBUSY); 1090 } 1091 mp->mnt_kern_flag |= MNTK_UNMOUNT; 1092 /* Allow filesystems to detect that a forced unmount is in progress. */ 1093 if (flags & MNT_FORCE) --- 469 unchanged lines hidden (view full) --- 1563 */ 1564 1565struct vnode * 1566__mnt_vnode_next(struct vnode **nvp, struct mount *mp) 1567{ 1568 struct vnode *vp; 1569 1570 mtx_assert(&mp->mnt_mtx, MA_OWNED); | 1102 mtx_lock(&mountlist_mtx); 1103 if (mp->mnt_kern_flag & MNTK_UNMOUNT) { 1104 mtx_unlock(&mountlist_mtx); 1105 return (EBUSY); 1106 } 1107 mp->mnt_kern_flag |= MNTK_UNMOUNT; 1108 /* Allow filesystems to detect that a forced unmount is in progress. */ 1109 if (flags & MNT_FORCE) --- 469 unchanged lines hidden (view full) --- 1579 */ 1580 1581struct vnode * 1582__mnt_vnode_next(struct vnode **nvp, struct mount *mp) 1583{ 1584 struct vnode *vp; 1585 1586 mtx_assert(&mp->mnt_mtx, MA_OWNED); |
1587 |
|
1571 vp = *nvp; 1572 /* Check if we are done */ 1573 if (vp == NULL) 1574 return (NULL); 1575 /* If our next vnode is no longer ours, start over */ 1576 if (vp->v_mount != mp) 1577 vp = TAILQ_FIRST(&mp->mnt_nvnodelist); 1578 /* Save pointer to next vnode in list */ 1579 if (vp != NULL) 1580 *nvp = TAILQ_NEXT(vp, v_nmntvnodes); 1581 else 1582 *nvp = NULL; 1583 return (vp); 1584} | 1588 vp = *nvp; 1589 /* Check if we are done */ 1590 if (vp == NULL) 1591 return (NULL); 1592 /* If our next vnode is no longer ours, start over */ 1593 if (vp->v_mount != mp) 1594 vp = TAILQ_FIRST(&mp->mnt_nvnodelist); 1595 /* Save pointer to next vnode in list */ 1596 if (vp != NULL) 1597 *nvp = TAILQ_NEXT(vp, v_nmntvnodes); 1598 else 1599 *nvp = NULL; 1600 return (vp); 1601} |