G_PROVIDER(9)
β¨ 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
gphas to have astartmethod 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
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms