list_cut_before(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… list_cut_before β€” cut a list into two, before given entry

okay bestie, welcome to list_cut_before(9) from the Kernel API Manual ✨ this one's a little linker-list surgery situation and honestly it's giving "snip snip, no cap" πŸ’–


✨ SYNOPSIS ✨

void list_cut_before (struct list_head *list , struct list_head *head ,
       struct list_head *entry );

literally just three pointers and vibes, that's the whole signature πŸŽ€


🫢 ARGUMENTS 🫢

  • list β€” a new list to add all removed entries. she's the destination, the receiving queen πŸ‘‘
  • head β€” a list with entries. this is the one getting chopped 🌸
  • entry β€” an entry within head, could be the head itself. yes bestie, literally the head is allowed, that's not a typo πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• this helper moves the initial part of head, up to but excluding entry, from head to list. like it takes everything before entry and rehomes it 🌈

you should pass in entry an element you know is on head. ma'am. fr fr. don't be passing random entries, that's not the vibe πŸ’€

list should be an empty list or a list you do not care about losing its data. read that again β€” if list already had stuff in it, that data is GONE, so only hand it something empty or something you're fully okay with losing 🫢

and if entry == head, all entries on head are moved to list. the whole thing. every single one. iconic behavior honestly πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./include/linux/list.h β€” and the whole friend group shows up too:

LIST_HEAD_INIT(9), LIST_HEAD(9), LIST_HEAD_GUARDED(9), INIT_LIST_HEAD(9), list_add(9), list_add_tail(9), list_add_tail_release(9), list_del(9), list_replace(9), list_replace_init(9), list_swap(9), list_del_init(9), list_move(9), list_move_tail(9), list_bulk_move_tail(9), list_is_first(9), list_is_last(9), list_is_head(9), list_empty(9), list_del_init_careful(9), list_empty_careful(9), list_rotate_left(9), list_rotate_to_front(9), list_is_singular(9), list_cut_position(9), list_splice(9), list_splice_tail(9), list_splice_init(9), list_splice_tail_init(9), list_entry(9), list_first_entry(9), list_last_entry(9), list_first_entry_or_null(9), list_first_entry_or_null_acquire(9), list_last_entry_or_null(9), list_next_entry(9), list_next_entry_circular(9), list_prev_entry(9), list_prev_entry_circular(9), list_for_each(9), list_for_each_continue(9), list_for_each_prev(9), list_for_each_safe(9), list_for_each_prev_safe(9), list_count_nodes(9), list_entry_is_head(9), list_for_each_entry(9), list_for_each_entry_reverse(9), list_prepare_entry(9), list_for_each_entry_continue(9), list_for_each_entry_continue_reverse(9), list_for_each_entry_from(9), list_for_each_entry_from_reverse(9), list_for_each_entry_safe(9), list_for_each_entry_safe_continue(9), list_for_each_entry_safe_from(9), list_for_each_entry_safe_reverse(9), list_safe_reset_next(9), hlist_unhashed(9), hlist_unhashed_lockless(9), hlist_empty(9), hlist_del(9), hlist_del_init(9), hlist_add_head(9), hlist_add_before(9), hlist_add_behind(9), hlist_add_fake(9), hlist_fake(9), hlist_is_singular_node(9), hlist_move_list(9), hlist_splice_init(9), hlist_for_each_entry(9), hlist_for_each_entry_continue(9), hlist_for_each_entry_from(9), hlist_for_each_entry_safe(9), hlist_count_nodes(9)

like I said. the whole friend group. iykyk πŸ’œ


that's the page bestie, go forth and cut lists responsibly πŸ’…βœ¨

signed off from ./include/linux, dated October 2026 β€” see u in the next manpage, mwah πŸŽ€

πŸ“¦ where this page comes from