Changeset View
Changeset View
Standalone View
Standalone View
sbin/mdconfig/mdconfig.c
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
#define CLASS_NAME_MD "MD" | #define CLASS_NAME_MD "MD" | ||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n" | "usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n" | ||||
" [-s size] [-S sectorsize] [-u unit]\n" | " [-s size] [-S sectorsize] [-u unit] [-L label]\n" | ||||
" [-x sectors/track] [-y heads/cylinder]\n" | " [-x sectors/track] [-y heads/cylinder]\n" | ||||
" mdconfig -d -u unit [-o [no]force]\n" | " mdconfig -d -u unit [-o [no]force]\n" | ||||
" mdconfig -r -u unit -s size [-o [no]force]\n" | " mdconfig -r -u unit -s size [-o [no]force]\n" | ||||
" mdconfig -l [-v] [-n] [-f file] [-u unit]\n" | " mdconfig -l [-v] [-n] [-f file] [-u unit]\n" | ||||
" mdconfig file\n"); | " mdconfig file\n"); | ||||
fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n"); | fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n"); | ||||
fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n"); | fprintf(stderr, "\t\toption = {cluster, compress, reserve}\n"); | ||||
fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n"); | fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n"); | ||||
fprintf(stderr, "\t\t %%dk (kB), %%dm (MB), %%dg (GB), \n"); | fprintf(stderr, "\t\t %%dk (kB), %%dm (MB), %%dg (GB), \n"); | ||||
fprintf(stderr, "\t\t %%dt (TB), or %%dp (PB)\n"); | fprintf(stderr, "\t\t %%dt (TB), or %%dp (PB)\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
int | int | ||||
main(int argc, char **argv) | main(int argc, char **argv) | ||||
{ | { | ||||
int ch, fd, i, vflag; | int ch, fd, i, vflag; | ||||
char *p; | char *p; | ||||
char *fflag = NULL, *sflag = NULL, *tflag = NULL, *uflag = NULL; | char *fflag = NULL, *sflag = NULL, *tflag = NULL, *uflag = NULL; | ||||
bzero(&mdio, sizeof(mdio)); | bzero(&mdio, sizeof(mdio)); | ||||
mdio.md_file = malloc(PATH_MAX); | mdio.md_file = malloc(PATH_MAX); | ||||
if (mdio.md_file == NULL) | mdio.md_label = malloc(PATH_MAX); | ||||
if (mdio.md_file == NULL || mdio.md_label == NULL) | |||||
err(1, "could not allocate memory"); | err(1, "could not allocate memory"); | ||||
vflag = 0; | vflag = 0; | ||||
bzero(mdio.md_file, PATH_MAX); | bzero(mdio.md_file, PATH_MAX); | ||||
bzero(mdio.md_label, PATH_MAX); | |||||
if (argc == 1) | if (argc == 1) | ||||
usage(); | usage(); | ||||
while ((ch = getopt(argc, argv, "ab:df:lno:rs:S:t:u:vx:y:")) != -1) { | while ((ch = getopt(argc, argv, "ab:df:lno:rs:S:t:u:vx:y:L:")) != -1) { | ||||
switch (ch) { | switch (ch) { | ||||
case 'a': | case 'a': | ||||
if (action != UNSET && action != ATTACH) | if (action != UNSET && action != ATTACH) | ||||
errx(1, "-a is mutually exclusive " | errx(1, "-a is mutually exclusive " | ||||
"with -d, -r, and -l"); | "with -d, -r, and -l"); | ||||
action = ATTACH; | action = ATTACH; | ||||
break; | break; | ||||
case 'd': | case 'd': | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | case 'v': | ||||
vflag = OPT_VERBOSE; | vflag = OPT_VERBOSE; | ||||
break; | break; | ||||
case 'x': | case 'x': | ||||
mdio.md_fwsectors = strtoul(optarg, &p, 0); | mdio.md_fwsectors = strtoul(optarg, &p, 0); | ||||
break; | break; | ||||
case 'y': | case 'y': | ||||
mdio.md_fwheads = strtoul(optarg, &p, 0); | mdio.md_fwheads = strtoul(optarg, &p, 0); | ||||
break; | break; | ||||
case 'L': | |||||
strlcpy(mdio.md_label, optarg, PATH_MAX); | |||||
break; | |||||
default: | default: | ||||
usage(); | usage(); | ||||
} | } | ||||
} | } | ||||
argc -= optind; | argc -= optind; | ||||
argv += optind; | argv += optind; | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | md_list(const char *units, int opt, const char *fflag) | ||||
struct gprovider *pp; | struct gprovider *pp; | ||||
struct gconf *gc; | struct gconf *gc; | ||||
struct gident *gid; | struct gident *gid; | ||||
struct devstat *gsp; | struct devstat *gsp; | ||||
struct ggeom *gg; | struct ggeom *gg; | ||||
struct gclass *gcl; | struct gclass *gcl; | ||||
void *sq; | void *sq; | ||||
int retcode, ffound, ufound; | int retcode, ffound, ufound; | ||||
char *type, *file, *length; | char *length; | ||||
const char *type, *file, *label; | |||||
type = file = length = NULL; | type = file = length = NULL; | ||||
retcode = geom_gettree(&gm); | retcode = geom_gettree(&gm); | ||||
if (retcode != 0) | if (retcode != 0) | ||||
return (-1); | return (-1); | ||||
retcode = geom_stats_open(); | retcode = geom_stats_open(); | ||||
if (retcode != 0) | if (retcode != 0) | ||||
Show All 38 Lines | if (gid->lg_what == ISPROVIDER) { | ||||
printf("%s", pp->lg_name); | printf("%s", pp->lg_name); | ||||
if (opt & OPT_VERBOSE || | if (opt & OPT_VERBOSE || | ||||
((opt & OPT_UNIT) && fflag == NULL)) { | ((opt & OPT_UNIT) && fflag == NULL)) { | ||||
length = geom_config_get(gc, "length"); | length = geom_config_get(gc, "length"); | ||||
printf("\t%s\t", type); | printf("\t%s\t", type); | ||||
if (length != NULL) | if (length != NULL) | ||||
md_prthumanval(length); | md_prthumanval(length); | ||||
if (file != NULL) { | if (file == NULL) | ||||
file = "-"; | |||||
printf("\t%s", file); | printf("\t%s", file); | ||||
file = NULL; | file = NULL; | ||||
} | label = geom_config_get(gc, "label"); | ||||
if (label == NULL) | |||||
label = ""; | |||||
printf("\t%s", label); | |||||
} | } | ||||
opt |= OPT_DONE; | opt |= OPT_DONE; | ||||
if ((opt & OPT_LIST) && !(opt & OPT_VERBOSE)) | if ((opt & OPT_LIST) && !(opt & OPT_VERBOSE)) | ||||
printf(" "); | printf(" "); | ||||
else | else | ||||
printf("\n"); | printf("\n"); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |