aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 35a50db9b6ce..8ee4a0619fbb 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -160,12 +160,13 @@ static struct ctl_table root_table[];
160static struct ctl_table_root sysctl_table_root; 160static struct ctl_table_root sysctl_table_root;
161static struct ctl_table_header root_table_header = { 161static struct ctl_table_header root_table_header = {
162 .ctl_table = root_table, 162 .ctl_table = root_table,
163 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.header_list), 163 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
164 .root = &sysctl_table_root, 164 .root = &sysctl_table_root,
165 .set = &sysctl_table_root.default_set,
165}; 166};
166static struct ctl_table_root sysctl_table_root = { 167static struct ctl_table_root sysctl_table_root = {
167 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 168 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
168 .header_list = LIST_HEAD_INIT(root_table_header.ctl_entry), 169 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
169}; 170};
170 171
171static struct ctl_table kern_table[]; 172static struct ctl_table kern_table[];
@@ -1403,14 +1404,20 @@ void sysctl_head_finish(struct ctl_table_header *head)
1403 spin_unlock(&sysctl_lock); 1404 spin_unlock(&sysctl_lock);
1404} 1405}
1405 1406
1407static struct ctl_table_set *
1408lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1409{
1410 struct ctl_table_set *set = &root->default_set;
1411 if (root->lookup)
1412 set = root->lookup(root, namespaces);
1413 return set;
1414}
1415
1406static struct list_head * 1416static struct list_head *
1407lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1417lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1408{ 1418{
1409 struct list_head *header_list; 1419 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1410 header_list = &root->header_list; 1420 return &set->list;
1411 if (root->lookup)
1412 header_list = root->lookup(root, namespaces);
1413 return header_list;
1414} 1421}
1415 1422
1416struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1423struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
@@ -1720,7 +1727,6 @@ struct ctl_table_header *__register_sysctl_paths(
1720 struct nsproxy *namespaces, 1727 struct nsproxy *namespaces,
1721 const struct ctl_path *path, struct ctl_table *table) 1728 const struct ctl_path *path, struct ctl_table *table)
1722{ 1729{
1723 struct list_head *header_list;
1724 struct ctl_table_header *header; 1730 struct ctl_table_header *header;
1725 struct ctl_table *new, **prevp; 1731 struct ctl_table *new, **prevp;
1726 unsigned int n, npath; 1732 unsigned int n, npath;
@@ -1772,8 +1778,8 @@ struct ctl_table_header *__register_sysctl_paths(
1772 } 1778 }
1773#endif 1779#endif
1774 spin_lock(&sysctl_lock); 1780 spin_lock(&sysctl_lock);
1775 header_list = lookup_header_list(root, namespaces); 1781 header->set = lookup_header_set(root, namespaces);
1776 list_add_tail(&header->ctl_entry, header_list); 1782 list_add_tail(&header->ctl_entry, &header->set->list);
1777 spin_unlock(&sysctl_lock); 1783 spin_unlock(&sysctl_lock);
1778 1784
1779 return header; 1785 return header;
@@ -1832,6 +1838,15 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1832 kfree(header); 1838 kfree(header);
1833} 1839}
1834 1840
1841void setup_sysctl_set(struct ctl_table_set *p,
1842 struct ctl_table_set *parent,
1843 int (*is_seen)(struct ctl_table_set *))
1844{
1845 INIT_LIST_HEAD(&p->list);
1846 p->parent = parent ? parent : &sysctl_table_root.default_set;
1847 p->is_seen = is_seen;
1848}
1849
1835#else /* !CONFIG_SYSCTL */ 1850#else /* !CONFIG_SYSCTL */
1836struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1851struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1837{ 1852{
@@ -1848,6 +1863,12 @@ void unregister_sysctl_table(struct ctl_table_header * table)
1848{ 1863{
1849} 1864}
1850 1865
1866void setup_sysctl_set(struct ctl_table_set *p,
1867 struct ctl_table_set *parent,
1868 int (*is_seen)(struct ctl_table_set *))
1869{
1870}
1871
1851#endif /* CONFIG_SYSCTL */ 1872#endif /* CONFIG_SYSCTL */
1852 1873
1853/* 1874/*