[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH RFC 5/8] utsns: introduce utsns_get_inum()



This allows other parts of the kernel to have access to userspace
visible namespace identification.

Signed-off-by: Aristeu Rozanski <arozansk redhat com>
---
 include/linux/utsname.h |    1 +
 kernel/utsname.c        |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index 239e277..eed8ca8 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -36,6 +36,7 @@ static inline void get_uts_ns(struct uts_namespace *ns)
 extern struct uts_namespace *copy_utsname(unsigned long flags,
 	struct user_namespace *user_ns, struct uts_namespace *old_ns);
 extern void free_uts_ns(struct kref *kref);
+extern unsigned int utsns_get_inum(struct task_struct *tsk);
 
 static inline void put_uts_ns(struct uts_namespace *ns)
 {
diff --git a/kernel/utsname.c b/kernel/utsname.c
index a47fc5d..146e95c 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -130,6 +130,20 @@ static unsigned int utsns_inum(void *vp)
 	return ns->proc_inum;
 }
 
+unsigned int utsns_get_inum(struct task_struct *tsk)
+{
+	struct nsproxy *nsproxy;
+	unsigned int rc = 0;
+
+	rcu_read_lock();
+	nsproxy = task_nsproxy(tsk);
+	if (nsproxy)
+		rc = utsns_inum(task_nsproxy(tsk)->uts_ns);
+	rcu_read_unlock();
+
+	return rc;
+}
+
 const struct proc_ns_operations utsns_operations = {
 	.name		= "uts",
 	.type		= CLONE_NEWUTS,
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]