Commit 895b5599 authored by Al Viro's avatar Al Viro

dgrp procfs fixes, part 6: just use proc_create{,_data}

->permission() of its own is a rudiment of sysctl imitation;
normal procfs logics will do just fine here, no need to
mess with ->proc_iops at all.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent af064cdd
...@@ -167,34 +167,3 @@ void dgrp_carrier(struct ch_struct *ch) ...@@ -167,34 +167,3 @@ void dgrp_carrier(struct ch_struct *ch)
ch->ch_flag &= ~CH_PHYS_CD; ch->ch_flag &= ~CH_PHYS_CD;
} }
/**
* dgrp_chk_perm() -- check permissions for net device
* @inode: pointer to inode structure for the net communication device
* @op: operation to be tested
*
* The file permissions and ownerships are tested to determine whether
* the operation "op" is permitted on the file pointed to by the inode.
* Returns 0 if the operation is permitted, -EACCESS otherwise
*/
int dgrp_chk_perm(int mode, int op)
{
if (!uid_eq(GLOBAL_ROOT_UID, current_euid()))
mode >>= 6;
else if (in_egroup_p(GLOBAL_ROOT_GID))
mode >>= 3;
if ((mode & op & 0007) == op)
return 0;
if (capable(CAP_SYS_ADMIN))
return 0;
return -EACCES;
}
/* dgrp_chk_perm wrapper for permission call in struct inode_operations */
int dgrp_inode_permission(struct inode *inode, int op)
{
return dgrp_chk_perm(inode->i_mode, op);
}
...@@ -89,8 +89,6 @@ extern void dgrp_register_proc(void); ...@@ -89,8 +89,6 @@ extern void dgrp_register_proc(void);
*-----------------------------------------------------------------------*/ *-----------------------------------------------------------------------*/
void dgrp_carrier(struct ch_struct *ch); void dgrp_carrier(struct ch_struct *ch);
extern int dgrp_inode_permission(struct inode *inode, int op);
extern int dgrp_chk_perm(int mode, int op);
/* /*
......
...@@ -55,12 +55,6 @@ static struct proc_dir_entry *add_proc_file(struct nd_struct *node, ...@@ -55,12 +55,6 @@ static struct proc_dir_entry *add_proc_file(struct nd_struct *node,
/* File operation declarations */ /* File operation declarations */
static int parse_write_config(char *); static int parse_write_config(char *);
static struct inode_operations proc_inode_ops = {
.permission = dgrp_inode_permission
};
static ssize_t dgrp_config_proc_write(struct file *file, static ssize_t dgrp_config_proc_write(struct file *file,
const char __user *buffer, const char __user *buffer,
size_t count, loff_t *pos); size_t count, loff_t *pos);
...@@ -139,28 +133,15 @@ void dgrp_unregister_proc(void) ...@@ -139,28 +133,15 @@ void dgrp_unregister_proc(void)
void dgrp_register_proc(void) void dgrp_register_proc(void)
{ {
struct proc_dir_entry *de;
/* /*
* Register /proc/dgrp * Register /proc/dgrp
*/ */
dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL); dgrp_proc_dir_entry = proc_mkdir("dgrp", NULL);
if (!dgrp_proc_dir_entry) if (!dgrp_proc_dir_entry)
return; return;
de = create_proc_entry("dgrp/config", 0644, NULL); proc_create("dgrp/config", 0644, NULL, &config_proc_file_ops);
if (de) { proc_create("dgrp/info", 0644, NULL, &info_proc_file_ops);
de->proc_fops = &config_proc_file_ops; proc_create("dgrp/nodeinfo", 0644, NULL, &nodeinfo_proc_file_ops);
de->proc_iops = &proc_inode_ops;
}
de = create_proc_entry("dgrp/info", 0644, NULL);
if (de) {
de->proc_fops = &info_proc_file_ops;
de->proc_iops = &proc_inode_ops;
}
de = create_proc_entry("dgrp/nodeinfo", 0644, NULL);
if (de) {
de->proc_fops = &nodeinfo_proc_file_ops;
de->proc_iops = &proc_inode_ops;
}
net_entry_pointer = proc_mkdir_mode("dgrp/net", 0500, NULL); net_entry_pointer = proc_mkdir_mode("dgrp/net", 0500, NULL);
mon_entry_pointer = proc_mkdir_mode("dgrp/mon", 0500, NULL); mon_entry_pointer = proc_mkdir_mode("dgrp/mon", 0500, NULL);
dpa_entry_pointer = proc_mkdir_mode("dgrp/dpa", 0500, NULL); dpa_entry_pointer = proc_mkdir_mode("dgrp/dpa", 0500, NULL);
...@@ -554,15 +535,6 @@ static struct proc_dir_entry *add_proc_file(struct nd_struct *node, ...@@ -554,15 +535,6 @@ static struct proc_dir_entry *add_proc_file(struct nd_struct *node,
const struct file_operations *fops) const struct file_operations *fops)
{ {
char buf[3]; char buf[3];
struct proc_dir_entry *de;
ID_TO_CHAR(node->nd_ID, buf); ID_TO_CHAR(node->nd_ID, buf);
return proc_create_data(buf, 0600, root, fops, node);
de = create_proc_entry(buf, 0600 | S_IFREG, root);
if (de) {
de->data = (void *) node;
de->proc_fops = fops;
de->proc_iops = &proc_inode_ops;
}
return de;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment