Commit 6b3286ed authored by Kirill Korotaev's avatar Kirill Korotaev Committed by Linus Torvalds

[PATCH] rename struct namespace to struct mnt_namespace

Rename 'struct namespace' to 'struct mnt_namespace' to avoid confusion with
other namespaces being developped for the containers : pid, uts, ipc, etc.
'namespace' variables and attributes are also renamed to 'mnt_ns'
Signed-off-by: default avatarKirill Korotaev <dev@sw.ru>
Signed-off-by: default avatarCedric Le Goater <clg@fr.ibm.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1ec320af
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include "super.h" #include "super.h"
#include "cell.h" #include "cell.h"
#include "volume.h" #include "volume.h"
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/mount.h> #include <linux/mount.h>
...@@ -133,10 +133,10 @@ struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry) ...@@ -133,10 +133,10 @@ struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
static inline int check_mnt(struct vfsmount *mnt) static inline int check_mnt(struct vfsmount *mnt)
{ {
return mnt->mnt_namespace == current->nsproxy->namespace; return mnt->mnt_ns == current->nsproxy->mnt_ns;
} }
static void touch_namespace(struct namespace *ns) static void touch_mnt_namespace(struct mnt_namespace *ns)
{ {
if (ns) { if (ns) {
ns->event = ++event; ns->event = ++event;
...@@ -144,7 +144,7 @@ static void touch_namespace(struct namespace *ns) ...@@ -144,7 +144,7 @@ static void touch_namespace(struct namespace *ns)
} }
} }
static void __touch_namespace(struct namespace *ns) static void __touch_mnt_namespace(struct mnt_namespace *ns)
{ {
if (ns && ns->event != event) { if (ns && ns->event != event) {
ns->event = event; ns->event = event;
...@@ -187,19 +187,19 @@ static void commit_tree(struct vfsmount *mnt) ...@@ -187,19 +187,19 @@ static void commit_tree(struct vfsmount *mnt)
struct vfsmount *parent = mnt->mnt_parent; struct vfsmount *parent = mnt->mnt_parent;
struct vfsmount *m; struct vfsmount *m;
LIST_HEAD(head); LIST_HEAD(head);
struct namespace *n = parent->mnt_namespace; struct mnt_namespace *n = parent->mnt_ns;
BUG_ON(parent == mnt); BUG_ON(parent == mnt);
list_add_tail(&head, &mnt->mnt_list); list_add_tail(&head, &mnt->mnt_list);
list_for_each_entry(m, &head, mnt_list) list_for_each_entry(m, &head, mnt_list)
m->mnt_namespace = n; m->mnt_ns = n;
list_splice(&head, n->list.prev); list_splice(&head, n->list.prev);
list_add_tail(&mnt->mnt_hash, mount_hashtable + list_add_tail(&mnt->mnt_hash, mount_hashtable +
hash(parent, mnt->mnt_mountpoint)); hash(parent, mnt->mnt_mountpoint));
list_add_tail(&mnt->mnt_child, &parent->mnt_mounts); list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
touch_namespace(n); touch_mnt_namespace(n);
} }
static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root)
...@@ -320,7 +320,7 @@ EXPORT_SYMBOL(mnt_unpin); ...@@ -320,7 +320,7 @@ EXPORT_SYMBOL(mnt_unpin);
/* iterator */ /* iterator */
static void *m_start(struct seq_file *m, loff_t *pos) static void *m_start(struct seq_file *m, loff_t *pos)
{ {
struct namespace *n = m->private; struct mnt_namespace *n = m->private;
struct list_head *p; struct list_head *p;
loff_t l = *pos; loff_t l = *pos;
...@@ -333,7 +333,7 @@ static void *m_start(struct seq_file *m, loff_t *pos) ...@@ -333,7 +333,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
static void *m_next(struct seq_file *m, void *v, loff_t *pos) static void *m_next(struct seq_file *m, void *v, loff_t *pos)
{ {
struct namespace *n = m->private; struct mnt_namespace *n = m->private;
struct list_head *p = ((struct vfsmount *)v)->mnt_list.next; struct list_head *p = ((struct vfsmount *)v)->mnt_list.next;
(*pos)++; (*pos)++;
return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list); return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list);
...@@ -526,8 +526,8 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) ...@@ -526,8 +526,8 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
list_for_each_entry(p, kill, mnt_hash) { list_for_each_entry(p, kill, mnt_hash) {
list_del_init(&p->mnt_expire); list_del_init(&p->mnt_expire);
list_del_init(&p->mnt_list); list_del_init(&p->mnt_list);
__touch_namespace(p->mnt_namespace); __touch_mnt_namespace(p->mnt_ns);
p->mnt_namespace = NULL; p->mnt_ns = NULL;
list_del_init(&p->mnt_child); list_del_init(&p->mnt_child);
if (p->mnt_parent != p) if (p->mnt_parent != p)
p->mnt_mountpoint->d_mounted--; p->mnt_mountpoint->d_mounted--;
...@@ -830,7 +830,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt, ...@@ -830,7 +830,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
if (parent_nd) { if (parent_nd) {
detach_mnt(source_mnt, parent_nd); detach_mnt(source_mnt, parent_nd);
attach_mnt(source_mnt, nd); attach_mnt(source_mnt, nd);
touch_namespace(current->nsproxy->namespace); touch_mnt_namespace(current->nsproxy->mnt_ns);
} else { } else {
mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
commit_tree(source_mnt); commit_tree(source_mnt);
...@@ -1145,9 +1145,9 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts, ...@@ -1145,9 +1145,9 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts,
*/ */
if (!propagate_mount_busy(mnt, 2)) { if (!propagate_mount_busy(mnt, 2)) {
/* delete from the namespace */ /* delete from the namespace */
touch_namespace(mnt->mnt_namespace); touch_mnt_namespace(mnt->mnt_ns);
list_del_init(&mnt->mnt_list); list_del_init(&mnt->mnt_list);
mnt->mnt_namespace = NULL; mnt->mnt_ns = NULL;
umount_tree(mnt, 1, umounts); umount_tree(mnt, 1, umounts);
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
} else { } else {
...@@ -1168,7 +1168,7 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts, ...@@ -1168,7 +1168,7 @@ static void expire_mount(struct vfsmount *mnt, struct list_head *mounts,
*/ */
static void expire_mount_list(struct list_head *graveyard, struct list_head *mounts) static void expire_mount_list(struct list_head *graveyard, struct list_head *mounts)
{ {
struct namespace *namespace; struct mnt_namespace *ns;
struct vfsmount *mnt; struct vfsmount *mnt;
while (!list_empty(graveyard)) { while (!list_empty(graveyard)) {
...@@ -1178,10 +1178,10 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou ...@@ -1178,10 +1178,10 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou
/* don't do anything if the namespace is dead - all the /* don't do anything if the namespace is dead - all the
* vfsmounts from it are going away anyway */ * vfsmounts from it are going away anyway */
namespace = mnt->mnt_namespace; ns = mnt->mnt_ns;
if (!namespace || !namespace->root) if (!ns || !ns->root)
continue; continue;
get_namespace(namespace); get_mnt_ns(ns);
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
down_write(&namespace_sem); down_write(&namespace_sem);
...@@ -1189,7 +1189,7 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou ...@@ -1189,7 +1189,7 @@ static void expire_mount_list(struct list_head *graveyard, struct list_head *mou
up_write(&namespace_sem); up_write(&namespace_sem);
release_mounts(&umounts); release_mounts(&umounts);
mntput(mnt); mntput(mnt);
put_namespace(namespace); put_mnt_ns(ns);
spin_lock(&vfsmount_lock); spin_lock(&vfsmount_lock);
} }
} }
...@@ -1439,14 +1439,15 @@ long do_mount(char *dev_name, char *dir_name, char *type_page, ...@@ -1439,14 +1439,15 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
* Allocate a new namespace structure and populate it with contents * Allocate a new namespace structure and populate it with contents
* copied from the namespace of the passed in task structure. * copied from the namespace of the passed in task structure.
*/ */
struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) struct mnt_namespace *dup_mnt_ns(struct task_struct *tsk,
struct fs_struct *fs)
{ {
struct namespace *namespace = tsk->nsproxy->namespace; struct mnt_namespace *mnt_ns = tsk->nsproxy->mnt_ns;
struct namespace *new_ns; struct mnt_namespace *new_ns;
struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL; struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
struct vfsmount *p, *q; struct vfsmount *p, *q;
new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL); new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
if (!new_ns) if (!new_ns)
return NULL; return NULL;
...@@ -1457,7 +1458,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) ...@@ -1457,7 +1458,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
down_write(&namespace_sem); down_write(&namespace_sem);
/* First pass: copy the tree topology */ /* First pass: copy the tree topology */
new_ns->root = copy_tree(namespace->root, namespace->root->mnt_root, new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root,
CL_COPY_ALL | CL_EXPIRE); CL_COPY_ALL | CL_EXPIRE);
if (!new_ns->root) { if (!new_ns->root) {
up_write(&namespace_sem); up_write(&namespace_sem);
...@@ -1473,10 +1474,10 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) ...@@ -1473,10 +1474,10 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
* as belonging to new namespace. We have already acquired a private * as belonging to new namespace. We have already acquired a private
* fs_struct, so tsk->fs->lock is not needed. * fs_struct, so tsk->fs->lock is not needed.
*/ */
p = namespace->root; p = mnt_ns->root;
q = new_ns->root; q = new_ns->root;
while (p) { while (p) {
q->mnt_namespace = new_ns; q->mnt_ns = new_ns;
if (fs) { if (fs) {
if (p == fs->rootmnt) { if (p == fs->rootmnt) {
rootmnt = p; rootmnt = p;
...@@ -1491,7 +1492,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) ...@@ -1491,7 +1492,7 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
fs->altrootmnt = mntget(q); fs->altrootmnt = mntget(q);
} }
} }
p = next_mnt(p, namespace->root); p = next_mnt(p, mnt_ns->root);
q = next_mnt(q, new_ns->root); q = next_mnt(q, new_ns->root);
} }
up_write(&namespace_sem); up_write(&namespace_sem);
...@@ -1506,16 +1507,16 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs) ...@@ -1506,16 +1507,16 @@ struct namespace *dup_namespace(struct task_struct *tsk, struct fs_struct *fs)
return new_ns; return new_ns;
} }
int copy_namespace(int flags, struct task_struct *tsk) int copy_mnt_ns(int flags, struct task_struct *tsk)
{ {
struct namespace *namespace = tsk->nsproxy->namespace; struct mnt_namespace *ns = tsk->nsproxy->mnt_ns;
struct namespace *new_ns; struct mnt_namespace *new_ns;
int err = 0; int err = 0;
if (!namespace) if (!ns)
return 0; return 0;
get_namespace(namespace); get_mnt_ns(ns);
if (!(flags & CLONE_NEWNS)) if (!(flags & CLONE_NEWNS))
return 0; return 0;
...@@ -1525,16 +1526,16 @@ int copy_namespace(int flags, struct task_struct *tsk) ...@@ -1525,16 +1526,16 @@ int copy_namespace(int flags, struct task_struct *tsk)
goto out; goto out;
} }
new_ns = dup_namespace(tsk, tsk->fs); new_ns = dup_mnt_ns(tsk, tsk->fs);
if (!new_ns) { if (!new_ns) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
tsk->nsproxy->namespace = new_ns; tsk->nsproxy->mnt_ns = new_ns;
out: out:
put_namespace(namespace); put_mnt_ns(ns);
return err; return err;
} }
...@@ -1754,7 +1755,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root, ...@@ -1754,7 +1755,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
detach_mnt(user_nd.mnt, &root_parent); detach_mnt(user_nd.mnt, &root_parent);
attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */ attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */
attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */ attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */
touch_namespace(current->nsproxy->namespace); touch_mnt_namespace(current->nsproxy->mnt_ns);
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
chroot_fs_refs(&user_nd, &new_nd); chroot_fs_refs(&user_nd, &new_nd);
security_sb_post_pivotroot(&user_nd, &new_nd); security_sb_post_pivotroot(&user_nd, &new_nd);
...@@ -1779,27 +1780,27 @@ asmlinkage long sys_pivot_root(const char __user * new_root, ...@@ -1779,27 +1780,27 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
static void __init init_mount_tree(void) static void __init init_mount_tree(void)
{ {
struct vfsmount *mnt; struct vfsmount *mnt;
struct namespace *namespace; struct mnt_namespace *ns;
mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
if (IS_ERR(mnt)) if (IS_ERR(mnt))
panic("Can't create rootfs"); panic("Can't create rootfs");
namespace = kmalloc(sizeof(*namespace), GFP_KERNEL); ns = kmalloc(sizeof(*ns), GFP_KERNEL);
if (!namespace) if (!ns)
panic("Can't allocate initial namespace"); panic("Can't allocate initial namespace");
atomic_set(&namespace->count, 1); atomic_set(&ns->count, 1);
INIT_LIST_HEAD(&namespace->list); INIT_LIST_HEAD(&ns->list);
init_waitqueue_head(&namespace->poll); init_waitqueue_head(&ns->poll);
namespace->event = 0; ns->event = 0;
list_add(&mnt->mnt_list, &namespace->list); list_add(&mnt->mnt_list, &ns->list);
namespace->root = mnt; ns->root = mnt;
mnt->mnt_namespace = namespace; mnt->mnt_ns = ns;
init_task.nsproxy->namespace = namespace; init_task.nsproxy->mnt_ns = ns;
get_namespace(namespace); get_mnt_ns(ns);
set_fs_pwd(current->fs, namespace->root, namespace->root->mnt_root); set_fs_pwd(current->fs, ns->root, ns->root->mnt_root);
set_fs_root(current->fs, namespace->root, namespace->root->mnt_root); set_fs_root(current->fs, ns->root, ns->root->mnt_root);
} }
void __init mnt_init(unsigned long mempages) void __init mnt_init(unsigned long mempages)
...@@ -1860,11 +1861,11 @@ void __init mnt_init(unsigned long mempages) ...@@ -1860,11 +1861,11 @@ void __init mnt_init(unsigned long mempages)
init_mount_tree(); init_mount_tree();
} }
void __put_namespace(struct namespace *namespace) void __put_mnt_ns(struct mnt_namespace *ns)
{ {
struct vfsmount *root = namespace->root; struct vfsmount *root = ns->root;
LIST_HEAD(umount_list); LIST_HEAD(umount_list);
namespace->root = NULL; ns->root = NULL;
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
down_write(&namespace_sem); down_write(&namespace_sem);
spin_lock(&vfsmount_lock); spin_lock(&vfsmount_lock);
...@@ -1872,5 +1873,5 @@ void __put_namespace(struct namespace *namespace) ...@@ -1872,5 +1873,5 @@ void __put_namespace(struct namespace *namespace)
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
release_mounts(&umount_list); release_mounts(&umount_list);
kfree(namespace); kfree(ns);
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <linux/nfs_idmap.h> #include <linux/nfs_idmap.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/security.h> #include <linux/security.h>
#include <asm/system.h> #include <asm/system.h>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Author : Ram Pai (linuxram@us.ibm.com) * Author : Ram Pai (linuxram@us.ibm.com)
* *
*/ */
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/fs.h> #include <linux/fs.h>
#include "pnode.h" #include "pnode.h"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED) #define IS_MNT_SHARED(mnt) (mnt->mnt_flags & MNT_SHARED)
#define IS_MNT_SLAVE(mnt) (mnt->mnt_master) #define IS_MNT_SLAVE(mnt) (mnt->mnt_master)
#define IS_MNT_NEW(mnt) (!mnt->mnt_namespace) #define IS_MNT_NEW(mnt) (!mnt->mnt_ns)
#define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED) #define CLEAR_MNT_SHARED(mnt) (mnt->mnt_flags &= ~MNT_SHARED)
#define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE) #define IS_MNT_UNBINDABLE(mnt) (mnt->mnt_flags & MNT_UNBINDABLE)
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
...@@ -365,33 +365,33 @@ struct proc_mounts { ...@@ -365,33 +365,33 @@ struct proc_mounts {
static int mounts_open(struct inode *inode, struct file *file) static int mounts_open(struct inode *inode, struct file *file)
{ {
struct task_struct *task = get_proc_task(inode); struct task_struct *task = get_proc_task(inode);
struct namespace *namespace = NULL; struct mnt_namespace *ns = NULL;
struct proc_mounts *p; struct proc_mounts *p;
int ret = -EINVAL; int ret = -EINVAL;
if (task) { if (task) {
task_lock(task); task_lock(task);
namespace = task->nsproxy->namespace; ns = task->nsproxy->mnt_ns;
if (namespace) if (ns)
get_namespace(namespace); get_mnt_ns(ns);
task_unlock(task); task_unlock(task);
put_task_struct(task); put_task_struct(task);
} }
if (namespace) { if (ns) {
ret = -ENOMEM; ret = -ENOMEM;
p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL); p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
if (p) { if (p) {
file->private_data = &p->m; file->private_data = &p->m;
ret = seq_open(file, &mounts_op); ret = seq_open(file, &mounts_op);
if (!ret) { if (!ret) {
p->m.private = namespace; p->m.private = ns;
p->event = namespace->event; p->event = ns->event;
return 0; return 0;
} }
kfree(p); kfree(p);
} }
put_namespace(namespace); put_mnt_ns(ns);
} }
return ret; return ret;
} }
...@@ -399,15 +399,15 @@ static int mounts_open(struct inode *inode, struct file *file) ...@@ -399,15 +399,15 @@ static int mounts_open(struct inode *inode, struct file *file)
static int mounts_release(struct inode *inode, struct file *file) static int mounts_release(struct inode *inode, struct file *file)
{ {
struct seq_file *m = file->private_data; struct seq_file *m = file->private_data;
struct namespace *namespace = m->private; struct mnt_namespace *ns = m->private;
put_namespace(namespace); put_mnt_ns(ns);
return seq_release(inode, file); return seq_release(inode, file);
} }
static unsigned mounts_poll(struct file *file, poll_table *wait) static unsigned mounts_poll(struct file *file, poll_table *wait)
{ {
struct proc_mounts *p = file->private_data; struct proc_mounts *p = file->private_data;
struct namespace *ns = p->m.private; struct mnt_namespace *ns = p->m.private;
unsigned res = 0; unsigned res = 0;
poll_wait(file, &ns->poll, wait); poll_wait(file, &ns->poll, wait);
...@@ -437,21 +437,21 @@ static int mountstats_open(struct inode *inode, struct file *file) ...@@ -437,21 +437,21 @@ static int mountstats_open(struct inode *inode, struct file *file)
if (!ret) { if (!ret) {
struct seq_file *m = file->private_data; struct seq_file *m = file->private_data;
struct namespace *namespace = NULL; struct mnt_namespace *mnt_ns = NULL;
struct task_struct *task = get_proc_task(inode); struct task_struct *task = get_proc_task(inode);
if (task) { if (task) {
task_lock(task); task_lock(task);
if (task->nsproxy) if (task->nsproxy)
namespace = task->nsproxy->namespace; mnt_ns = task->nsproxy->mnt_ns;
if (namespace) if (mnt_ns)
get_namespace(namespace); get_mnt_ns(mnt_ns);
task_unlock(task); task_unlock(task);
put_task_struct(task); put_task_struct(task);
} }
if (namespace) if (mnt_ns)
m->private = namespace; m->private = mnt_ns;
else { else {
seq_release(inode, file); seq_release(inode, file);
ret = -EINVAL; ret = -EINVAL;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/quotaops.h> #include <linux/quotaops.h>
......
...@@ -76,7 +76,7 @@ extern struct nsproxy init_nsproxy; ...@@ -76,7 +76,7 @@ extern struct nsproxy init_nsproxy;
.count = ATOMIC_INIT(1), \ .count = ATOMIC_INIT(1), \
.nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \ .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \
.uts_ns = &init_uts_ns, \ .uts_ns = &init_uts_ns, \
.namespace = NULL, \ .mnt_ns = NULL, \
INIT_IPC_NS(ipc_ns) \ INIT_IPC_NS(ipc_ns) \
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
struct namespace { struct mnt_namespace {
atomic_t count; atomic_t count;
struct vfsmount * root; struct vfsmount * root;
struct list_head list; struct list_head list;
...@@ -14,28 +14,28 @@ struct namespace { ...@@ -14,28 +14,28 @@ struct namespace {
int event; int event;
}; };
extern int copy_namespace(int, struct task_struct *); extern int copy_mnt_ns(int, struct task_struct *);
extern void __put_namespace(struct namespace *namespace); extern void __put_mnt_ns(struct mnt_namespace *ns);
extern struct namespace *dup_namespace(struct task_struct *, struct fs_struct *); extern struct mnt_namespace *dup_mnt_ns(struct task_struct *,
struct fs_struct *);
static inline void put_namespace(struct namespace *namespace) static inline void put_mnt_ns(struct mnt_namespace *ns)
{ {
if (atomic_dec_and_lock(&namespace->count, &vfsmount_lock)) if (atomic_dec_and_lock(&ns->count, &vfsmount_lock))
/* releases vfsmount_lock */ /* releases vfsmount_lock */
__put_namespace(namespace); __put_mnt_ns(ns);
} }
static inline void exit_namespace(struct task_struct *p) static inline void exit_mnt_ns(struct task_struct *p)
{ {
struct namespace *namespace = p->nsproxy->namespace; struct mnt_namespace *ns = p->nsproxy->mnt_ns;
if (namespace) { if (ns)
put_namespace(namespace); put_mnt_ns(ns);
}
} }
static inline void get_namespace(struct namespace *namespace) static inline void get_mnt_ns(struct mnt_namespace *ns)
{ {
atomic_inc(&namespace->count); atomic_inc(&ns->count);
} }
#endif #endif
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
struct super_block; struct super_block;
struct vfsmount; struct vfsmount;
struct dentry; struct dentry;
struct namespace; struct mnt_namespace;
#define MNT_NOSUID 0x01 #define MNT_NOSUID 0x01
#define MNT_NODEV 0x02 #define MNT_NODEV 0x02
...@@ -52,7 +52,7 @@ struct vfsmount { ...@@ -52,7 +52,7 @@ struct vfsmount {
struct list_head mnt_slave_list;/* list of slave mounts */ struct list_head mnt_slave_list;/* list of slave mounts */
struct list_head mnt_slave; /* slave list entry */ struct list_head mnt_slave; /* slave list entry */
struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
struct namespace *mnt_namespace; /* containing namespace */ struct mnt_namespace *mnt_ns; /* containing namespace */
int mnt_pinned; int mnt_pinned;
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/sched.h> #include <linux/sched.h>
struct namespace; struct mnt_namespace;
struct uts_namespace; struct uts_namespace;
struct ipc_namespace; struct ipc_namespace;
...@@ -25,7 +25,7 @@ struct nsproxy { ...@@ -25,7 +25,7 @@ struct nsproxy {
spinlock_t nslock; spinlock_t nslock;
struct uts_namespace *uts_ns; struct uts_namespace *uts_ns;
struct ipc_namespace *ipc_ns; struct ipc_namespace *ipc_ns;
struct namespace *namespace; struct mnt_namespace *mnt_ns;
}; };
extern struct nsproxy init_nsproxy; extern struct nsproxy init_nsproxy;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/key.h> #include <linux/key.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/cpu.h> #include <linux/cpu.h>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/mempolicy.h> #include <linux/mempolicy.h>
#include <linux/sem.h> #include <linux/sem.h>
...@@ -1525,17 +1525,18 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp) ...@@ -1525,17 +1525,18 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
} }
/* /*
* Unshare the namespace structure if it is being shared * Unshare the mnt_namespace structure if it is being shared
*/ */
static int unshare_namespace(unsigned long unshare_flags, struct namespace **new_nsp, struct fs_struct *new_fs) static int unshare_mnt_namespace(unsigned long unshare_flags,
struct mnt_namespace **new_nsp, struct fs_struct *new_fs)
{ {
struct namespace *ns = current->nsproxy->namespace; struct mnt_namespace *ns = current->nsproxy->mnt_ns;
if ((unshare_flags & CLONE_NEWNS) && ns) { if ((unshare_flags & CLONE_NEWNS) && ns) {
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
*new_nsp = dup_namespace(current, new_fs ? new_fs : current->fs); *new_nsp = dup_mnt_ns(current, new_fs ? new_fs : current->fs);
if (!*new_nsp) if (!*new_nsp)
return -ENOMEM; return -ENOMEM;
} }
...@@ -1623,7 +1624,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) ...@@ -1623,7 +1624,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
{ {
int err = 0; int err = 0;
struct fs_struct *fs, *new_fs = NULL; struct fs_struct *fs, *new_fs = NULL;
struct namespace *ns, *new_ns = NULL; struct mnt_namespace *ns, *new_ns = NULL;
struct sighand_struct *new_sigh = NULL; struct sighand_struct *new_sigh = NULL;
struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL; struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;
struct files_struct *fd, *new_fd = NULL; struct files_struct *fd, *new_fd = NULL;
...@@ -1645,7 +1646,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) ...@@ -1645,7 +1646,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
goto bad_unshare_out; goto bad_unshare_out;
if ((err = unshare_fs(unshare_flags, &new_fs))) if ((err = unshare_fs(unshare_flags, &new_fs)))
goto bad_unshare_cleanup_thread; goto bad_unshare_cleanup_thread;
if ((err = unshare_namespace(unshare_flags, &new_ns, new_fs))) if ((err = unshare_mnt_namespace(unshare_flags, &new_ns, new_fs)))
goto bad_unshare_cleanup_fs; goto bad_unshare_cleanup_fs;
if ((err = unshare_sighand(unshare_flags, &new_sigh))) if ((err = unshare_sighand(unshare_flags, &new_sigh)))
goto bad_unshare_cleanup_ns; goto bad_unshare_cleanup_ns;
...@@ -1686,8 +1687,8 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) ...@@ -1686,8 +1687,8 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
} }
if (new_ns) { if (new_ns) {
ns = current->nsproxy->namespace; ns = current->nsproxy->mnt_ns;
current->nsproxy->namespace = new_ns; current->nsproxy->mnt_ns = new_ns;
new_ns = ns; new_ns = ns;
} }
...@@ -1748,7 +1749,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) ...@@ -1748,7 +1749,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
bad_unshare_cleanup_ns: bad_unshare_cleanup_ns:
if (new_ns) if (new_ns)
put_namespace(new_ns); put_mnt_ns(new_ns);
bad_unshare_cleanup_fs: bad_unshare_cleanup_fs:
if (new_fs) if (new_fs)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <linux/version.h> #include <linux/version.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
#include <linux/init_task.h> #include <linux/init_task.h>
#include <linux/namespace.h> #include <linux/mnt_namespace.h>
#include <linux/utsname.h> #include <linux/utsname.h>
struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy); struct nsproxy init_nsproxy = INIT_NSPROXY(init_nsproxy);
...@@ -60,8 +60,8 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig) ...@@ -60,8 +60,8 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig)
struct nsproxy *ns = clone_namespaces(orig); struct nsproxy *ns = clone_namespaces(orig);
if (ns) { if (ns) {
if (ns->namespace) if (ns->mnt_ns)
get_namespace(ns->namespace); get_mnt_ns(ns->mnt_ns);
if (ns->uts_ns) if (ns->uts_ns)
get_uts_ns(ns->uts_ns); get_uts_ns(ns->uts_ns);
if (ns->ipc_ns) if (ns->ipc_ns)
...@@ -97,7 +97,7 @@ int copy_namespaces(int flags, struct task_struct *tsk) ...@@ -97,7 +97,7 @@ int copy_namespaces(int flags, struct task_struct *tsk)
tsk->nsproxy = new_ns; tsk->nsproxy = new_ns;
err = copy_namespace(flags, tsk); err = copy_mnt_ns(flags, tsk);
if (err) if (err)
goto out_ns; goto out_ns;
...@@ -117,8 +117,8 @@ int copy_namespaces(int flags, struct task_struct *tsk) ...@@ -117,8 +117,8 @@ int copy_namespaces(int flags, struct task_struct *tsk)
if (new_ns->uts_ns) if (new_ns->uts_ns)
put_uts_ns(new_ns->uts_ns); put_uts_ns(new_ns->uts_ns);
out_uts: out_uts:
if (new_ns->namespace) if (new_ns->mnt_ns)
put_namespace(new_ns->namespace); put_mnt_ns(new_ns->mnt_ns);
out_ns: out_ns:
tsk->nsproxy = old_ns; tsk->nsproxy = old_ns;
kfree(new_ns); kfree(new_ns);
...@@ -127,8 +127,8 @@ int copy_namespaces(int flags, struct task_struct *tsk) ...@@ -127,8 +127,8 @@ int copy_namespaces(int flags, struct task_struct *tsk)
void free_nsproxy(struct nsproxy *ns) void free_nsproxy(struct nsproxy *ns)
{ {
if (ns->namespace) if (ns->mnt_ns)
put_namespace(ns->namespace); put_mnt_ns(ns->mnt_ns);
if (ns->uts_ns) if (ns->uts_ns)
put_uts_ns(ns->uts_ns); put_uts_ns(ns->uts_ns);
if (ns->ipc_ns) if (ns->ipc_ns)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment