X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=kernel%2Futsname.c;h=160c8c5136bd6a6607ccfae5cfc2e285fe5791c6;hb=aabded9c3aab5160ae2ca3dd1fa0fa37f3d510e4;hp=1824384ecfa3225f11b1a30b0e9f79dea3c46327;hpb=4865ecf1315b450ab3317a745a6678c04d311e40;p=powerpc.git diff --git a/kernel/utsname.c b/kernel/utsname.c index 1824384ecf..160c8c5136 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -14,23 +14,43 @@ #include #include +/* + * Clone a new ns copying an original utsname, setting refcount to 1 + * @old_ns: namespace to clone + * Return NULL on error (failure to kmalloc), new ns otherwise + */ +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns) +{ + struct uts_namespace *ns; + + ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL); + if (ns) { + memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); + kref_init(&ns->kref); + } + return ns; +} + /* * Copy task tsk's utsname namespace, or clone it if flags * specifies CLONE_NEWUTS. In latter case, changes to the * utsname of this process won't be seen by parent, and vice * versa. */ -int copy_utsname(int flags, struct task_struct *tsk) +struct uts_namespace *copy_utsname(int flags, struct uts_namespace *old_ns) { - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns; - int err = 0; - - if (!old_ns) - return 0; + struct uts_namespace *new_ns; + BUG_ON(!old_ns); get_uts_ns(old_ns); - return err; + if (!(flags & CLONE_NEWUTS)) + return old_ns; + + new_ns = clone_uts_ns(old_ns); + + put_uts_ns(old_ns); + return new_ns; } void free_uts_ns(struct kref *kref)