Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/label/g_label.c
Show First 20 Lines • Show All 436 Lines • ▼ Show 20 Lines | g_label_ctl_create(struct gctl_req *req, struct g_class *mp) | ||||
/* | /* | ||||
* arg1 is the name of provider. | * arg1 is the name of provider. | ||||
*/ | */ | ||||
name = gctl_get_asciiparam(req, "arg1"); | name = gctl_get_asciiparam(req, "arg1"); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
gctl_error(req, "No 'arg%d' argument", 1); | gctl_error(req, "No 'arg%d' argument", 1); | ||||
return; | return; | ||||
} | } | ||||
if (strncmp(name, "/dev/", strlen("/dev/")) == 0) | if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) | ||||
name += strlen("/dev/"); | name += strlen(_PATH_DEV); | ||||
pp = g_provider_by_name(name); | pp = g_provider_by_name(name); | ||||
if (pp == NULL) { | if (pp == NULL) { | ||||
G_LABEL_DEBUG(1, "Provider %s is invalid.", name); | G_LABEL_DEBUG(1, "Provider %s is invalid.", name); | ||||
gctl_error(req, "Provider %s is invalid.", name); | gctl_error(req, "Provider %s is invalid.", name); | ||||
return; | return; | ||||
} | } | ||||
/* | /* | ||||
* arg0 is the label. | * arg0 is the label. | ||||
*/ | */ | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_asciiparam(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
gctl_error(req, "No 'arg%d' argument", 0); | gctl_error(req, "No 'arg%d' argument", 0); | ||||
return; | return; | ||||
} | } | ||||
g_label_create(req, mp, pp, name, G_LABEL_DIR, pp->mediasize); | g_label_create(req, mp, pp, name, G_LABEL_DIR, pp->mediasize); | ||||
} | } | ||||
static const char * | static const char * | ||||
g_label_skip_dir(const char *name) | g_label_skip_dir(const char *name) | ||||
{ | { | ||||
char path[64]; | char path[64]; | ||||
u_int i; | u_int i; | ||||
if (strncmp(name, "/dev/", strlen("/dev/")) == 0) | if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) | ||||
name += strlen("/dev/"); | name += strlen(_PATH_DEV); | ||||
if (strncmp(name, G_LABEL_DIR "/", strlen(G_LABEL_DIR "/")) == 0) | if (strncmp(name, G_LABEL_DIR "/", strlen(G_LABEL_DIR "/")) == 0) | ||||
name += strlen(G_LABEL_DIR "/"); | name += strlen(G_LABEL_DIR "/"); | ||||
for (i = 0; g_labels[i] != NULL; i++) { | for (i = 0; g_labels[i] != NULL; i++) { | ||||
snprintf(path, sizeof(path), "%s/", g_labels[i]->ld_dir); | snprintf(path, sizeof(path), "%s/", g_labels[i]->ld_dir); | ||||
if (strncmp(name, path, strlen(path)) == 0) { | if (strncmp(name, path, strlen(path)) == 0) { | ||||
name += strlen(path); | name += strlen(path); | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |