History

lost sysctl fix

try_attach() should walk into the matching subdirectory, not the first one...

Al Viro committed 18 years ago

Commit bfbcf031 parent 8be1a6d1 file · +9 −7Browse files

Showing the changes to kernel/sysctl.c (1 of 1 file). Show all

Unified · Split

kernel/sysctl.c+9−7
@@ -1680,43 +1680,45 @@ static __init int sysctl_init(void) · 1679 unmodified lines
16801680
16811681 core_initcall(sysctl_init);
16821682
1683−static int is_branch_in(struct ctl_table *branch, struct ctl_table *table)
1683+static struct ctl_table *is_branch_in(struct ctl_table *branch,
1684+ struct ctl_table *table)
16841685 {
16851686 struct ctl_table *p;
16861687 const char *s = branch->procname;
16871688
16881689 /* branch should have named subdirectory as its first element */
16891690 if (!s || !branch->child)
1690− return 0;
1691+ return NULL;
16911692
16921693 /* ... and nothing else */
16931694 if (branch[1].procname || branch[1].ctl_name)
1694− return 0;
1695+ return NULL;
16951696
16961697 /* table should contain subdirectory with the same name */
16971698 for (p = table; p->procname || p->ctl_name; p++) {
16981699 if (!p->child)
16991700 continue;
17001701 if (p->procname && strcmp(p->procname, s) == 0)
1701− return 1;
1702+ return p;
17021703 }
1703− return 0;
1704+ return NULL;
17041705 }
17051706
17061707 /* see if attaching q to p would be an improvement */
17071708 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
17081709 {
17091710 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1711+ struct ctl_table *next;
17101712 int is_better = 0;
17111713 int not_in_parent = !p->attached_by;
17121714
1713− while (is_branch_in(by, to)) {
1715+ while ((next = is_branch_in(by, to)) != NULL) {
17141716 if (by == q->attached_by)
17151717 is_better = 1;
17161718 if (to == p->attached_by)
17171719 not_in_parent = 1;
17181720 by = by->child;
1719− to = to->child;
1721+ to = next->child;
17201722 }
17211723
17221724 if (is_better && not_in_parent) {