Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84619
b: refs/heads/master
c: 2d3a4e3
h: refs/heads/master
i:
  84617: a85c32c
  84615: fade416
v: v3
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Feb 8, 2008
1 parent d3f6ea4 commit 693a594
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c6caeb7c4544608e8ae62731334661fc396c7f85
refs/heads/master: 2d3a4e3666325a9709cc8ea2e88151394e8f20fc
40 changes: 36 additions & 4 deletions trunk/fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
return 0;
}

static struct proc_dir_entry *proc_create(struct proc_dir_entry **parent,
static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
const char *name,
mode_t mode,
nlink_t nlink)
Expand Down Expand Up @@ -605,7 +605,7 @@ struct proc_dir_entry *proc_symlink(const char *name,
{
struct proc_dir_entry *ent;

ent = proc_create(&parent,name,
ent = __proc_create(&parent, name,
(S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO),1);

if (ent) {
Expand All @@ -630,7 +630,7 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
{
struct proc_dir_entry *ent;

ent = proc_create(&parent, name, S_IFDIR | mode, 2);
ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
if (ent) {
if (proc_register(parent, ent) < 0) {
kfree(ent);
Expand Down Expand Up @@ -664,7 +664,7 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
nlink = 1;
}

ent = proc_create(&parent,name,mode,nlink);
ent = __proc_create(&parent, name, mode, nlink);
if (ent) {
if (proc_register(parent, ent) < 0) {
kfree(ent);
Expand All @@ -674,6 +674,38 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
return ent;
}

struct proc_dir_entry *proc_create(const char *name, mode_t mode,
struct proc_dir_entry *parent,
const struct file_operations *proc_fops)
{
struct proc_dir_entry *pde;
nlink_t nlink;

if (S_ISDIR(mode)) {
if ((mode & S_IALLUGO) == 0)
mode |= S_IRUGO | S_IXUGO;
nlink = 2;
} else {
if ((mode & S_IFMT) == 0)
mode |= S_IFREG;
if ((mode & S_IALLUGO) == 0)
mode |= S_IRUGO;
nlink = 1;
}

pde = __proc_create(&parent, name, mode, nlink);
if (!pde)
goto out;
pde->proc_fops = proc_fops;
if (proc_register(parent, pde) < 0)
goto out_free;
return pde;
out_free:
kfree(pde);
out:
return NULL;
}

void free_proc_entry(struct proc_dir_entry *de)
{
unsigned int ino = de->low_ino;
Expand Down
7 changes: 1 addition & 6 deletions trunk/fs/proc/proc_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ EXPORT_SYMBOL_GPL(seq_release_net);
struct proc_dir_entry *proc_net_fops_create(struct net *net,
const char *name, mode_t mode, const struct file_operations *fops)
{
struct proc_dir_entry *res;

res = create_proc_entry(name, mode, net->proc_net);
if (res)
res->proc_fops = fops;
return res;
return proc_create(name, mode, net->proc_net, fops);
}
EXPORT_SYMBOL_GPL(proc_net_fops_create);

Expand Down
1 change: 1 addition & 0 deletions trunk/fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ void pid_ns_release_proc(struct pid_namespace *ns)
EXPORT_SYMBOL(proc_symlink);
EXPORT_SYMBOL(proc_mkdir);
EXPORT_SYMBOL(create_proc_entry);
EXPORT_SYMBOL(proc_create);
EXPORT_SYMBOL(remove_proc_entry);
EXPORT_SYMBOL(proc_root);
EXPORT_SYMBOL(proc_root_fs);
Expand Down
10 changes: 9 additions & 1 deletion trunk/include/linux/proc_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ void de_put(struct proc_dir_entry *de);

extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
struct proc_dir_entry *parent);
struct proc_dir_entry *proc_create(const char *name, mode_t mode,
struct proc_dir_entry *parent,
const struct file_operations *proc_fops);
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);

extern struct vfsmount *proc_mnt;
Expand Down Expand Up @@ -220,7 +223,12 @@ static inline void proc_flush_task(struct task_struct *task)

static inline struct proc_dir_entry *create_proc_entry(const char *name,
mode_t mode, struct proc_dir_entry *parent) { return NULL; }

static inline struct proc_dir_entry *proc_create(const char *name,
mode_t mode, struct proc_dir_entry *parent,
const struct file_operations *proc_fops)
{
return NULL;
}
#define remove_proc_entry(name, parent) do {} while (0)

static inline struct proc_dir_entry *proc_symlink(const char *name,
Expand Down

0 comments on commit 693a594

Please sign in to comment.