sysctl: clean from unneeded extern and forward declarations
The do_sysctl_strategy isn't used outside kernel/sysctl.c, so this can be static and without a prototype in header. Besides, move this one and parse_table() above their callers and drop the forward declarations of the latter call. One more "besides" - fix two checkpatch warnings: space before a ( and an extra space at the end of a line. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: David S. Miller <davem@davemloft.net> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Alexey Dobriyan <adobriyan@sw.ru> Cc: Denis V. Lunev <den@openvz.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
7708bfb1c8
commit
2c4c7155f2
@ -981,11 +981,6 @@ extern int do_sysctl (int __user *name, int nlen,
|
|||||||
void __user *oldval, size_t __user *oldlenp,
|
void __user *oldval, size_t __user *oldlenp,
|
||||||
void __user *newval, size_t newlen);
|
void __user *newval, size_t newlen);
|
||||||
|
|
||||||
extern int do_sysctl_strategy (struct ctl_table *table,
|
|
||||||
int __user *name, int nlen,
|
|
||||||
void __user *oldval, size_t __user *oldlenp,
|
|
||||||
void __user *newval, size_t newlen);
|
|
||||||
|
|
||||||
extern ctl_handler sysctl_data;
|
extern ctl_handler sysctl_data;
|
||||||
extern ctl_handler sysctl_string;
|
extern ctl_handler sysctl_string;
|
||||||
extern ctl_handler sysctl_intvec;
|
extern ctl_handler sysctl_intvec;
|
||||||
|
144
kernel/sysctl.c
144
kernel/sysctl.c
@ -145,12 +145,6 @@ extern int no_unaligned_warning;
|
|||||||
extern int max_lock_depth;
|
extern int max_lock_depth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL_SYSCALL
|
|
||||||
static int parse_table(int __user *, int, void __user *, size_t __user *,
|
|
||||||
void __user *, size_t, struct ctl_table *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_SYSCTL
|
#ifdef CONFIG_PROC_SYSCTL
|
||||||
static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
|
static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
|
||||||
void __user *buffer, size_t *lenp, loff_t *ppos);
|
void __user *buffer, size_t *lenp, loff_t *ppos);
|
||||||
@ -1439,6 +1433,74 @@ void register_sysctl_root(struct ctl_table_root *root)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL_SYSCALL
|
#ifdef CONFIG_SYSCTL_SYSCALL
|
||||||
|
/* Perform the actual read/write of a sysctl table entry. */
|
||||||
|
static int do_sysctl_strategy(struct ctl_table *table,
|
||||||
|
int __user *name, int nlen,
|
||||||
|
void __user *oldval, size_t __user *oldlenp,
|
||||||
|
void __user *newval, size_t newlen)
|
||||||
|
{
|
||||||
|
int op = 0, rc;
|
||||||
|
|
||||||
|
if (oldval)
|
||||||
|
op |= 004;
|
||||||
|
if (newval)
|
||||||
|
op |= 002;
|
||||||
|
if (sysctl_perm(table, op))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
|
if (table->strategy) {
|
||||||
|
rc = table->strategy(table, name, nlen, oldval, oldlenp,
|
||||||
|
newval, newlen);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
if (rc > 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If there is no strategy routine, or if the strategy returns
|
||||||
|
* zero, proceed with automatic r/w */
|
||||||
|
if (table->data && table->maxlen) {
|
||||||
|
rc = sysctl_data(table, name, nlen, oldval, oldlenp,
|
||||||
|
newval, newlen);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_table(int __user *name, int nlen,
|
||||||
|
void __user *oldval, size_t __user *oldlenp,
|
||||||
|
void __user *newval, size_t newlen,
|
||||||
|
struct ctl_table *table)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
repeat:
|
||||||
|
if (!nlen)
|
||||||
|
return -ENOTDIR;
|
||||||
|
if (get_user(n, name))
|
||||||
|
return -EFAULT;
|
||||||
|
for ( ; table->ctl_name || table->procname; table++) {
|
||||||
|
if (!table->ctl_name)
|
||||||
|
continue;
|
||||||
|
if (n == table->ctl_name) {
|
||||||
|
int error;
|
||||||
|
if (table->child) {
|
||||||
|
if (sysctl_perm(table, 001))
|
||||||
|
return -EPERM;
|
||||||
|
name++;
|
||||||
|
nlen--;
|
||||||
|
table = table->child;
|
||||||
|
goto repeat;
|
||||||
|
}
|
||||||
|
error = do_sysctl_strategy(table, name, nlen,
|
||||||
|
oldval, oldlenp,
|
||||||
|
newval, newlen);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -ENOTDIR;
|
||||||
|
}
|
||||||
|
|
||||||
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
|
int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
|
||||||
void __user *newval, size_t newlen)
|
void __user *newval, size_t newlen)
|
||||||
{
|
{
|
||||||
@ -1511,76 +1573,6 @@ int sysctl_perm(struct ctl_table *table, int op)
|
|||||||
return test_perm(table->mode, op);
|
return test_perm(table->mode, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL_SYSCALL
|
|
||||||
static int parse_table(int __user *name, int nlen,
|
|
||||||
void __user *oldval, size_t __user *oldlenp,
|
|
||||||
void __user *newval, size_t newlen,
|
|
||||||
struct ctl_table *table)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
repeat:
|
|
||||||
if (!nlen)
|
|
||||||
return -ENOTDIR;
|
|
||||||
if (get_user(n, name))
|
|
||||||
return -EFAULT;
|
|
||||||
for ( ; table->ctl_name || table->procname; table++) {
|
|
||||||
if (!table->ctl_name)
|
|
||||||
continue;
|
|
||||||
if (n == table->ctl_name) {
|
|
||||||
int error;
|
|
||||||
if (table->child) {
|
|
||||||
if (sysctl_perm(table, 001))
|
|
||||||
return -EPERM;
|
|
||||||
name++;
|
|
||||||
nlen--;
|
|
||||||
table = table->child;
|
|
||||||
goto repeat;
|
|
||||||
}
|
|
||||||
error = do_sysctl_strategy(table, name, nlen,
|
|
||||||
oldval, oldlenp,
|
|
||||||
newval, newlen);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -ENOTDIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Perform the actual read/write of a sysctl table entry. */
|
|
||||||
int do_sysctl_strategy (struct ctl_table *table,
|
|
||||||
int __user *name, int nlen,
|
|
||||||
void __user *oldval, size_t __user *oldlenp,
|
|
||||||
void __user *newval, size_t newlen)
|
|
||||||
{
|
|
||||||
int op = 0, rc;
|
|
||||||
|
|
||||||
if (oldval)
|
|
||||||
op |= 004;
|
|
||||||
if (newval)
|
|
||||||
op |= 002;
|
|
||||||
if (sysctl_perm(table, op))
|
|
||||||
return -EPERM;
|
|
||||||
|
|
||||||
if (table->strategy) {
|
|
||||||
rc = table->strategy(table, name, nlen, oldval, oldlenp,
|
|
||||||
newval, newlen);
|
|
||||||
if (rc < 0)
|
|
||||||
return rc;
|
|
||||||
if (rc > 0)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there is no strategy routine, or if the strategy returns
|
|
||||||
* zero, proceed with automatic r/w */
|
|
||||||
if (table->data && table->maxlen) {
|
|
||||||
rc = sysctl_data(table, name, nlen, oldval, oldlenp,
|
|
||||||
newval, newlen);
|
|
||||||
if (rc < 0)
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_SYSCTL_SYSCALL */
|
|
||||||
|
|
||||||
static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
|
static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
|
||||||
{
|
{
|
||||||
for (; table->ctl_name || table->procname; table++) {
|
for (; table->ctl_name || table->procname; table++) {
|
||||||
|
Reference in New Issue
Block a user