lkml.org 
[lkml]   [2020]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 19/23] uts: Add uts namespaces into ns_idr
From
Date
Now they are exposed in /proc/namespace/ directory.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
kernel/utsname.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/kernel/utsname.c b/kernel/utsname.c
index aebf4df5f592..883855ca16cd 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -70,8 +70,16 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
ns->user_ns = get_user_ns(user_ns);
up_read(&uts_sem);
+
+ err = ns_idr_register(&ns->ns);
+ if (err)
+ goto fail_put;
+
return ns;

+fail_put:
+ put_user_ns(user_ns);
+ ns_free_inum(&ns->ns);
fail_free:
kmem_cache_free(uts_ns_cache, ns);
fail_dec:
@@ -113,6 +121,7 @@ static void free_uts_ns_rcu(struct rcu_head *head)

void free_uts_ns(struct uts_namespace *ns)
{
+ ns_idr_unregister(&ns->ns);
dec_uts_namespaces(ns->ucounts);
put_user_ns(ns->user_ns);
ns_free_inum(&ns->ns);
@@ -182,4 +191,5 @@ void __init uts_ns_init(void)
offsetof(struct uts_namespace, name),
sizeof_field(struct uts_namespace, name),
NULL);
+ WARN_ON(ns_idr_register(&init_uts_ns.ns) < 0);
}

\
 
 \ /
  Last update: 2020-07-30 14:01    [W:0.315 / U:13.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site