Skip to content

Commit 78e92b9

Browse files
dlunevdavem330
authored andcommitted
netns: assign PDE->data before gluing entry into /proc tree
In this unfortunate case, proc_mkdir_mode wrapper can't be used anymore and this is no way to reuse proc_create_data due to nlinks assignment. So, copy the code from proc_mkdir and assign PDE->data at the appropriate moment. Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8b16924 commit 78e92b9

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎fs/proc/generic.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,23 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
641641
return ent;
642642
}
643643

644+
struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
645+
struct proc_dir_entry *parent)
646+
{
647+
struct proc_dir_entry *ent;
648+
649+
ent = __proc_create(&parent, name, S_IFDIR | S_IRUGO | S_IXUGO, 2);
650+
if (ent) {
651+
ent->data = net;
652+
if (proc_register(parent, ent) < 0) {
653+
kfree(ent);
654+
ent = NULL;
655+
}
656+
}
657+
return ent;
658+
}
659+
EXPORT_SYMBOL_GPL(proc_net_mkdir);
660+
644661
struct proc_dir_entry *proc_mkdir(const char *name,
645662
struct proc_dir_entry *parent)
646663
{

‎fs/proc/proc_net.c‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,6 @@ struct net *get_proc_net(const struct inode *inode)
159159
}
160160
EXPORT_SYMBOL_GPL(get_proc_net);
161161

162-
struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
163-
struct proc_dir_entry *parent)
164-
{
165-
struct proc_dir_entry *pde;
166-
pde = proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent);
167-
if (pde != NULL)
168-
pde->data = net;
169-
return pde;
170-
}
171-
EXPORT_SYMBOL_GPL(proc_net_mkdir);
172-
173162
static __net_init int proc_net_ns_init(struct net *net)
174163
{
175164
struct proc_dir_entry *netd, *net_statd;

0 commit comments

Comments
 (0)