Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 153832
b: refs/heads/master
c: cf8d2c1
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Linus Torvalds committed Jun 23, 2009
1 parent 1d9cf0b commit 150833e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 616511d039af402670de8500d0e24495113a9cab
refs/heads/master: cf8d2c11cb77f129675478792122f50827e5b0ae
45 changes: 37 additions & 8 deletions trunk/fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,21 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
return retval;
}

static struct mnt_namespace *alloc_mnt_ns(void)
{
struct mnt_namespace *new_ns;

new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
if (!new_ns)
return ERR_PTR(-ENOMEM);
atomic_set(&new_ns->count, 1);
new_ns->root = NULL;
INIT_LIST_HEAD(&new_ns->list);
init_waitqueue_head(&new_ns->poll);
new_ns->event = 0;
return new_ns;
}

/*
* Allocate a new namespace structure and populate it with contents
* copied from the namespace of the passed in task structure.
Expand All @@ -1948,14 +1963,9 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
struct vfsmount *rootmnt = NULL, *pwdmnt = NULL;
struct vfsmount *p, *q;

new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
if (!new_ns)
return ERR_PTR(-ENOMEM);

atomic_set(&new_ns->count, 1);
INIT_LIST_HEAD(&new_ns->list);
init_waitqueue_head(&new_ns->poll);
new_ns->event = 0;
new_ns = alloc_mnt_ns();
if (IS_ERR(new_ns))
return new_ns;

down_write(&namespace_sem);
/* First pass: copy the tree topology */
Expand Down Expand Up @@ -2019,6 +2029,24 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
return new_ns;
}

/**
* create_mnt_ns - creates a private namespace and adds a root filesystem
* @mnt: pointer to the new root filesystem mountpoint
*/
struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
{
struct mnt_namespace *new_ns;

new_ns = alloc_mnt_ns();
if (!IS_ERR(new_ns)) {
mnt->mnt_ns = new_ns;
new_ns->root = mnt;
list_add(&new_ns->list, &new_ns->root->mnt_list);
}
return new_ns;
}
EXPORT_SYMBOL(create_mnt_ns);

SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
char __user *, type, unsigned long, flags, void __user *, data)
{
Expand Down Expand Up @@ -2264,3 +2292,4 @@ void put_mnt_ns(struct mnt_namespace *ns)
release_mounts(&umount_list);
kfree(ns);
}
EXPORT_SYMBOL(put_mnt_ns);
1 change: 1 addition & 0 deletions trunk/include/linux/mnt_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct proc_mounts {

struct fs_struct;

extern struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt);
extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *,
struct fs_struct *);
extern void put_mnt_ns(struct mnt_namespace *ns);
Expand Down

0 comments on commit 150833e

Please sign in to comment.