Lines Matching refs:head
30 static bool is_empty_dir(struct ctl_table_header *head) in is_empty_dir() argument
32 return head->ctl_table[0].child == sysctl_mount_point; in is_empty_dir()
78 static int insert_links(struct ctl_table_header *head);
107 struct ctl_table_header *head; in find_entry() local
118 head = ctl_node->header; in find_entry()
119 entry = &head->ctl_table[ctl_node - head->node]; in find_entry()
128 *phead = head; in find_entry()
135 static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry) in insert_entry() argument
137 struct rb_node *node = &head->node[entry - head->ctl_table].node; in insert_entry()
138 struct rb_node **p = &head->parent->root.rb_node; in insert_entry()
163 sysctl_print_dir(head->parent); in insert_entry()
170 rb_insert_color(node, &head->parent->root); in insert_entry()
174 static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry) in erase_entry() argument
176 struct rb_node *node = &head->node[entry - head->ctl_table].node; in erase_entry()
178 rb_erase(node, &head->parent->root); in erase_entry()
181 static void init_header(struct ctl_table_header *head, in init_header() argument
185 head->ctl_table = table; in init_header()
186 head->ctl_table_arg = table; in init_header()
187 head->used = 0; in init_header()
188 head->count = 1; in init_header()
189 head->nreg = 1; in init_header()
190 head->unregistering = NULL; in init_header()
191 head->root = root; in init_header()
192 head->set = set; in init_header()
193 head->parent = NULL; in init_header()
194 head->node = node; in init_header()
195 INIT_HLIST_HEAD(&head->inodes); in init_header()
199 node->header = head; in init_header()
203 static void erase_header(struct ctl_table_header *head) in erase_header() argument
206 for (entry = head->ctl_table; entry->procname; entry++) in erase_header()
207 erase_entry(head, entry); in erase_header()
265 static void proc_sys_prune_dcache(struct ctl_table_header *head) in proc_sys_prune_dcache() argument
274 node = hlist_first_rcu(&head->inodes); in proc_sys_prune_dcache()
334 static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) in sysctl_head_grab() argument
336 BUG_ON(!head); in sysctl_head_grab()
338 if (!use_table(head)) in sysctl_head_grab()
339 head = ERR_PTR(-ENOENT); in sysctl_head_grab()
341 return head; in sysctl_head_grab()
344 static void sysctl_head_finish(struct ctl_table_header *head) in sysctl_head_finish() argument
346 if (!head) in sysctl_head_finish()
349 unuse_table(head); in sysctl_head_finish()
366 struct ctl_table_header *head; in lookup_entry() local
370 entry = find_entry(&head, dir, name, namelen); in lookup_entry()
371 if (entry && use_table(head)) in lookup_entry()
372 *phead = head; in lookup_entry()
394 struct ctl_table_header *head = NULL; in first_entry() local
402 head = ctl_node->header; in first_entry()
403 entry = &head->ctl_table[ctl_node - head->node]; in first_entry()
405 *phead = head; in first_entry()
411 struct ctl_table_header *head = *phead; in next_entry() local
413 struct ctl_node *ctl_node = &head->node[entry - head->ctl_table]; in next_entry()
416 unuse_table(head); in next_entry()
420 head = NULL; in next_entry()
422 head = ctl_node->header; in next_entry()
423 entry = &head->ctl_table[ctl_node - head->node]; in next_entry()
425 *phead = head; in next_entry()
445 static int sysctl_perm(struct ctl_table_header *head, struct ctl_table *table, int op) in sysctl_perm() argument
447 struct ctl_table_root *root = head->root; in sysctl_perm()
451 mode = root->permissions(head, table); in sysctl_perm()
459 struct ctl_table_header *head, struct ctl_table *table) in proc_sys_make_inode() argument
461 struct ctl_table_root *root = head->root; in proc_sys_make_inode()
474 if (unlikely(head->unregistering)) { in proc_sys_make_inode()
480 ei->sysctl = head; in proc_sys_make_inode()
482 hlist_add_head_rcu(&ei->sysctl_inodes, &head->inodes); in proc_sys_make_inode()
483 head->count++; in proc_sys_make_inode()
496 if (is_empty_dir(head)) in proc_sys_make_inode()
501 root->set_ownership(head, table, &inode->i_uid, &inode->i_gid); in proc_sys_make_inode()
507 void proc_sys_evict_inode(struct inode *inode, struct ctl_table_header *head) in proc_sys_evict_inode() argument
511 if (!--head->count) in proc_sys_evict_inode()
512 kfree_rcu(head, rcu); in proc_sys_evict_inode()
518 struct ctl_table_header *head = PROC_I(inode)->sysctl; in grab_header() local
519 if (!head) in grab_header()
520 head = &sysctl_table_root.default_set.dir.header; in grab_header()
521 return sysctl_head_grab(head); in grab_header()
527 struct ctl_table_header *head = grab_header(dir); in proc_sys_lookup() local
536 if (IS_ERR(head)) in proc_sys_lookup()
537 return ERR_CAST(head); in proc_sys_lookup()
539 ctl_dir = container_of(head, struct ctl_dir, header); in proc_sys_lookup()
553 inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p); in proc_sys_lookup()
563 sysctl_head_finish(head); in proc_sys_lookup()
571 struct ctl_table_header *head = grab_header(inode); in proc_sys_call_handler() local
576 if (IS_ERR(head)) in proc_sys_call_handler()
577 return PTR_ERR(head); in proc_sys_call_handler()
584 if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ)) in proc_sys_call_handler()
598 sysctl_head_finish(head); in proc_sys_call_handler()
617 struct ctl_table_header *head = grab_header(inode); in proc_sys_open() local
621 if (IS_ERR(head)) in proc_sys_open()
622 return PTR_ERR(head); in proc_sys_open()
627 sysctl_head_finish(head); in proc_sys_open()
635 struct ctl_table_header *head = grab_header(inode); in proc_sys_poll() local
641 if (IS_ERR(head)) in proc_sys_poll()
659 sysctl_head_finish(head); in proc_sys_poll()
666 struct ctl_table_header *head, in proc_sys_fill_cache() argument
687 inode = proc_sys_make_inode(dir->d_sb, head, table); in proc_sys_fill_cache()
715 struct ctl_table_header *head, in proc_sys_link_fill_cache() argument
720 head = sysctl_head_grab(head); in proc_sys_link_fill_cache()
721 if (IS_ERR(head)) in proc_sys_link_fill_cache()
725 if (sysctl_follow_link(&head, &table)) in proc_sys_link_fill_cache()
728 ret = proc_sys_fill_cache(file, ctx, head, table); in proc_sys_link_fill_cache()
730 sysctl_head_finish(head); in proc_sys_link_fill_cache()
734 static int scan(struct ctl_table_header *head, struct ctl_table *table, in scan() argument
744 res = proc_sys_link_fill_cache(file, ctx, head, table); in scan()
746 res = proc_sys_fill_cache(file, ctx, head, table); in scan()
756 struct ctl_table_header *head = grab_header(file_inode(file)); in proc_sys_readdir() local
762 if (IS_ERR(head)) in proc_sys_readdir()
763 return PTR_ERR(head); in proc_sys_readdir()
765 ctl_dir = container_of(head, struct ctl_dir, header); in proc_sys_readdir()
779 sysctl_head_finish(head); in proc_sys_readdir()
789 struct ctl_table_header *head; in proc_sys_permission() local
797 head = grab_header(inode); in proc_sys_permission()
798 if (IS_ERR(head)) in proc_sys_permission()
799 return PTR_ERR(head); in proc_sys_permission()
805 error = sysctl_perm(head, table, mask & ~MAY_NOT_BLOCK); in proc_sys_permission()
807 sysctl_head_finish(head); in proc_sys_permission()
832 struct ctl_table_header *head = grab_header(inode); in proc_sys_getattr() local
835 if (IS_ERR(head)) in proc_sys_getattr()
836 return PTR_ERR(head); in proc_sys_getattr()
842 sysctl_head_finish(head); in proc_sys_getattr()
903 struct ctl_table_header *head; in proc_sys_compare() local
916 head = rcu_dereference(PROC_I(inode)->sysctl); in proc_sys_compare()
917 return !head || !sysctl_is_seen(head); in proc_sys_compare()
929 struct ctl_table_header *head; in find_subdir() local
932 entry = find_entry(&head, dir, name, namelen); in find_subdir()
937 return container_of(head, struct ctl_dir, header); in find_subdir()
1044 struct ctl_table_header *head; in sysctl_follow_link() local
1060 head = NULL; in sysctl_follow_link()
1061 entry = find_entry(&head, dir, procname, strlen(procname)); in sysctl_follow_link()
1063 if (entry && use_table(head)) { in sysctl_follow_link()
1065 *phead = head; in sysctl_follow_link()
1184 struct ctl_table_header *head; in get_links() local
1190 link = find_entry(&head, dir, procname, strlen(procname)); in get_links()
1203 link = find_entry(&head, dir, procname, strlen(procname)); in get_links()
1204 head->nreg++; in get_links()
1209 static int insert_links(struct ctl_table_header *head) in insert_links() argument
1216 if (head->set == root_set) in insert_links()
1219 core_parent = xlate_dir(root_set, head->parent); in insert_links()
1223 if (get_links(core_parent, head->ctl_table, head->root)) in insert_links()
1229 links = new_links(core_parent, head->ctl_table, head->root); in insert_links()
1237 if (get_links(core_parent, head->ctl_table, head->root)) { in insert_links()