aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2006-10-02 05:18:06 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 10:57:20 -0400
commitab516013ad9ca47f1d3a936fa81303bfbf734d52 (patch)
tree643ea9c4c3d28958cb42dd87b1856f74edd22b11 /kernel/fork.c
parentb1ba4ddde0cf67991d89f039365eaaeda61aa027 (diff)
[PATCH] namespaces: add nsproxy
This patch adds a nsproxy structure to the task struct. Later patches will move the fs namespace pointer into this structure, and introduce a new utsname namespace into the nsproxy. The vserver and openvz functionality, then, would be implemented in large part by virtualizing/isolating more and more resources into namespaces, each contained in the nsproxy. [akpm@osdl.org: build fix] Signed-off-by: Serge Hallyn <serue@us.ibm.com> Cc: Kirill Korotaev <dev@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Andrey Savochkin <saw@sw.ru> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 89f666491d1f..c9e660ae47aa 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -27,6 +27,7 @@
27#include <linux/binfmts.h> 27#include <linux/binfmts.h>
28#include <linux/mman.h> 28#include <linux/mman.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/nsproxy.h>
30#include <linux/capability.h> 31#include <linux/capability.h>
31#include <linux/cpu.h> 32#include <linux/cpu.h>
32#include <linux/cpuset.h> 33#include <linux/cpuset.h>
@@ -1116,8 +1117,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1116 goto bad_fork_cleanup_signal; 1117 goto bad_fork_cleanup_signal;
1117 if ((retval = copy_keys(clone_flags, p))) 1118 if ((retval = copy_keys(clone_flags, p)))
1118 goto bad_fork_cleanup_mm; 1119 goto bad_fork_cleanup_mm;
1119 if ((retval = copy_namespace(clone_flags, p))) 1120 if ((retval = copy_namespaces(clone_flags, p)))
1120 goto bad_fork_cleanup_keys; 1121 goto bad_fork_cleanup_keys;
1122 if ((retval = copy_namespace(clone_flags, p)))
1123 goto bad_fork_cleanup_namespaces;
1121 retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); 1124 retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
1122 if (retval) 1125 if (retval)
1123 goto bad_fork_cleanup_namespace; 1126 goto bad_fork_cleanup_namespace;
@@ -1262,6 +1265,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1262 1265
1263bad_fork_cleanup_namespace: 1266bad_fork_cleanup_namespace:
1264 exit_namespace(p); 1267 exit_namespace(p);
1268bad_fork_cleanup_namespaces:
1269 exit_task_namespaces(p);
1265bad_fork_cleanup_keys: 1270bad_fork_cleanup_keys:
1266 exit_keys(p); 1271 exit_keys(p);
1267bad_fork_cleanup_mm: 1272bad_fork_cleanup_mm:
@@ -1606,6 +1611,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
1606 struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL; 1611 struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;
1607 struct files_struct *fd, *new_fd = NULL; 1612 struct files_struct *fd, *new_fd = NULL;
1608 struct sem_undo_list *new_ulist = NULL; 1613 struct sem_undo_list *new_ulist = NULL;
1614 struct nsproxy *new_nsproxy, *old_nsproxy;
1609 1615
1610 check_unshare_flags(&unshare_flags); 1616 check_unshare_flags(&unshare_flags);
1611 1617
@@ -1632,7 +1638,15 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
1632 1638
1633 if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist) { 1639 if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist) {
1634 1640
1641 old_nsproxy = current->nsproxy;
1642 new_nsproxy = dup_namespaces(old_nsproxy);
1643 if (!new_nsproxy) {
1644 err = -ENOMEM;
1645 goto bad_unshare_cleanup_semundo;
1646 }
1647
1635 task_lock(current); 1648 task_lock(current);
1649 current->nsproxy = new_nsproxy;
1636 1650
1637 if (new_fs) { 1651 if (new_fs) {
1638 fs = current->fs; 1652 fs = current->fs;
@@ -1668,8 +1682,10 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
1668 } 1682 }
1669 1683
1670 task_unlock(current); 1684 task_unlock(current);
1685 put_nsproxy(old_nsproxy);
1671 } 1686 }
1672 1687
1688bad_unshare_cleanup_semundo:
1673bad_unshare_cleanup_fd: 1689bad_unshare_cleanup_fd:
1674 if (new_fd) 1690 if (new_fd)
1675 put_files_struct(new_fd); 1691 put_files_struct(new_fd);