Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/label/g_label.c
Show First 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) | ||||
if (strcmp(pp->geom->class->name, mp->name) == 0) | if (strcmp(pp->geom->class->name, mp->name) == 0) | ||||
return (NULL); | return (NULL); | ||||
gp = g_new_geomf(mp, "label:taste"); | gp = g_new_geomf(mp, "label:taste"); | ||||
gp->start = g_label_start_taste; | gp->start = g_label_start_taste; | ||||
gp->access = g_label_access_taste; | gp->access = g_label_access_taste; | ||||
gp->orphan = g_label_orphan_taste; | gp->orphan = g_label_orphan_taste; | ||||
cp = g_new_consumer(gp); | cp = g_new_consumer(gp); | ||||
g_attach(cp, pp); | if (g_attach(cp, pp) != 0) | ||||
goto end2; | |||||
if (g_access(cp, 1, 0, 0) != 0) | if (g_access(cp, 1, 0, 0) != 0) | ||||
goto end; | goto end; | ||||
for (i = 0; g_labels[i] != NULL; i++) { | for (i = 0; g_labels[i] != NULL; i++) { | ||||
char label[128]; | char label[128]; | ||||
if (g_labels[i]->ld_enabled == 0) | if (g_labels[i]->ld_enabled == 0) | ||||
continue; | continue; | ||||
g_topology_unlock(); | g_topology_unlock(); | ||||
g_labels[i]->ld_taste(cp, label, sizeof(label)); | g_labels[i]->ld_taste(cp, label, sizeof(label)); | ||||
g_label_mangle_name(label, sizeof(label)); | g_label_mangle_name(label, sizeof(label)); | ||||
g_topology_lock(); | g_topology_lock(); | ||||
if (label[0] == '\0') | if (label[0] == '\0') | ||||
continue; | continue; | ||||
if (g_labels[i] != &g_label_generic) { | if (g_labels[i] != &g_label_generic) { | ||||
mediasize = pp->mediasize; | mediasize = pp->mediasize; | ||||
} else { | } else { | ||||
mediasize = pp->mediasize - pp->sectorsize; | mediasize = pp->mediasize - pp->sectorsize; | ||||
} | } | ||||
g_label_create(NULL, mp, pp, label, | g_label_create(NULL, mp, pp, label, | ||||
g_labels[i]->ld_dirprefix, mediasize); | g_labels[i]->ld_dirprefix, mediasize); | ||||
} | } | ||||
g_access(cp, -1, 0, 0); | g_access(cp, -1, 0, 0); | ||||
end: | end: | ||||
g_detach(cp); | g_detach(cp); | ||||
end2: | |||||
g_destroy_consumer(cp); | g_destroy_consumer(cp); | ||||
g_destroy_geom(gp); | g_destroy_geom(gp); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static void | static void | ||||
g_label_ctl_create(struct gctl_req *req, struct g_class *mp) | g_label_ctl_create(struct gctl_req *req, struct g_class *mp) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |