G_PROVIDER(9)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1, nixpkgs unstable

✨ G_PROVIDER(9) ✨

okay so this is a page from the Kernel Developer's Manual, and it's all about managing GEOM providers β€” like, the whole g_new_providerf, g_destroy_provider, g_error_provider situation. bestie, let's get into it πŸ’…


πŸŽ€ NAME πŸŽ€

g_new_providerf, g_destroy_provider, g_error_provider β€” GEOM providers management, aka keeping your logical disks in check ✨


🌸 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 a GEOM provider is literally the front gate where a geom offers service 🫢. It's "a disk-like thing which appears in /dev" β€” a logical disk, in other words. Every provider has three main properties, no cap: name, sectorsize, and size. iconic.

g_new_providerf() β€” this one creates a new provider on the given geom gp. The name of the provider, which will show up as a device in devfs(4), gets built in a printf(3)-like way from the rest of the arguments. after creation, the caller has to set the provider's mediasize and sectorsize, plus any other initializations they want, and then call g_error_provider() to reset the provider's error β€” which is initially set to ENXIO. don't forget that part, bestie πŸ™ˆ

g_destroy_provider() β€” destroys the given provider, cancels all related pending events, and removes the corresponding devfs entry. it's giving cleanup era ✨

g_error_provider() β€” used to set the provider's error value. if you set it to a nonzero, all I/O requests will be denied, and increasing its access count won't be possible either (the error error will be returned). so like, expect to be told no πŸ’€


πŸ’… RESTRICTIONS/CONDITIONS πŸ’…

g_new_provider():

  • The provider name should be unique, but GEOM does not enforce this 🫠. if the name is not unique, you'll end up with two (or more) files with the same name β€” which is a programmer error. yeah. that's on you.
  • The geom gp has to have a start method defined. required, no exceptions πŸ”₯
  • The topology lock has to be held. periodt.

g_destroy_provider():

  • The provider must not have consumers attached. nope, not even one πŸ™…β€β™€οΈ
  • The access count has to be 0.
  • The topology lock has to be held. same rule as above, bestie.

⭐ RETURN VALUES ⭐

The g_new_providerf() function returns a pointer to the newly created provider. slay πŸ’–


🌈 EXAMPLES 🌈

Create an example provider, set its parameters, and make it usable. look at her go πŸ‘‘

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);
}

πŸ”₯ 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) β€” go read these too, iykyk πŸ“š


πŸ‘‘ AUTHORS πŸ‘‘

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


ngl this whole page is from the Debian edition of the Kernel Developer's Manual, dated January 16, 2004, and it's filed under G_PROVIDER(9). that's the vibe check, we're done here πŸ’œβœ¨
πŸ“¦ where this page comes from