Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/part/g_part.c
Show First 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
g_part_new_provider(struct g_geom *gp, struct g_part_table *table, | g_part_new_provider(struct g_geom *gp, struct g_part_table *table, | ||||
struct g_part_entry *entry) | struct g_part_entry *entry) | ||||
{ | { | ||||
struct g_consumer *cp; | struct g_consumer *cp; | ||||
struct g_provider *pp; | struct g_provider *pp; | ||||
struct sbuf *sb; | |||||
struct g_geom_alias *gap; | struct g_geom_alias *gap; | ||||
off_t offset; | off_t offset; | ||||
cp = LIST_FIRST(&gp->consumer); | cp = LIST_FIRST(&gp->consumer); | ||||
pp = cp->provider; | pp = cp->provider; | ||||
offset = entry->gpe_start * pp->sectorsize; | offset = entry->gpe_start * pp->sectorsize; | ||||
if (entry->gpe_offset < offset) | if (entry->gpe_offset < offset) | ||||
entry->gpe_offset = offset; | entry->gpe_offset = offset; | ||||
if (entry->gpe_pp == NULL) { | if (entry->gpe_pp == NULL) { | ||||
sb = sbuf_new_auto(); | entry->gpe_pp = G_PART_NEW_PROVIDER(table, gp, entry, gp->name); | ||||
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); | |||||
/* | /* | ||||
* If our parent provider had any aliases, then copy them to our | * If our parent provider had any aliases, then copy them to our | ||||
* provider so when geom DEV tastes things later, they will be | * provider so when geom DEV tastes things later, they will be | ||||
* there for it to create the aliases with those name used in | * there for it to create the aliases with those name used in | ||||
* place of the geom's name we use to create the provider. The | * place of the geom's name we use to create the provider. The | ||||
* kobj interface that generates names makes this awkward. | * kobj interface that generates names makes this awkward. | ||||
*/ | */ | ||||
LIST_FOREACH(gap, &pp->aliases, ga_next) { | LIST_FOREACH(gap, &pp->aliases, ga_next) | ||||
sb = sbuf_new_auto(); | G_PART_ADD_ALIAS(table, entry->gpe_pp, entry, gap->ga_alias); | ||||
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); | |||||
} | |||||
entry->gpe_pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; | entry->gpe_pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; | ||||
entry->gpe_pp->private = entry; /* Close the circle. */ | entry->gpe_pp->private = entry; /* Close the circle. */ | ||||
} | } | ||||
entry->gpe_pp->index = entry->gpe_index - 1; /* index is 1-based. */ | entry->gpe_pp->index = entry->gpe_index - 1; /* index is 1-based. */ | ||||
entry->gpe_pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * | entry->gpe_pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * | ||||
pp->sectorsize; | pp->sectorsize; | ||||
entry->gpe_pp->mediasize -= entry->gpe_offset - offset; | entry->gpe_pp->mediasize -= entry->gpe_offset - offset; | ||||
entry->gpe_pp->sectorsize = pp->sectorsize; | entry->gpe_pp->sectorsize = pp->sectorsize; | ||||
▲ Show 20 Lines • Show All 1,924 Lines • Show Last 20 Lines |