Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 170014
b: refs/heads/master
c: 63395b6
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman committed Nov 12, 2009
1 parent 221a61f commit d656198
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 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: 2fb10732c3b3c9671b1a391996ce7e551876c25e
refs/heads/master: 63395b65972c07edce595c9cc8a983016738cdac
35 changes: 20 additions & 15 deletions trunk/kernel/sysctl_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/pid_namespace.h>
#include <linux/file.h>
#include <linux/ctype.h>
#include <linux/netdevice.h>

#ifdef CONFIG_SYSCTL_SYSCALL

Expand Down Expand Up @@ -1250,9 +1251,12 @@ static ssize_t bin_dn_node_address(struct file *file,
static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
{
const struct bin_table *table = &bin_root_table[0];
struct net *net = current->nsproxy->net_ns;
int ctl_name;

/* The binary sysctl tables have a small maximum depth so
* there is no danger of overflowing our path as it PATH_MAX
* bytes long.
*/
memcpy(path, "sys/", 4);
path += 4;

Expand All @@ -1263,30 +1267,31 @@ static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
name++;
nlen--;
for ( ; table->convert; table++) {
struct net_device *dev = NULL;
const char *procname = NULL;
int len = 0;

/* Use the well known sysctl number to proc name mapping */
if (ctl_name == table->ctl_name)
procname = table->procname;

if (ctl_name == table->ctl_name) {
len = strlen(table->procname);
memcpy(path, table->procname, len);
}
#ifdef CONFIG_NET
/*
* For a wild card entry map from ifindex to network
* device name.
*/
else if (!table->ctl_name) {
struct net *net = current->nsproxy->net_ns;
struct net_device *dev;
dev = dev_get_by_index(net, ctl_name);
if (dev)
procname = dev->name;
if (dev) {
len = strlen(dev->name);
memcpy(path, dev->name, len);
dev_put(dev);
}
}
if (procname) {
int len;

len = strlen(procname);
memcpy(path, procname, len);
#endif
if (len) {
path += len;
if (dev)
dev_put(dev);
if (table->child) {
*path++ = '/';
table = table->child;
Expand Down

0 comments on commit d656198

Please sign in to comment.