diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2014-07-31 06:10:50 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2014-08-04 13:07:11 -0400 |
commit | 0097875bd41528922fb3bb5f348c53f17e00e2fd (patch) | |
tree | 414cffac820d04e4542dc7654e7ef188f00ba0b2 /fs/proc/root.c | |
parent | 6ba8ed79a3cce14bd5597218fd46408b8376f8f3 (diff) |
proc: Implement /proc/thread-self to point at the directory of the current thread
/proc/thread-self is derived from /proc/self. /proc/thread-self
points to the directory in proc containing information about the
current thread.
This funtionality has been missing for a long time, and is tricky to
implement in userspace as gettid() is not exported by glibc. More
importantly this allows fixing defects in /proc/mounts and /proc/net
where in a threaded application today they wind up being empty files
when only the initial pthread has exited, causing problems for other
threads.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/proc/root.c')
-rw-r--r-- | fs/proc/root.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/proc/root.c b/fs/proc/root.c index 5dbadecb234d..48f1c03bc7ed 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -149,6 +149,8 @@ static void proc_kill_sb(struct super_block *sb) | |||
149 | ns = (struct pid_namespace *)sb->s_fs_info; | 149 | ns = (struct pid_namespace *)sb->s_fs_info; |
150 | if (ns->proc_self) | 150 | if (ns->proc_self) |
151 | dput(ns->proc_self); | 151 | dput(ns->proc_self); |
152 | if (ns->proc_thread_self) | ||
153 | dput(ns->proc_thread_self); | ||
152 | kill_anon_super(sb); | 154 | kill_anon_super(sb); |
153 | put_pid_ns(ns); | 155 | put_pid_ns(ns); |
154 | } | 156 | } |
@@ -170,6 +172,7 @@ void __init proc_root_init(void) | |||
170 | return; | 172 | return; |
171 | 173 | ||
172 | proc_self_init(); | 174 | proc_self_init(); |
175 | proc_thread_self_init(); | ||
173 | proc_symlink("mounts", NULL, "self/mounts"); | 176 | proc_symlink("mounts", NULL, "self/mounts"); |
174 | 177 | ||
175 | proc_net_init(); | 178 | proc_net_init(); |