Lines Matching refs:head
35 static bool is_empty_dir(struct ctl_table_header *head) in is_empty_dir() argument
37 return head->ctl_table[0].child == sysctl_mount_point; in is_empty_dir()
83 static int insert_links(struct ctl_table_header *head);
112 struct ctl_table_header *head; in find_entry() local
123 head = ctl_node->header; in find_entry()
124 entry = &head->ctl_table[ctl_node - head->node]; in find_entry()
133 *phead = head; in find_entry()
140 static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry) in insert_entry() argument
142 struct rb_node *node = &head->node[entry - head->ctl_table].node; in insert_entry()
143 struct rb_node **p = &head->parent->root.rb_node; in insert_entry()
168 sysctl_print_dir(head->parent); in insert_entry()
175 rb_insert_color(node, &head->parent->root); in insert_entry()
179 static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry) in erase_entry() argument
181 struct rb_node *node = &head->node[entry - head->ctl_table].node; in erase_entry()
183 rb_erase(node, &head->parent->root); in erase_entry()
186 static void init_header(struct ctl_table_header *head, in init_header() argument
190 head->ctl_table = table; in init_header()
191 head->ctl_table_arg = table; in init_header()
192 head->used = 0; in init_header()
193 head->count = 1; in init_header()
194 head->nreg = 1; in init_header()
195 head->unregistering = NULL; in init_header()
196 head->root = root; in init_header()
197 head->set = set; in init_header()
198 head->parent = NULL; in init_header()
199 head->node = node; in init_header()
200 INIT_HLIST_HEAD(&head->inodes); in init_header()
204 node->header = head; in init_header()
208 static void erase_header(struct ctl_table_header *head) in erase_header() argument
211 for (entry = head->ctl_table; entry->procname; entry++) in erase_header()
212 erase_entry(head, entry); in erase_header()
270 static void proc_sys_prune_dcache(struct ctl_table_header *head) in proc_sys_prune_dcache() argument
279 node = hlist_first_rcu(&head->inodes); in proc_sys_prune_dcache()
339 static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) in sysctl_head_grab() argument
341 BUG_ON(!head); in sysctl_head_grab()
343 if (!use_table(head)) in sysctl_head_grab()
344 head = ERR_PTR(-ENOENT); in sysctl_head_grab()
346 return head; in sysctl_head_grab()
349 static void sysctl_head_finish(struct ctl_table_header *head) in sysctl_head_finish() argument
351 if (!head) in sysctl_head_finish()
354 unuse_table(head); in sysctl_head_finish()
371 struct ctl_table_header *head; in lookup_entry() local
375 entry = find_entry(&head, dir, name, namelen); in lookup_entry()
376 if (entry && use_table(head)) in lookup_entry()
377 *phead = head; in lookup_entry()
399 struct ctl_table_header *head = NULL; in first_entry() local
407 head = ctl_node->header; in first_entry()
408 entry = &head->ctl_table[ctl_node - head->node]; in first_entry()
410 *phead = head; in first_entry()
416 struct ctl_table_header *head = *phead; in next_entry() local
418 struct ctl_node *ctl_node = &head->node[entry - head->ctl_table]; in next_entry()
421 unuse_table(head); in next_entry()
425 head = NULL; in next_entry()
427 head = ctl_node->header; in next_entry()
428 entry = &head->ctl_table[ctl_node - head->node]; in next_entry()
430 *phead = head; in next_entry()
450 static int sysctl_perm(struct ctl_table_header *head, struct ctl_table *table, int op) in sysctl_perm() argument
452 struct ctl_table_root *root = head->root; in sysctl_perm()
456 mode = root->permissions(head, table); in sysctl_perm()
464 struct ctl_table_header *head, struct ctl_table *table) in proc_sys_make_inode() argument
466 struct ctl_table_root *root = head->root; in proc_sys_make_inode()
479 if (unlikely(head->unregistering)) { in proc_sys_make_inode()
484 ei->sysctl = head; in proc_sys_make_inode()
486 hlist_add_head_rcu(&ei->sysctl_inodes, &head->inodes); in proc_sys_make_inode()
487 head->count++; in proc_sys_make_inode()
500 if (is_empty_dir(head)) in proc_sys_make_inode()
505 root->set_ownership(head, table, &inode->i_uid, &inode->i_gid); in proc_sys_make_inode()
514 void proc_sys_evict_inode(struct inode *inode, struct ctl_table_header *head) in proc_sys_evict_inode() argument
518 if (!--head->count) in proc_sys_evict_inode()
519 kfree_rcu(head, rcu); in proc_sys_evict_inode()
525 struct ctl_table_header *head = PROC_I(inode)->sysctl; in grab_header() local
526 if (!head) in grab_header()
527 head = &sysctl_table_root.default_set.dir.header; in grab_header()
528 return sysctl_head_grab(head); in grab_header()
534 struct ctl_table_header *head = grab_header(dir); in proc_sys_lookup() local
543 if (IS_ERR(head)) in proc_sys_lookup()
544 return ERR_CAST(head); in proc_sys_lookup()
546 ctl_dir = container_of(head, struct ctl_dir, header); in proc_sys_lookup()
559 inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p); in proc_sys_lookup()
571 sysctl_head_finish(head); in proc_sys_lookup()
579 struct ctl_table_header *head = grab_header(inode); in proc_sys_call_handler() local
584 if (IS_ERR(head)) in proc_sys_call_handler()
585 return PTR_ERR(head); in proc_sys_call_handler()
592 if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ)) in proc_sys_call_handler()
600 error = BPF_CGROUP_RUN_PROG_SYSCTL(head, table, write, buf, &count, in proc_sys_call_handler()
622 sysctl_head_finish(head); in proc_sys_call_handler()
641 struct ctl_table_header *head = grab_header(inode); in proc_sys_open() local
645 if (IS_ERR(head)) in proc_sys_open()
646 return PTR_ERR(head); in proc_sys_open()
651 sysctl_head_finish(head); in proc_sys_open()
659 struct ctl_table_header *head = grab_header(inode); in proc_sys_poll() local
665 if (IS_ERR(head)) in proc_sys_poll()
683 sysctl_head_finish(head); in proc_sys_poll()
690 struct ctl_table_header *head, in proc_sys_fill_cache() argument
711 inode = proc_sys_make_inode(dir->d_sb, head, table); in proc_sys_fill_cache()
739 struct ctl_table_header *head, in proc_sys_link_fill_cache() argument
744 head = sysctl_head_grab(head); in proc_sys_link_fill_cache()
745 if (IS_ERR(head)) in proc_sys_link_fill_cache()
749 if (sysctl_follow_link(&head, &table)) in proc_sys_link_fill_cache()
752 ret = proc_sys_fill_cache(file, ctx, head, table); in proc_sys_link_fill_cache()
754 sysctl_head_finish(head); in proc_sys_link_fill_cache()
758 static int scan(struct ctl_table_header *head, struct ctl_table *table, in scan() argument
768 res = proc_sys_link_fill_cache(file, ctx, head, table); in scan()
770 res = proc_sys_fill_cache(file, ctx, head, table); in scan()
780 struct ctl_table_header *head = grab_header(file_inode(file)); in proc_sys_readdir() local
786 if (IS_ERR(head)) in proc_sys_readdir()
787 return PTR_ERR(head); in proc_sys_readdir()
789 ctl_dir = container_of(head, struct ctl_dir, header); in proc_sys_readdir()
803 sysctl_head_finish(head); in proc_sys_readdir()
813 struct ctl_table_header *head; in proc_sys_permission() local
821 head = grab_header(inode); in proc_sys_permission()
822 if (IS_ERR(head)) in proc_sys_permission()
823 return PTR_ERR(head); in proc_sys_permission()
829 error = sysctl_perm(head, table, mask & ~MAY_NOT_BLOCK); in proc_sys_permission()
831 sysctl_head_finish(head); in proc_sys_permission()
856 struct ctl_table_header *head = grab_header(inode); in proc_sys_getattr() local
859 if (IS_ERR(head)) in proc_sys_getattr()
860 return PTR_ERR(head); in proc_sys_getattr()
866 sysctl_head_finish(head); in proc_sys_getattr()
927 struct ctl_table_header *head; in proc_sys_compare() local
940 head = rcu_dereference(PROC_I(inode)->sysctl); in proc_sys_compare()
941 return !head || !sysctl_is_seen(head); in proc_sys_compare()
953 struct ctl_table_header *head; in find_subdir() local
956 entry = find_entry(&head, dir, name, namelen); in find_subdir()
961 return container_of(head, struct ctl_dir, header); in find_subdir()
1068 struct ctl_table_header *head; in sysctl_follow_link() local
1084 head = NULL; in sysctl_follow_link()
1085 entry = find_entry(&head, dir, procname, strlen(procname)); in sysctl_follow_link()
1087 if (entry && use_table(head)) { in sysctl_follow_link()
1089 *phead = head; in sysctl_follow_link()
1208 struct ctl_table_header *head; in get_links() local
1214 link = find_entry(&head, dir, procname, strlen(procname)); in get_links()
1227 link = find_entry(&head, dir, procname, strlen(procname)); in get_links()
1228 head->nreg++; in get_links()
1233 static int insert_links(struct ctl_table_header *head) in insert_links() argument
1240 if (head->set == root_set) in insert_links()
1243 core_parent = xlate_dir(root_set, head->parent); in insert_links()
1247 if (get_links(core_parent, head->ctl_table, head->root)) in insert_links()
1253 links = new_links(core_parent, head->ctl_table, head->root); in insert_links()
1261 if (get_links(core_parent, head->ctl_table, head->root)) { in insert_links()