Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

namespaces: move the UTS namespace under UTS_NS option

Currently all the namespace management code is in the kernel/utsname.c file,
so just compile it out and make stubs in the appropriate header.

The init namespace itself is in init/version.c and is in the kernel all the
time.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Kirill Korotaev <dev@sw.ru>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Pavel Emelyanov and committed by
Linus Torvalds
58bfdd6d c5289a69

+30 -1
+21
include/linux/utsname.h
··· 35 35 #include <linux/sched.h> 36 36 #include <linux/kref.h> 37 37 #include <linux/nsproxy.h> 38 + #include <linux/err.h> 38 39 #include <asm/atomic.h> 39 40 40 41 struct uts_namespace { ··· 44 43 }; 45 44 extern struct uts_namespace init_uts_ns; 46 45 46 + #ifdef CONFIG_UTS_NS 47 47 static inline void get_uts_ns(struct uts_namespace *ns) 48 48 { 49 49 kref_get(&ns->kref); ··· 58 56 { 59 57 kref_put(&ns->kref, free_uts_ns); 60 58 } 59 + #else 60 + static inline void get_uts_ns(struct uts_namespace *ns) 61 + { 62 + } 63 + 64 + static inline void put_uts_ns(struct uts_namespace *ns) 65 + { 66 + } 67 + 68 + static inline struct uts_namespace *copy_utsname(unsigned long flags, 69 + struct uts_namespace *ns) 70 + { 71 + if (flags & CLONE_NEWUTS) 72 + return ERR_PTR(-EINVAL); 73 + 74 + return ns; 75 + } 76 + #endif 77 + 61 78 static inline struct new_utsname *utsname(void) 62 79 { 63 80 return &current->nsproxy->uts_ns->name;
+7
init/Kconfig
··· 429 429 or same user id or pid may refer to different tasks when used in 430 430 different namespaces. 431 431 432 + config UTS_NS 433 + bool "UTS namespace" 434 + depends on NAMESPACES 435 + help 436 + In this namespace tasks see different info provided with the 437 + uname() system call 438 + 432 439 config BLK_DEV_INITRD 433 440 bool "Initial RAM filesystem and RAM disk (initramfs/initrd) support" 434 441 depends on BROKEN || !FRV
+2 -1
kernel/Makefile
··· 9 9 rcupdate.o extable.o params.o posix-timers.o \ 10 10 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ 11 11 hrtimer.o rwsem.o nsproxy.o srcu.o \ 12 - utsname.o notifier.o ksysfs.o pm_qos_params.o 12 + notifier.o ksysfs.o pm_qos_params.o 13 13 14 14 obj-$(CONFIG_SYSCTL) += sysctl_check.o 15 15 obj-$(CONFIG_STACKTRACE) += stacktrace.o ··· 33 33 obj-$(CONFIG_UID16) += uid16.o 34 34 obj-$(CONFIG_MODULES) += module.o 35 35 obj-$(CONFIG_KALLSYMS) += kallsyms.o 36 + obj-$(CONFIG_UTS_NS) += utsname.o 36 37 obj-$(CONFIG_PM) += power/ 37 38 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o 38 39 obj-$(CONFIG_KEXEC) += kexec.o