[RFC][PATCH 5/7]: Implement get_pts_ns() and put_pts_ns()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Containers <containers@...>, <clg@...>, Pavel Emelyanov <xemul@...>
Date: Tuesday, April 8, 2008 - 6:00 pm

From: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Subject: [RFC][PATCH 5/7]: Implement get_pts_ns() and put_pts_ns()

Implement get_pts_ns() and put_pts_ns() interfaces.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
---
 include/linux/devpts_fs.h |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

Index: 2.6.25-rc8-mm1/include/linux/devpts_fs.h
===================================================================
--- 2.6.25-rc8-mm1.orig/include/linux/devpts_fs.h	2008-04-08 09:18:23.000000000 -0700
+++ 2.6.25-rc8-mm1/include/linux/devpts_fs.h	2008-04-08 13:36:31.000000000 -0700
@@ -27,13 +27,26 @@ struct pts_namespace {
 extern struct pts_namespace init_pts_ns;
 
 #ifdef CONFIG_UNIX98_PTYS
-
 int devpts_new_index(void);
 void devpts_kill_index(int idx);
 int devpts_pty_new(struct tty_struct *tty);      /* mknod in devpts */
 struct tty_struct *devpts_get_tty(int number);	 /* get tty structure */
 void devpts_pty_kill(int number);		 /* unlink */
 
+static inline void free_pts_ns(struct kref *ns_kref) { }
+
+static inline struct pts_namespace *get_pts_ns(struct pts_namespace *ns)
+{
+	if (ns && (ns != &init_pts_ns))
+		kref_get(&ns->kref);
+	return ns;
+}
+static inline void put_pts_ns(struct pts_namespace *ns)
+{
+	if (ns && (ns != &init_pts_ns))
+		kref_put(&ns->kref, free_pts_ns);
+}
+
 #else
 
 /* Dummy stubs in the no-pty case */
@@ -43,6 +56,12 @@ static inline int devpts_pty_new(struct 
 static inline struct tty_struct *devpts_get_tty(int number) { return NULL; }
 static inline void devpts_pty_kill(int number) { }
 
+static inline struct pts_namespace *get_pts_ns(struct pts_namespace *ns)
+{
+	return &init_pts_ns;
+}
+
+static inline void put_pts_ns(struct pts_namespace *ns) { }
 #endif
 
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH 0/7] Clone PTS namespace, , (Tue Apr 8, 5:53 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, H. Peter Anvin, (Tue Apr 8, 8:53 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Eric W. Biederman, (Wed Apr 9, 6:15 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Wed Apr 9, 9:59 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Eric W. Biederman, (Thu Apr 10, 3:36 am)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Tue Apr 22, 10:25 am)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Eric W. Biederman, (Tue Apr 22, 2:53 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Wed Apr 23, 10:36 am)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Wed Apr 23, 1:57 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Eric W. Biederman, (Wed Apr 23, 2:49 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Fri Apr 25, 3:21 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Eric W. Biederman, (Fri Apr 25, 3:47 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Sat Apr 26, 9:02 am)
Re: [RFC][PATCH 0/7] Clone PTS namespace, Serge E. Hallyn, (Thu Apr 10, 12:44 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, H. Peter Anvin, (Wed Apr 9, 2:01 pm)
Re: [RFC][PATCH 0/7] Clone PTS namespace, H. Peter Anvin, (Wed Apr 9, 6:38 pm)
[RFC][PATCH 5/7]: Implement get_pts_ns() and put_pts_ns(), , (Tue Apr 8, 6:00 pm)