3 #include <linux/sched.h>
4 #include <linux/ptrace.h>
10 #include <linux/utsname.h>
33 static struct dentry *proc_ns_instantiate(
struct inode *dir,
46 ns = ns_ops->
get(task);
52 inode->
i_fop = &ns_file_operations;
68 static int proc_ns_fill_cache(
struct file *filp,
void *
dirent,
74 proc_ns_instantiate, task, ops);
77 static int proc_ns_dir_readdir(
struct file *filp,
void *dirent,
81 struct dentry *dentry = filp->
f_path.dentry;
82 struct inode *inode = dentry->
d_inode;
101 if (filldir(dirent,
".", 1, i, ino,
DT_DIR) < 0)
108 if (filldir(dirent,
"..", 2, i, ino,
DT_DIR) < 0)
119 entry = ns_entries +
i;
120 last = &ns_entries[
ARRAY_SIZE(ns_entries) - 1];
121 while (entry <= last) {
122 if (proc_ns_fill_cache(filp, dirent, filldir,
132 put_task_struct(task);
139 .readdir = proc_ns_dir_readdir,
142 static struct dentry *proc_ns_dir_lookup(
struct inode *dir,
143 struct dentry *dentry,
unsigned int flags)
145 struct dentry *
error;
155 error = ERR_PTR(-
EPERM);
160 for (entry = ns_entries; entry < last; entry++) {
161 if (
strlen((*entry)->name) != len)
170 error = proc_ns_instantiate(dir, dentry, task, *entry);
172 put_task_struct(task);
178 .lookup = proc_ns_dir_lookup,
189 return ERR_PTR(-
EBADF);
191 if (file->
f_op != &ns_file_operations)