Skip to content

Commit b1f01e2

Browse files
Joelgranadosmcgrof
authored andcommitted
sysctl: Add size argument to init_header
In this commit, we add a table_size argument to the init_header function in order to initialize the ctl_table_size variable in ctl_table_header. Even though the size is not yet used, it is now initialized within the sysctl subsys. We need this commit for when we start adding the table_size arguments to the sysctl functions (e.g. register_sysctl, __register_sysctl_table and __register_sysctl_init). Note that in __register_sysctl_table we temporarily use a calculated size until we add the size argument to that function in subsequent commits. Signed-off-by: Joel Granados <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 1e88772 commit b1f01e2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fs/proc/proc_sysctl.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry)
188188

189189
static void init_header(struct ctl_table_header *head,
190190
struct ctl_table_root *root, struct ctl_table_set *set,
191-
struct ctl_node *node, struct ctl_table *table)
191+
struct ctl_node *node, struct ctl_table *table, size_t table_size)
192192
{
193193
head->ctl_table = table;
194+
head->ctl_table_size = table_size;
194195
head->ctl_table_arg = table;
195196
head->used = 0;
196197
head->count = 1;
@@ -973,7 +974,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
973974
memcpy(new_name, name, namelen);
974975
table[0].procname = new_name;
975976
table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
976-
init_header(&new->header, set->dir.header.root, set, node, table);
977+
init_header(&new->header, set->dir.header.root, set, node, table, 1);
977978

978979
return new;
979980
}
@@ -1197,7 +1198,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
11971198
link_name += len;
11981199
link++;
11991200
}
1200-
init_header(links, dir->header.root, dir->header.set, node, link_table);
1201+
init_header(links, dir->header.root, dir->header.set, node, link_table,
1202+
head->ctl_table_size);
12011203
links->nreg = nr_entries;
12021204

12031205
return links;
@@ -1372,7 +1374,7 @@ struct ctl_table_header *__register_sysctl_table(
13721374
return NULL;
13731375

13741376
node = (struct ctl_node *)(header + 1);
1375-
init_header(header, root, set, node, table);
1377+
init_header(header, root, set, node, table, nr_entries);
13761378
if (sysctl_check_table(path, header))
13771379
goto fail;
13781380

@@ -1537,7 +1539,7 @@ void setup_sysctl_set(struct ctl_table_set *set,
15371539
{
15381540
memset(set, 0, sizeof(*set));
15391541
set->is_seen = is_seen;
1540-
init_header(&set->dir.header, root, set, NULL, root_table);
1542+
init_header(&set->dir.header, root, set, NULL, root_table, 1);
15411543
}
15421544

15431545
void retire_sysctl_set(struct ctl_table_set *set)

0 commit comments

Comments
 (0)