Lines Matching refs:head
38 static bool is_empty_dir(struct ctl_table_header *head) in is_empty_dir() argument
40 return head->ctl_table[0].child == sysctl_mount_point; in is_empty_dir()
86 static int insert_links(struct ctl_table_header *head);
110 struct ctl_table_header *head; in find_entry() local
121 head = ctl_node->header; in find_entry()
122 entry = &head->ctl_table[ctl_node - head->node]; in find_entry()
131 *phead = head; in find_entry()
138 static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry) in insert_entry() argument
140 struct rb_node *node = &head->node[entry - head->ctl_table].node; in insert_entry()
141 struct rb_node **p = &head->parent->root.rb_node; in insert_entry()
166 sysctl_print_dir(head->parent); in insert_entry()
173 rb_insert_color(node, &head->parent->root); in insert_entry()
177 static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry) in erase_entry() argument
179 struct rb_node *node = &head->node[entry - head->ctl_table].node; in erase_entry()
181 rb_erase(node, &head->parent->root); in erase_entry()
184 static void init_header(struct ctl_table_header *head, in init_header() argument
188 head->ctl_table = table; in init_header()
189 head->ctl_table_arg = table; in init_header()
190 head->used = 0; in init_header()
191 head->count = 1; in init_header()
192 head->nreg = 1; in init_header()
193 head->unregistering = NULL; in init_header()
194 head->root = root; in init_header()
195 head->set = set; in init_header()
196 head->parent = NULL; in init_header()
197 head->node = node; in init_header()
198 INIT_HLIST_HEAD(&head->inodes); in init_header()
202 node->header = head; in init_header()
206 static void erase_header(struct ctl_table_header *head) in erase_header() argument
209 for (entry = head->ctl_table; entry->procname; entry++) in erase_header()
210 erase_entry(head, entry); in erase_header()
268 static void proc_sys_invalidate_dcache(struct ctl_table_header *head) in proc_sys_invalidate_dcache() argument
270 proc_invalidate_siblings_dcache(&head->inodes, &sysctl_lock); in proc_sys_invalidate_dcache()
304 static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) in sysctl_head_grab() argument
306 BUG_ON(!head); in sysctl_head_grab()
308 if (!use_table(head)) in sysctl_head_grab()
309 head = ERR_PTR(-ENOENT); in sysctl_head_grab()
311 return head; in sysctl_head_grab()
314 static void sysctl_head_finish(struct ctl_table_header *head) in sysctl_head_finish() argument
316 if (!head) in sysctl_head_finish()
319 unuse_table(head); in sysctl_head_finish()
336 struct ctl_table_header *head; in lookup_entry() local
340 entry = find_entry(&head, dir, name, namelen); in lookup_entry()
341 if (entry && use_table(head)) in lookup_entry()
342 *phead = head; in lookup_entry()
364 struct ctl_table_header *head = NULL; in first_entry() local
372 head = ctl_node->header; in first_entry()
373 entry = &head->ctl_table[ctl_node - head->node]; in first_entry()
375 *phead = head; in first_entry()
381 struct ctl_table_header *head = *phead; in next_entry() local
383 struct ctl_node *ctl_node = &head->node[entry - head->ctl_table]; in next_entry()
386 unuse_table(head); in next_entry()
390 head = NULL; in next_entry()
392 head = ctl_node->header; in next_entry()
393 entry = &head->ctl_table[ctl_node - head->node]; in next_entry()
395 *phead = head; in next_entry()
415 static int sysctl_perm(struct ctl_table_header *head, struct ctl_table *table, int op) in sysctl_perm() argument
417 struct ctl_table_root *root = head->root; in sysctl_perm()
421 mode = root->permissions(head, table); in sysctl_perm()
429 struct ctl_table_header *head, struct ctl_table *table) in proc_sys_make_inode() argument
431 struct ctl_table_root *root = head->root; in proc_sys_make_inode()
444 if (unlikely(head->unregistering)) { in proc_sys_make_inode()
449 ei->sysctl = head; in proc_sys_make_inode()
451 hlist_add_head_rcu(&ei->sibling_inodes, &head->inodes); in proc_sys_make_inode()
452 head->count++; in proc_sys_make_inode()
465 if (is_empty_dir(head)) in proc_sys_make_inode()
470 root->set_ownership(head, table, &inode->i_uid, &inode->i_gid); in proc_sys_make_inode()
479 void proc_sys_evict_inode(struct inode *inode, struct ctl_table_header *head) in proc_sys_evict_inode() argument
483 if (!--head->count) in proc_sys_evict_inode()
484 kfree_rcu(head, rcu); in proc_sys_evict_inode()
490 struct ctl_table_header *head = PROC_I(inode)->sysctl; in grab_header() local
491 if (!head) in grab_header()
492 head = &sysctl_table_root.default_set.dir.header; in grab_header()
493 return sysctl_head_grab(head); in grab_header()
499 struct ctl_table_header *head = grab_header(dir); in proc_sys_lookup() local
508 if (IS_ERR(head)) in proc_sys_lookup()
509 return ERR_CAST(head); in proc_sys_lookup()
511 ctl_dir = container_of(head, struct ctl_dir, header); in proc_sys_lookup()
524 inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p); in proc_sys_lookup()
536 sysctl_head_finish(head); in proc_sys_lookup()
544 struct ctl_table_header *head = grab_header(inode); in proc_sys_call_handler() local
550 if (IS_ERR(head)) in proc_sys_call_handler()
551 return PTR_ERR(head); in proc_sys_call_handler()
558 if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ)) in proc_sys_call_handler()
581 error = BPF_CGROUP_RUN_PROG_SYSCTL(head, table, write, &kbuf, &count, in proc_sys_call_handler()
601 sysctl_head_finish(head); in proc_sys_call_handler()
618 struct ctl_table_header *head = grab_header(inode); in proc_sys_open() local
622 if (IS_ERR(head)) in proc_sys_open()
623 return PTR_ERR(head); in proc_sys_open()
628 sysctl_head_finish(head); in proc_sys_open()
636 struct ctl_table_header *head = grab_header(inode); in proc_sys_poll() local
642 if (IS_ERR(head)) in proc_sys_poll()
660 sysctl_head_finish(head); in proc_sys_poll()
667 struct ctl_table_header *head, in proc_sys_fill_cache() argument
688 inode = proc_sys_make_inode(dir->d_sb, head, table); in proc_sys_fill_cache()
716 struct ctl_table_header *head, in proc_sys_link_fill_cache() argument
721 head = sysctl_head_grab(head); in proc_sys_link_fill_cache()
722 if (IS_ERR(head)) in proc_sys_link_fill_cache()
726 if (sysctl_follow_link(&head, &table)) in proc_sys_link_fill_cache()
729 ret = proc_sys_fill_cache(file, ctx, head, table); in proc_sys_link_fill_cache()
731 sysctl_head_finish(head); in proc_sys_link_fill_cache()
735 static int scan(struct ctl_table_header *head, struct ctl_table *table, in scan() argument
745 res = proc_sys_link_fill_cache(file, ctx, head, table); in scan()
747 res = proc_sys_fill_cache(file, ctx, head, table); in scan()
757 struct ctl_table_header *head = grab_header(file_inode(file)); in proc_sys_readdir() local
763 if (IS_ERR(head)) in proc_sys_readdir()
764 return PTR_ERR(head); in proc_sys_readdir()
766 ctl_dir = container_of(head, struct ctl_dir, header); in proc_sys_readdir()
780 sysctl_head_finish(head); in proc_sys_readdir()
791 struct ctl_table_header *head; in proc_sys_permission() local
799 head = grab_header(inode); in proc_sys_permission()
800 if (IS_ERR(head)) in proc_sys_permission()
801 return PTR_ERR(head); in proc_sys_permission()
807 error = sysctl_perm(head, table, mask & ~MAY_NOT_BLOCK); in proc_sys_permission()
809 sysctl_head_finish(head); in proc_sys_permission()
836 struct ctl_table_header *head = grab_header(inode); in proc_sys_getattr() local
839 if (IS_ERR(head)) in proc_sys_getattr()
840 return PTR_ERR(head); in proc_sys_getattr()
846 sysctl_head_finish(head); in proc_sys_getattr()
909 struct ctl_table_header *head; in proc_sys_compare() local
922 head = rcu_dereference(PROC_I(inode)->sysctl); in proc_sys_compare()
923 return !head || !sysctl_is_seen(head); in proc_sys_compare()
935 struct ctl_table_header *head; in find_subdir() local
938 entry = find_entry(&head, dir, name, namelen); in find_subdir()
943 return container_of(head, struct ctl_dir, header); in find_subdir()
1050 struct ctl_table_header *head; in sysctl_follow_link() local
1066 head = NULL; in sysctl_follow_link()
1067 entry = find_entry(&head, dir, procname, strlen(procname)); in sysctl_follow_link()
1069 if (entry && use_table(head)) { in sysctl_follow_link()
1071 *phead = head; in sysctl_follow_link()
1196 struct ctl_table_header *head; in get_links() local
1202 link = find_entry(&head, dir, procname, strlen(procname)); in get_links()
1215 link = find_entry(&head, dir, procname, strlen(procname)); in get_links()
1216 head->nreg++; in get_links()
1221 static int insert_links(struct ctl_table_header *head) in insert_links() argument
1228 if (head->set == root_set) in insert_links()
1231 core_parent = xlate_dir(root_set, head->parent); in insert_links()
1235 if (get_links(core_parent, head->ctl_table, head->root)) in insert_links()
1241 links = new_links(core_parent, head->ctl_table, head->root); in insert_links()
1249 if (get_links(core_parent, head->ctl_table, head->root)) { in insert_links()