diff options
Diffstat (limited to 'kernel/user_namespace.c')
-rw-r--r-- | kernel/user_namespace.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c new file mode 100644 index 000000000000..3d7964209774 --- /dev/null +++ b/kernel/user_namespace.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or | ||
3 | * modify it under the terms of the GNU General Public License as | ||
4 | * published by the Free Software Foundation, version 2 of the | ||
5 | * License. | ||
6 | */ | ||
7 | |||
8 | #include <linux/module.h> | ||
9 | #include <linux/version.h> | ||
10 | #include <linux/nsproxy.h> | ||
11 | #include <linux/user_namespace.h> | ||
12 | |||
13 | struct user_namespace init_user_ns = { | ||
14 | .kref = { | ||
15 | .refcount = ATOMIC_INIT(2), | ||
16 | }, | ||
17 | .root_user = &root_user, | ||
18 | }; | ||
19 | |||
20 | EXPORT_SYMBOL_GPL(init_user_ns); | ||
21 | |||
22 | #ifdef CONFIG_USER_NS | ||
23 | |||
24 | struct user_namespace * copy_user_ns(int flags, struct user_namespace *old_ns) | ||
25 | { | ||
26 | struct user_namespace *new_ns; | ||
27 | |||
28 | BUG_ON(!old_ns); | ||
29 | get_user_ns(old_ns); | ||
30 | |||
31 | new_ns = old_ns; | ||
32 | return new_ns; | ||
33 | } | ||
34 | |||
35 | void free_user_ns(struct kref *kref) | ||
36 | { | ||
37 | struct user_namespace *ns; | ||
38 | |||
39 | ns = container_of(kref, struct user_namespace, kref); | ||
40 | kfree(ns); | ||
41 | } | ||
42 | |||
43 | #endif /* CONFIG_USER_NS */ | ||