aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorJan Blunck <jblunck@suse.de>2008-02-14 22:34:38 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-15 00:13:33 -0500
commit6ac08c39a16f72c2d3e845cb6849a1392fa03e80 (patch)
treed7603571e9ab3ea4b57b7901211320e48d0c5ed8 /fs/namespace.c
parent5dd784d04924be5d8bc066aded0ec3274b20e612 (diff)
Use struct path in fs_struct
* Use struct path in fs_struct. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Jan Blunck <jblunck@suse.de> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index c77eedd2ac66..ac19212c9bc3 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -593,7 +593,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
593 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount] 593 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount]
594 */ 594 */
595 if (flags & MNT_EXPIRE) { 595 if (flags & MNT_EXPIRE) {
596 if (mnt == current->fs->rootmnt || 596 if (mnt == current->fs->root.mnt ||
597 flags & (MNT_FORCE | MNT_DETACH)) 597 flags & (MNT_FORCE | MNT_DETACH))
598 return -EINVAL; 598 return -EINVAL;
599 599
@@ -628,7 +628,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
628 * /reboot - static binary that would close all descriptors and 628 * /reboot - static binary that would close all descriptors and
629 * call reboot(9). Then init(8) could umount root and exec /reboot. 629 * call reboot(9). Then init(8) could umount root and exec /reboot.
630 */ 630 */
631 if (mnt == current->fs->rootmnt && !(flags & MNT_DETACH)) { 631 if (mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) {
632 /* 632 /*
633 * Special case for "unmounting" root ... 633 * Special case for "unmounting" root ...
634 * we just try to remount it readonly. 634 * we just try to remount it readonly.
@@ -1559,17 +1559,17 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
1559 while (p) { 1559 while (p) {
1560 q->mnt_ns = new_ns; 1560 q->mnt_ns = new_ns;
1561 if (fs) { 1561 if (fs) {
1562 if (p == fs->rootmnt) { 1562 if (p == fs->root.mnt) {
1563 rootmnt = p; 1563 rootmnt = p;
1564 fs->rootmnt = mntget(q); 1564 fs->root.mnt = mntget(q);
1565 } 1565 }
1566 if (p == fs->pwdmnt) { 1566 if (p == fs->pwd.mnt) {
1567 pwdmnt = p; 1567 pwdmnt = p;
1568 fs->pwdmnt = mntget(q); 1568 fs->pwd.mnt = mntget(q);
1569 } 1569 }
1570 if (p == fs->altrootmnt) { 1570 if (p == fs->altroot.mnt) {
1571 altrootmnt = p; 1571 altrootmnt = p;
1572 fs->altrootmnt = mntget(q); 1572 fs->altroot.mnt = mntget(q);
1573 } 1573 }
1574 } 1574 }
1575 p = next_mnt(p, mnt_ns->root); 1575 p = next_mnt(p, mnt_ns->root);
@@ -1653,18 +1653,15 @@ out1:
1653void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt, 1653void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
1654 struct dentry *dentry) 1654 struct dentry *dentry)
1655{ 1655{
1656 struct dentry *old_root; 1656 struct path old_root;
1657 struct vfsmount *old_rootmnt; 1657
1658 write_lock(&fs->lock); 1658 write_lock(&fs->lock);
1659 old_root = fs->root; 1659 old_root = fs->root;
1660 old_rootmnt = fs->rootmnt; 1660 fs->root.mnt = mntget(mnt);
1661 fs->rootmnt = mntget(mnt); 1661 fs->root.dentry = dget(dentry);
1662 fs->root = dget(dentry);
1663 write_unlock(&fs->lock); 1662 write_unlock(&fs->lock);
1664 if (old_root) { 1663 if (old_root.dentry)
1665 dput(old_root); 1664 path_put(&old_root);
1666 mntput(old_rootmnt);
1667 }
1668} 1665}
1669 1666
1670/* 1667/*
@@ -1674,20 +1671,16 @@ void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
1674void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, 1671void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
1675 struct dentry *dentry) 1672 struct dentry *dentry)
1676{ 1673{
1677 struct dentry *old_pwd; 1674 struct path old_pwd;
1678 struct vfsmount *old_pwdmnt;
1679 1675
1680 write_lock(&fs->lock); 1676 write_lock(&fs->lock);
1681 old_pwd = fs->pwd; 1677 old_pwd = fs->pwd;
1682 old_pwdmnt = fs->pwdmnt; 1678 fs->pwd.mnt = mntget(mnt);
1683 fs->pwdmnt = mntget(mnt); 1679 fs->pwd.dentry = dget(dentry);
1684 fs->pwd = dget(dentry);
1685 write_unlock(&fs->lock); 1680 write_unlock(&fs->lock);
1686 1681
1687 if (old_pwd) { 1682 if (old_pwd.dentry)
1688 dput(old_pwd); 1683 path_put(&old_pwd);
1689 mntput(old_pwdmnt);
1690 }
1691} 1684}
1692 1685
1693static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd) 1686static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
@@ -1702,12 +1695,12 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
1702 if (fs) { 1695 if (fs) {
1703 atomic_inc(&fs->count); 1696 atomic_inc(&fs->count);
1704 task_unlock(p); 1697 task_unlock(p);
1705 if (fs->root == old_nd->path.dentry 1698 if (fs->root.dentry == old_nd->path.dentry
1706 && fs->rootmnt == old_nd->path.mnt) 1699 && fs->root.mnt == old_nd->path.mnt)
1707 set_fs_root(fs, new_nd->path.mnt, 1700 set_fs_root(fs, new_nd->path.mnt,
1708 new_nd->path.dentry); 1701 new_nd->path.dentry);
1709 if (fs->pwd == old_nd->path.dentry 1702 if (fs->pwd.dentry == old_nd->path.dentry
1710 && fs->pwdmnt == old_nd->path.mnt) 1703 && fs->pwd.mnt == old_nd->path.mnt)
1711 set_fs_pwd(fs, new_nd->path.mnt, 1704 set_fs_pwd(fs, new_nd->path.mnt,
1712 new_nd->path.dentry); 1705 new_nd->path.dentry);
1713 put_fs_struct(fs); 1706 put_fs_struct(fs);
@@ -1773,8 +1766,8 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1773 } 1766 }
1774 1767
1775 read_lock(&current->fs->lock); 1768 read_lock(&current->fs->lock);
1776 user_nd.path.mnt = mntget(current->fs->rootmnt); 1769 user_nd.path = current->fs->root;
1777 user_nd.path.dentry = dget(current->fs->root); 1770 path_get(&current->fs->root);
1778 read_unlock(&current->fs->lock); 1771 read_unlock(&current->fs->lock);
1779 down_write(&namespace_sem); 1772 down_write(&namespace_sem);
1780 mutex_lock(&old_nd.path.dentry->d_inode->i_mutex); 1773 mutex_lock(&old_nd.path.dentry->d_inode->i_mutex);