STARTUPHOOK_ESTABLISH(9)

πŸ“¦ in nixpkgs unstable

πŸ’… STARTUPHOOK_ESTABLISH(9) πŸ’…

okay bestie, welcome to the Kernel Developer's Manual corner where we talk startup hooks. This page is about startuphook_establish and startuphook_disestablish β€” the add/remove duo for startup hooks. It’s giving very specific kernel timing, and honestly? iconic. ✨


🌸 NAME 🌸

startuphook_establish, startuphook_disestablish β€” the duo that adds or removes a startup hook.

✨ SYNOPSIS ✨

#include <sys/types.h>
#include <sys/systm.h>

void *
startuphook_establish(void (*fn)(void *), void *arg);

void
startuphook_disestablish(void *cookie);

πŸ’– DESCRIPTION πŸ’–

So startuphook_establish() adds fn to the list of hooks that dostartuphooks(9) invokes at startup. When that hook gets invoked, the hook function fn receives arg as its only argument. Periodt.

startuphook_disestablish() removes the hook described by the opaque pointer cookie from the list of hooks to be invoked at startup. If cookie is invalid, the result of startuphook_disestablish() is undefined.

🚨 undefined behavior alert: invalid cookie means all bets are off for startuphook_disestablish().

Startup hooks are for one-time activities that must happen immediately before the root and swap devices are configured, but after normal device autoconfiguration. That timing window is the whole vibe. Also, startup hooks are implemented via the more general dohooks(9) API. iykyk.

🫢 RETURN VALUES 🫢

If it works, startuphook_establish() returns an opaque pointer describing the newly established startup hook. If not, it returns NULL. No cap.

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ’€ BUGS πŸ’€

ngl, the names are clumsy, at best. The functionality ate, but the naming? Not so much. 😭


πŸ’– cute sign-off: this page comes from Debian, dated December 10, 2014. bye bestie, go establish those hooks responsibly! πŸ’–

πŸ“¦ where this page comes from