sh: remove PTRACE_O_TRACESYSGOOD from asm/ptrace.h
[linux-2.6/mini2440.git] / kernel / utsname.c
blob816d7b24fa031af51b08d9108366d21626e3d38e
1 /*
2 * Copyright (C) 2004 IBM Corporation
4 * Author: Serge Hallyn <serue@us.ibm.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the
9 * License.
12 #include <linux/module.h>
13 #include <linux/uts.h>
14 #include <linux/utsname.h>
15 #include <linux/version.h>
16 #include <linux/err.h>
19 * Clone a new ns copying an original utsname, setting refcount to 1
20 * @old_ns: namespace to clone
21 * Return NULL on error (failure to kmalloc), new ns otherwise
23 static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns)
25 struct uts_namespace *ns;
27 ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
28 if (!ns)
29 return ERR_PTR(-ENOMEM);
31 down_read(&uts_sem);
32 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
33 up_read(&uts_sem);
34 kref_init(&ns->kref);
35 return ns;
39 * Copy task tsk's utsname namespace, or clone it if flags
40 * specifies CLONE_NEWUTS. In latter case, changes to the
41 * utsname of this process won't be seen by parent, and vice
42 * versa.
44 struct uts_namespace *copy_utsname(unsigned long flags, struct uts_namespace *old_ns)
46 struct uts_namespace *new_ns;
48 BUG_ON(!old_ns);
49 get_uts_ns(old_ns);
51 if (!(flags & CLONE_NEWUTS))
52 return old_ns;
54 new_ns = clone_uts_ns(old_ns);
56 put_uts_ns(old_ns);
57 return new_ns;
60 void free_uts_ns(struct kref *kref)
62 struct uts_namespace *ns;
64 ns = container_of(kref, struct uts_namespace, kref);
65 kfree(ns);