utsname.c (020abf03cd659388f94cb328e1e1df0656e0d7ff) utsname.c (34482e89a5218f0f9317abf1cfba3bb38b5c29dd)
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Author: Serge Hallyn <serue@us.ibm.com>
5 *
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.
10 */
11
12#include <linux/module.h>
13#include <linux/uts.h>
14#include <linux/utsname.h>
15#include <linux/err.h>
16#include <linux/slab.h>
17#include <linux/user_namespace.h>
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Author: Serge Hallyn <serue@us.ibm.com>
5 *
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.
10 */
11
12#include <linux/module.h>
13#include <linux/uts.h>
14#include <linux/utsname.h>
15#include <linux/err.h>
16#include <linux/slab.h>
17#include <linux/user_namespace.h>
18#include <linux/proc_fs.h>
18
19static struct uts_namespace *create_uts_ns(void)
20{
21 struct uts_namespace *uts_ns;
22
23 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
24 if (uts_ns)
25 kref_init(&uts_ns->kref);

--- 48 unchanged lines hidden (view full) ---

74void free_uts_ns(struct kref *kref)
75{
76 struct uts_namespace *ns;
77
78 ns = container_of(kref, struct uts_namespace, kref);
79 put_user_ns(ns->user_ns);
80 kfree(ns);
81}
19
20static struct uts_namespace *create_uts_ns(void)
21{
22 struct uts_namespace *uts_ns;
23
24 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
25 if (uts_ns)
26 kref_init(&uts_ns->kref);

--- 48 unchanged lines hidden (view full) ---

75void free_uts_ns(struct kref *kref)
76{
77 struct uts_namespace *ns;
78
79 ns = container_of(kref, struct uts_namespace, kref);
80 put_user_ns(ns->user_ns);
81 kfree(ns);
82}
83
84static void *utsns_get(struct task_struct *task)
85{
86 struct uts_namespace *ns = NULL;
87 struct nsproxy *nsproxy;
88
89 rcu_read_lock();
90 nsproxy = task_nsproxy(task);
91 if (nsproxy) {
92 ns = nsproxy->uts_ns;
93 get_uts_ns(ns);
94 }
95 rcu_read_unlock();
96
97 return ns;
98}
99
100static void utsns_put(void *ns)
101{
102 put_uts_ns(ns);
103}
104
105static int utsns_install(struct nsproxy *nsproxy, void *ns)
106{
107 get_uts_ns(ns);
108 put_uts_ns(nsproxy->uts_ns);
109 nsproxy->uts_ns = ns;
110 return 0;
111}
112
113const struct proc_ns_operations utsns_operations = {
114 .name = "uts",
115 .type = CLONE_NEWUTS,
116 .get = utsns_get,
117 .put = utsns_put,
118 .install = utsns_install,
119};
120