Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/vinum/geom_vinum_share.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <geom/geom.h> | |||||
#define iswhite(c) (((c) == ' ') || ((c) == '\t')) | #define iswhite(c) (((c) == ' ') || ((c) == '\t')) | ||||
#else | #else | ||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <paths.h> | #include <paths.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#define iswhite isspace | #define iswhite isspace | ||||
#define g_free free | #define g_free free | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#include <geom/geom.h> | |||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <geom/vinum/geom_vinum_var.h> | #include <geom/vinum/geom_vinum_var.h> | ||||
#include <geom/vinum/geom_vinum_share.h> | #include <geom/vinum/geom_vinum_share.h> | ||||
/* | /* | ||||
* Take a blank separated list of tokens and turn it into a list of | * Take a blank separated list of tokens and turn it into a list of | ||||
▲ Show 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* Get a new drive object. */ | /* Get a new drive object. */ | ||||
struct gv_drive * | struct gv_drive * | ||||
gv_new_drive(int max, char *token[]) | gv_new_drive(int max, char *token[]) | ||||
{ | { | ||||
struct gv_drive *d; | struct gv_drive *d; | ||||
int j, errors; | int j, errors; | ||||
char *ptr; | const char *ptr; | ||||
if (token[1] == NULL || *token[1] == '\0') | if (token[1] == NULL || *token[1] == '\0') | ||||
return (NULL); | return (NULL); | ||||
d = gv_alloc_drive(); | d = gv_alloc_drive(); | ||||
if (d == NULL) | if (d == NULL) | ||||
return (NULL); | return (NULL); | ||||
errors = 0; | errors = 0; | ||||
for (j = 1; j < max; j++) { | for (j = 1; j < max; j++) { | ||||
if (!strcmp(token[j], "state")) { | if (!strcmp(token[j], "state")) { | ||||
j++; | j++; | ||||
if (j >= max) { | if (j >= max) { | ||||
errors++; | errors++; | ||||
break; | break; | ||||
} | } | ||||
d->state = gv_drivestatei(token[j]); | d->state = gv_drivestatei(token[j]); | ||||
} else if (!strcmp(token[j], "device")) { | } else if (!strcmp(token[j], "device")) { | ||||
j++; | j++; | ||||
if (j >= max) { | if (j >= max) { | ||||
errors++; | errors++; | ||||
break; | break; | ||||
} | } | ||||
ptr = token[j]; | ptr = g_provider_name(token[j]); | ||||
if (strncmp(ptr, _PATH_DEV, 5) == 0) | |||||
ptr += 5; | |||||
strlcpy(d->device, ptr, sizeof(d->device)); | strlcpy(d->device, ptr, sizeof(d->device)); | ||||
} else { | } else { | ||||
/* We assume this is the drive name. */ | /* We assume this is the drive name. */ | ||||
strlcpy(d->name, token[j], sizeof(d->name)); | strlcpy(d->name, token[j], sizeof(d->name)); | ||||
} | } | ||||
} | } | ||||
if (strlen(d->name) == 0 || strlen(d->device) == 0) | if (strlen(d->name) == 0 || strlen(d->device) == 0) | ||||
▲ Show 20 Lines • Show All 250 Lines • Show Last 20 Lines |