geom_part: Dispatch to partitions to create providers and aliases
This allows partitions to create additional aliases of their own. The default method implementations preserve the existing behavior. No functional change. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D24938
This commit is contained in:
parent
6f9454895c
commit
b71dc87559
@ -469,7 +469,6 @@ g_part_new_provider(struct g_geom *gp, struct g_part_table *table,
|
||||
{
|
||||
struct g_consumer *cp;
|
||||
struct g_provider *pp;
|
||||
struct sbuf *sb;
|
||||
struct g_geom_alias *gap;
|
||||
off_t offset;
|
||||
|
||||
@ -481,11 +480,7 @@ g_part_new_provider(struct g_geom *gp, struct g_part_table *table,
|
||||
entry->gpe_offset = offset;
|
||||
|
||||
if (entry->gpe_pp == NULL) {
|
||||
sb = sbuf_new_auto();
|
||||
G_PART_FULLNAME(table, entry, sb, gp->name);
|
||||
sbuf_finish(sb);
|
||||
entry->gpe_pp = g_new_providerf(gp, "%s", sbuf_data(sb));
|
||||
sbuf_delete(sb);
|
||||
entry->gpe_pp = G_PART_NEW_PROVIDER(table, gp, entry, gp->name);
|
||||
/*
|
||||
* If our parent provider had any aliases, then copy them to our
|
||||
* provider so when geom DEV tastes things later, they will be
|
||||
@ -493,13 +488,8 @@ g_part_new_provider(struct g_geom *gp, struct g_part_table *table,
|
||||
* place of the geom's name we use to create the provider. The
|
||||
* kobj interface that generates names makes this awkward.
|
||||
*/
|
||||
LIST_FOREACH(gap, &pp->aliases, ga_next) {
|
||||
sb = sbuf_new_auto();
|
||||
G_PART_FULLNAME(table, entry, sb, gap->ga_alias);
|
||||
sbuf_finish(sb);
|
||||
g_provider_add_alias(entry->gpe_pp, "%s", sbuf_data(sb));
|
||||
sbuf_delete(sb);
|
||||
}
|
||||
LIST_FOREACH(gap, &pp->aliases, ga_next)
|
||||
G_PART_ADD_ALIAS(table, entry->gpe_pp, entry, gap->ga_alias);
|
||||
entry->gpe_pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
|
||||
entry->gpe_pp->private = entry; /* Close the circle. */
|
||||
}
|
||||
|
@ -52,6 +52,34 @@ CODE {
|
||||
G_PART_NAME(table, entry, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
static struct g_provider *
|
||||
default_new_provider(struct g_part_table *table, struct g_geom *gp,
|
||||
struct g_part_entry *entry, const char *pfx)
|
||||
{
|
||||
struct g_provider *ret;
|
||||
struct sbuf *sb;
|
||||
|
||||
sb = sbuf_new_auto();
|
||||
G_PART_FULLNAME(table, entry, sb, pfx);
|
||||
sbuf_finish(sb);
|
||||
ret = g_new_providerf(gp, "%s", sbuf_data(sb));
|
||||
sbuf_delete(sb);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static void
|
||||
default_add_alias(struct g_part_table *table, struct g_provider *pp,
|
||||
struct g_part_entry *entry, const char *pfx)
|
||||
{
|
||||
struct sbuf *sb;
|
||||
|
||||
sb = sbuf_new_auto();
|
||||
G_PART_FULLNAME(table, entry, sb, pfx);
|
||||
sbuf_finish(sb);
|
||||
g_provider_add_alias(pp, "%s", sbuf_data(sb));
|
||||
sbuf_delete(sb);
|
||||
}
|
||||
|
||||
static int
|
||||
default_precheck(struct g_part_table *t __unused,
|
||||
enum g_part_ctl r __unused, struct g_part_parms *p __unused)
|
||||
@ -88,6 +116,15 @@ METHOD int add {
|
||||
struct g_part_parms *gpp;
|
||||
};
|
||||
|
||||
# add_alias() - Create aliases for the partition's provider with the given
|
||||
# alias prefixes.
|
||||
METHOD void add_alias {
|
||||
struct g_part_table *table;
|
||||
struct g_provider *pp;
|
||||
struct g_part_entry *entry;
|
||||
const char *pfx;
|
||||
} DEFAULT default_add_alias;
|
||||
|
||||
# bootcode() - scheme specific processing for the bootcode verb.
|
||||
METHOD int bootcode {
|
||||
struct g_part_table *table;
|
||||
@ -145,6 +182,14 @@ METHOD int modify {
|
||||
struct g_part_parms *gpp;
|
||||
};
|
||||
|
||||
# new_provider() - Create the partition's provider(s).
|
||||
METHOD struct g_provider * new_provider {
|
||||
struct g_part_table *table;
|
||||
struct g_geom *gp;
|
||||
struct g_part_entry *entry;
|
||||
const char *pfx;
|
||||
} DEFAULT default_new_provider;
|
||||
|
||||
# resize() - scheme specific processing for the resize verb.
|
||||
METHOD int resize {
|
||||
struct g_part_table *table;
|
||||
|
Loading…
x
Reference in New Issue
Block a user