aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@austin.ibm.com>2006-01-24 15:34:47 -0500
committerDave Kleikamp <shaggy@austin.ibm.com>2006-01-24 15:34:47 -0500
commit0a0fc0ddbe732779366ab6b1b879f62195e65967 (patch)
tree7b42490a676cf39ae0691b6859ecf7fd410f229b /fs/namespace.c
parent4d5dbd0945d9e0833dd7964a3d6ee33157f7cc7a (diff)
parent3ee68c4af3fd7228c1be63254b9f884614f9ebb2 (diff)
Merge with /home/shaggy/git/linus-clean/
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 2019899f2ab8..ce97becff461 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/quotaops.h> 17#include <linux/quotaops.h>
18#include <linux/acct.h> 18#include <linux/acct.h>
19#include <linux/capability.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
21#include <linux/namespace.h> 22#include <linux/namespace.h>
@@ -47,6 +48,10 @@ static int hash_mask __read_mostly, hash_bits __read_mostly;
47static kmem_cache_t *mnt_cache; 48static kmem_cache_t *mnt_cache;
48static struct rw_semaphore namespace_sem; 49static struct rw_semaphore namespace_sem;
49 50
51/* /sys/fs */
52decl_subsys(fs, NULL, NULL);
53EXPORT_SYMBOL_GPL(fs_subsys);
54
50static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) 55static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
51{ 56{
52 unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES); 57 unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES);
@@ -355,14 +360,14 @@ static int show_vfsmnt(struct seq_file *m, void *v)
355 { MS_SYNCHRONOUS, ",sync" }, 360 { MS_SYNCHRONOUS, ",sync" },
356 { MS_DIRSYNC, ",dirsync" }, 361 { MS_DIRSYNC, ",dirsync" },
357 { MS_MANDLOCK, ",mand" }, 362 { MS_MANDLOCK, ",mand" },
358 { MS_NOATIME, ",noatime" },
359 { MS_NODIRATIME, ",nodiratime" },
360 { 0, NULL } 363 { 0, NULL }
361 }; 364 };
362 static struct proc_fs_info mnt_info[] = { 365 static struct proc_fs_info mnt_info[] = {
363 { MNT_NOSUID, ",nosuid" }, 366 { MNT_NOSUID, ",nosuid" },
364 { MNT_NODEV, ",nodev" }, 367 { MNT_NODEV, ",nodev" },
365 { MNT_NOEXEC, ",noexec" }, 368 { MNT_NOEXEC, ",noexec" },
369 { MNT_NOATIME, ",noatime" },
370 { MNT_NODIRATIME, ",nodiratime" },
366 { 0, NULL } 371 { 0, NULL }
367 }; 372 };
368 struct proc_fs_info *fs_infop; 373 struct proc_fs_info *fs_infop;
@@ -451,7 +456,7 @@ EXPORT_SYMBOL(may_umount);
451void release_mounts(struct list_head *head) 456void release_mounts(struct list_head *head)
452{ 457{
453 struct vfsmount *mnt; 458 struct vfsmount *mnt;
454 while(!list_empty(head)) { 459 while (!list_empty(head)) {
455 mnt = list_entry(head->next, struct vfsmount, mnt_hash); 460 mnt = list_entry(head->next, struct vfsmount, mnt_hash);
456 list_del_init(&mnt->mnt_hash); 461 list_del_init(&mnt->mnt_hash);
457 if (mnt->mnt_parent != mnt) { 462 if (mnt->mnt_parent != mnt) {
@@ -814,7 +819,7 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
814 return -ENOTDIR; 819 return -ENOTDIR;
815 820
816 err = -ENOENT; 821 err = -ENOENT;
817 down(&nd->dentry->d_inode->i_sem); 822 mutex_lock(&nd->dentry->d_inode->i_mutex);
818 if (IS_DEADDIR(nd->dentry->d_inode)) 823 if (IS_DEADDIR(nd->dentry->d_inode))
819 goto out_unlock; 824 goto out_unlock;
820 825
@@ -826,7 +831,7 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
826 if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry)) 831 if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry))
827 err = attach_recursive_mnt(mnt, nd, NULL); 832 err = attach_recursive_mnt(mnt, nd, NULL);
828out_unlock: 833out_unlock:
829 up(&nd->dentry->d_inode->i_sem); 834 mutex_unlock(&nd->dentry->d_inode->i_mutex);
830 if (!err) 835 if (!err)
831 security_sb_post_addmount(mnt, nd); 836 security_sb_post_addmount(mnt, nd);
832 return err; 837 return err;
@@ -962,7 +967,7 @@ static int do_move_mount(struct nameidata *nd, char *old_name)
962 goto out; 967 goto out;
963 968
964 err = -ENOENT; 969 err = -ENOENT;
965 down(&nd->dentry->d_inode->i_sem); 970 mutex_lock(&nd->dentry->d_inode->i_mutex);
966 if (IS_DEADDIR(nd->dentry->d_inode)) 971 if (IS_DEADDIR(nd->dentry->d_inode))
967 goto out1; 972 goto out1;
968 973
@@ -1004,7 +1009,7 @@ static int do_move_mount(struct nameidata *nd, char *old_name)
1004 list_del_init(&old_nd.mnt->mnt_expire); 1009 list_del_init(&old_nd.mnt->mnt_expire);
1005 spin_unlock(&vfsmount_lock); 1010 spin_unlock(&vfsmount_lock);
1006out1: 1011out1:
1007 up(&nd->dentry->d_inode->i_sem); 1012 mutex_unlock(&nd->dentry->d_inode->i_mutex);
1008out: 1013out:
1009 up_write(&namespace_sem); 1014 up_write(&namespace_sem);
1010 if (!err) 1015 if (!err)
@@ -1286,7 +1291,13 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
1286 mnt_flags |= MNT_NODEV; 1291 mnt_flags |= MNT_NODEV;
1287 if (flags & MS_NOEXEC) 1292 if (flags & MS_NOEXEC)
1288 mnt_flags |= MNT_NOEXEC; 1293 mnt_flags |= MNT_NOEXEC;
1289 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE); 1294 if (flags & MS_NOATIME)
1295 mnt_flags |= MNT_NOATIME;
1296 if (flags & MS_NODIRATIME)
1297 mnt_flags |= MNT_NODIRATIME;
1298
1299 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
1300 MS_NOATIME | MS_NODIRATIME);
1290 1301
1291 /* ... and get the mountpoint */ 1302 /* ... and get the mountpoint */
1292 retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd); 1303 retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
@@ -1526,6 +1537,10 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
1526 * pointed to by put_old must yield the same directory as new_root. No other 1537 * pointed to by put_old must yield the same directory as new_root. No other
1527 * file system may be mounted on put_old. After all, new_root is a mountpoint. 1538 * file system may be mounted on put_old. After all, new_root is a mountpoint.
1528 * 1539 *
1540 * Also, the current root cannot be on the 'rootfs' (initial ramfs) filesystem.
1541 * See Documentation/filesystems/ramfs-rootfs-initramfs.txt for alternatives
1542 * in this situation.
1543 *
1529 * Notes: 1544 * Notes:
1530 * - we don't move root/cwd if they are not at the root (reason: if something 1545 * - we don't move root/cwd if they are not at the root (reason: if something
1531 * cared enough to change them, it's probably wrong to force them elsewhere) 1546 * cared enough to change them, it's probably wrong to force them elsewhere)
@@ -1569,7 +1584,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1569 user_nd.dentry = dget(current->fs->root); 1584 user_nd.dentry = dget(current->fs->root);
1570 read_unlock(&current->fs->lock); 1585 read_unlock(&current->fs->lock);
1571 down_write(&namespace_sem); 1586 down_write(&namespace_sem);
1572 down(&old_nd.dentry->d_inode->i_sem); 1587 mutex_lock(&old_nd.dentry->d_inode->i_mutex);
1573 error = -EINVAL; 1588 error = -EINVAL;
1574 if (IS_MNT_SHARED(old_nd.mnt) || 1589 if (IS_MNT_SHARED(old_nd.mnt) ||
1575 IS_MNT_SHARED(new_nd.mnt->mnt_parent) || 1590 IS_MNT_SHARED(new_nd.mnt->mnt_parent) ||
@@ -1622,7 +1637,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1622 path_release(&root_parent); 1637 path_release(&root_parent);
1623 path_release(&parent_nd); 1638 path_release(&parent_nd);
1624out2: 1639out2:
1625 up(&old_nd.dentry->d_inode->i_sem); 1640 mutex_unlock(&old_nd.dentry->d_inode->i_mutex);
1626 up_write(&namespace_sem); 1641 up_write(&namespace_sem);
1627 path_release(&user_nd); 1642 path_release(&user_nd);
1628 path_release(&old_nd); 1643 path_release(&old_nd);
@@ -1714,6 +1729,7 @@ void __init mnt_init(unsigned long mempages)
1714 i--; 1729 i--;
1715 } while (i); 1730 } while (i);
1716 sysfs_init(); 1731 sysfs_init();
1732 subsystem_register(&fs_subsys);
1717 init_rootfs(); 1733 init_rootfs();
1718 init_mount_tree(); 1734 init_mount_tree();
1719} 1735}