aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-05-11 17:44:25 -0400
committerEric W. Biederman <ebiederm@xmission.com>2015-07-01 11:36:41 -0400
commiteb6d38d5427b3ad42f5268da0f1dd31bb0af1264 (patch)
tree1fb54abb73c369444d6b84f12e3eff670c0a5d64 /fs/proc/generic.c
parentf9bd6733d3f11e24f3949becf277507d422ee1eb (diff)
proc: Allow creating permanently empty directories that serve as mount points
Add a new function proc_create_mount_point that when used to creates a directory that can not be added to. Add a new function is_empty_pde to test if a function is a mount point. Update the code to use make_empty_dir_inode when reporting a permanently empty directory to the vfs. Update the code to not allow adding to permanently empty directories. Update /proc/openprom and /proc/fs/nfsd to be permanently empty directories. Cc: stable@vger.kernel.org Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index df6327a2b865..e5dee5c3188e 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -373,6 +373,10 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
373 WARN(1, "create '/proc/%s' by hand\n", qstr.name); 373 WARN(1, "create '/proc/%s' by hand\n", qstr.name);
374 return NULL; 374 return NULL;
375 } 375 }
376 if (is_empty_pde(*parent)) {
377 WARN(1, "attempt to add to permanently empty directory");
378 return NULL;
379 }
376 380
377 ent = kzalloc(sizeof(struct proc_dir_entry) + qstr.len + 1, GFP_KERNEL); 381 ent = kzalloc(sizeof(struct proc_dir_entry) + qstr.len + 1, GFP_KERNEL);
378 if (!ent) 382 if (!ent)
@@ -455,6 +459,25 @@ struct proc_dir_entry *proc_mkdir(const char *name,
455} 459}
456EXPORT_SYMBOL(proc_mkdir); 460EXPORT_SYMBOL(proc_mkdir);
457 461
462struct proc_dir_entry *proc_create_mount_point(const char *name)
463{
464 umode_t mode = S_IFDIR | S_IRUGO | S_IXUGO;
465 struct proc_dir_entry *ent, *parent = NULL;
466
467 ent = __proc_create(&parent, name, mode, 2);
468 if (ent) {
469 ent->data = NULL;
470 ent->proc_fops = NULL;
471 ent->proc_iops = NULL;
472 if (proc_register(parent, ent) < 0) {
473 kfree(ent);
474 parent->nlink--;
475 ent = NULL;
476 }
477 }
478 return ent;
479}
480
458struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, 481struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
459 struct proc_dir_entry *parent, 482 struct proc_dir_entry *parent,
460 const struct file_operations *proc_fops, 483 const struct file_operations *proc_fops,