G_PROVIDER(9)

πŸ’– G_PROVIDER(9) β€” the kernel dev manual, but make it cute πŸ’–

okay bestie, gather round β€” this is the page for the GEOM providers management trio: g_new_providerf, g_destroy_provider, and g_error_provider. Kernel devs only, no cap. 🫢


✨ NAME ✨

g_new_providerf, g_destroy_provider, g_error_provider β€” GEOM providers management πŸ’…


🌸 SYNOPSIS 🌸

#include <geom/geom.h>

struct g_provider *
g_new_providerf(struct g_geom *gp, const char *fmt, ...);

void
g_destroy_provider(struct g_provider *pp);

void
g_error_provider(struct g_provider *pp, int error);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, a GEOM provider is the front gate at which a geom offers service. Think of it as "a disk-like thing which appears in /dev" β€” a logical disk, in other words. 🌈 Every single provider has three main properties: name, sectorsize, and size. Those are the big three, the holy trinity, the main characters. πŸ‘‘

g_new_providerf() β€” this one creates a new provider on the given geom gp. πŸŽ€ The name of the provider, which is gonna show up as a device in devfs(5), gets built in a printf(3)-like way from the rest of the arguments. Very "fill in the blanks" of it. ✨

⚠️ But listen β€” after creation, the caller has to set the provider's mediasize and sectorsize, plus any other initializations it wants. Then it has to call g_error_provider() to reset the provider's error, which is initially set to ENXIO. Don't skip that step, bestie, it's giving unfinished business. 😭

g_destroy_provider() β€” destroys the given provider, cancels all related pending events, and removes the corresponding devfs entry. 🧹 Cleanup era. Bye bye, provider. πŸ‘‹

g_error_provider() β€” used to set the provider's error value. 🚨 If you set it to a nonzero value, all I/O requests will be denied, and increasing its access count will not be possible either (the error you passed in will be returned). It's giving "we're closed, go home." πŸ’€


πŸ”₯ RESTRICTIONS/CONDITIONS πŸ”₯

rules are rules, bestie, and these ones are non-negotiable fr fr

g_new_provider():

  • The provider name should be unique, but this is not enforced by GEOM. 😳 If the name isn't unique, you'll end up with two (or more) files with the same name β€” and that is a programmer error.
  • The geom gp has to have a start method defined. Periodt.
  • The topology lock has to be held. πŸ”’

g_destroy_provider():

  • The provider must not have consumers attached. πŸ™…
  • The access count has to be 0.
  • The topology lock has to be held. πŸ”’

⭐ RETURN VALUES ⭐

The g_new_providerf() function returns a pointer to the newly created provider. That's it, that's the return value. 🎁


πŸŽ€ EXAMPLES πŸŽ€

Create an example provider, set its parameters, and make it usable. Iconic behavior, honestly.

struct g_provider *
create_example_provider(struct g_geom *gp)
{
        struct g_provider *pp;

        g_topology_lock();
        pp = g_new_providerf(gp, "example_provider");
        g_topology_unlock();
        pp->mediasize = 65536;
        pp->sectorsize = 512;
        g_error_provider(pp, 0);

        return (pp);
}

Look at her. Locked, created, unlocked, sized up, error reset, returned. 🌟 Ate and left no crumbs.


πŸ‘€ SEE ALSO πŸ‘€

geom(4), DECLARE_GEOM_CLASS(9), g_access(9), g_attach(9), g_bio(9), g_consumer(9), g_data(9), g_event(9), g_geom(9), g_provider_by_name(9), g_wither_geom(9)

iykyk β€” go read those next, the lore runs deep. πŸ“š


πŸ’œ AUTHORS πŸ’œ

This manual page was written by Pawel Jakub Dawidek <pjd@FreeBSD.org>. 🫢


okay that's the whole page, you're officially a GEOM provider girlie now πŸ’…βœ¨ This little beauty comes to you from Debian, dated January 16, 2004 β€” yes, she's an elder but she still serves. πŸŽ€πŸ¦‹πŸŒΈ bye bestie, go hold that topology lock πŸ’–

πŸ“¦ where this page comes from