Lines Matching +full:- +full:gp
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@FreeBSD.org>
94 "[-a] [name ...]"
103 "[-ags] [name ...]"
117 if (cmd->gc_usage != NULL) { in usage_command()
120 sptr = ptr = strdup(cmd->gc_usage); in usage_command()
125 cmd->gc_name, pos); in usage_command()
131 fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); in usage_command()
132 if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0) in usage_command()
133 fprintf(stderr, " [-v]"); in usage_command()
135 opt = &cmd->gc_options[i]; in usage_command()
136 if (opt->go_name == NULL) in usage_command()
138 if (opt->go_val != NULL || G_OPT_TYPE(opt) == G_TYPE_BOOL) in usage_command()
142 fprintf(stderr, "-%c", opt->go_char); in usage_command()
144 fprintf(stderr, " %s", opt->go_name); in usage_command()
145 if (opt->go_val != NULL || G_OPT_TYPE(opt) == G_TYPE_BOOL) in usage_command()
157 fprintf(stderr, " geom -p <provider-name>\n"); in usage()
158 fprintf(stderr, " geom -t\n"); in usage()
169 if (cmd->gc_name == NULL) in usage()
177 if (cmd->gc_name == NULL) in usage()
184 if (find_command(cmd->gc_name, GEOM_CLASS_CMDS) != NULL) in usage()
219 size -= len; in strlcatf()
238 opt = &cmd->gc_options[i]; in find_option()
239 if (opt->go_name == NULL) in find_option()
241 if (opt->go_char == ch) in find_option()
262 errx(EXIT_FAILURE, "Too many -%c options.", opt->go_char); in set_option()
268 optnamesize = strlen(opt->go_name) + 3 + 1; in set_option()
272 snprintf(ptr, optnamesize, "%s%u", opt->go_name, G_OPT_NUM(opt)); in set_option()
276 optname = opt->go_name; in set_option()
280 if (expand_number(val, &number) == -1) { in set_option()
282 opt->go_char); in set_option()
288 opt->go_val = ptr; in set_option()
289 gctl_ro_param(req, optname, sizeof(intmax_t), opt->go_val); in set_option()
291 gctl_ro_param(req, optname, -1, val); in set_option()
296 *(int *)ptr = *val - '0'; in set_option()
297 opt->go_val = ptr; in set_option()
298 gctl_ro_param(req, optname, sizeof(int), opt->go_val); in set_option()
322 if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0) in parse_arguments()
325 opt = &cmd->gc_options[i]; in parse_arguments()
326 if (opt->go_name == NULL) in parse_arguments()
329 assert((opt->go_type & ~(G_TYPE_MASK | G_TYPE_MULTI)) == 0); in parse_arguments()
332 (opt->go_type & G_TYPE_MULTI) == 0); in parse_arguments()
333 strlcatf(opts, sizeof(opts), "%c", opt->go_char); in parse_arguments()
342 while ((ch = getopt(*argc, *argv, opts)) != -1) { in parse_arguments()
344 if (ch == 'v' && (cmd->gc_flags & G_FLAG_VERBOSE) != 0) in parse_arguments()
349 if (ch == 'v' && (cmd->gc_flags & G_FLAG_VERBOSE) != 0){ in parse_arguments()
358 warnx("Option '%c' specified twice.", opt->go_char); in parse_arguments()
368 *argc -= optind; in parse_arguments()
375 opt = &cmd->gc_options[i]; in parse_arguments()
376 if (opt->go_name == NULL) in parse_arguments()
382 assert(opt->go_val == NULL); in parse_arguments()
385 if (opt->go_val == NULL) { in parse_arguments()
387 opt->go_char); in parse_arguments()
389 } else if (opt->go_val == G_VAL_OPTIONAL) { in parse_arguments()
392 set_option(req, opt, opt->go_val); in parse_arguments()
405 gctl_ro_param(req, argname, -1, (*argv)[i]); in parse_arguments()
424 if (cmd->gc_name == NULL) in find_command()
426 if (strcmp(cmd->gc_name, cmdstr) == 0) in find_command()
436 if (cmd->gc_name == NULL) in find_command()
438 if (strcmp(cmd->gc_name, cmdstr) == 0) in find_command()
450 if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0 && verbose) in set_flags()
476 if (!std_available(cmd->gc_name)) { in run_command()
482 if ((cmd->gc_flags & G_FLAG_LOADKLD) != 0) in run_command()
486 gctl_ro_param(req, "class", -1, gclass_name); in run_command()
487 gctl_ro_param(req, "verb", -1, argv[0]); in run_command()
493 if (cmd->gc_func != NULL) { in run_command()
497 cmd->gc_func(req, flags); in run_command()
498 errstr = req->error; in run_command()
508 req->nerror = 0; in run_command()
509 if (req->nerror != 0) { in run_command()
557 if (ret == -1) { in load_library()
572 if (ret == -1) in load_library()
634 if (strcmp((*argv)[1], "-h") == 0 || in get_class()
641 *argc -= 2; in get_class()
645 *argc -= 1; in get_class()
677 struct ggeom *gp; in find_geom_by_provider() local
680 LIST_FOREACH(classp, &mesh->lg_class, lg_class) { in find_geom_by_provider()
681 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in find_geom_by_provider()
682 LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { in find_geom_by_provider()
683 if (strcmp(pp->lg_name, name) == 0) in find_geom_by_provider()
684 return (gp); in find_geom_by_provider()
693 compute_tree_width_geom(struct gmesh *mesh, struct ggeom *gp, int indent) in compute_tree_width_geom() argument
701 max_width = width = indent + strlen(gp->lg_name); in compute_tree_width_geom()
703 LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { in compute_tree_width_geom()
704 LIST_FOREACH(classp2, &mesh->lg_class, lg_class) { in compute_tree_width_geom()
705 LIST_FOREACH(gp2, &classp2->lg_geom, lg_geom) { in compute_tree_width_geom()
707 &gp2->lg_consumer, lg_consumer) { in compute_tree_width_geom()
708 if (pp != cp2->lg_provider) in compute_tree_width_geom()
726 struct ggeom *gp; in compute_tree_width() local
731 LIST_FOREACH(classp, &mesh->lg_class, lg_class) { in compute_tree_width()
732 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in compute_tree_width()
733 if (!LIST_EMPTY(&gp->lg_consumer)) in compute_tree_width()
735 width = compute_tree_width_geom(mesh, gp, 0); in compute_tree_width()
745 show_tree_geom(struct gmesh *mesh, struct ggeom *gp, int indent, int width) in show_tree_geom() argument
752 if (LIST_EMPTY(&gp->lg_provider)) { in show_tree_geom()
753 printf("%*s%-*.*s %-*.*s\n", indent, "", in show_tree_geom()
754 width - indent, width - indent, gp->lg_name, in show_tree_geom()
755 GEOM_CLASS_WIDTH, GEOM_CLASS_WIDTH, gp->lg_class->lg_name); in show_tree_geom()
759 LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { in show_tree_geom()
760 printf("%*s%-*.*s %-*.*s %s\n", indent, "", in show_tree_geom()
761 width - indent, width - indent, gp->lg_name, in show_tree_geom()
762 GEOM_CLASS_WIDTH, GEOM_CLASS_WIDTH, gp->lg_class->lg_name, in show_tree_geom()
763 pp->lg_name); in show_tree_geom()
765 LIST_FOREACH(classp2, &mesh->lg_class, lg_class) { in show_tree_geom()
766 LIST_FOREACH(gp2, &classp2->lg_geom, lg_geom) { in show_tree_geom()
768 &gp2->lg_consumer, lg_consumer) { in show_tree_geom()
769 if (pp != cp2->lg_provider) in show_tree_geom()
784 struct ggeom *gp; in show_tree() local
793 printf("%-*.*s %-*.*s %s\n", in show_tree()
799 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in show_tree()
800 if (!LIST_EMPTY(&gp->lg_consumer)) in show_tree()
802 show_tree_geom(&mesh, gp, 0, width); in show_tree()
822 while ((ch = getopt(argc, argv, "hp:t")) != -1) { in main()
846 "At most one of -P and -t may be specified."); in main()
872 LIST_FOREACH(classp, &mesh->lg_class, lg_class) { in find_class()
873 if (strcmp(classp->lg_name, name) == 0) in find_class()
882 struct ggeom *gp; in find_geom() local
884 if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) in find_geom()
885 name += sizeof(_PATH_DEV) - 1; in find_geom()
887 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in find_geom()
888 if (strcmp(gp->lg_name, name) == 0) in find_geom()
889 return (gp); in find_geom()
900 xo_emit("{Lcw:Name}{:name}\n", pp->lg_name); in list_one_provider()
901 humanize_number(buf, sizeof(buf), (int64_t)pp->lg_mediasize, "", in list_one_provider()
904 padding, (intmax_t)pp->lg_mediasize, buf); in list_one_provider()
906 padding, pp->lg_sectorsize); in list_one_provider()
907 if (pp->lg_stripesize > 0 || pp->lg_stripeoffset > 0) { in list_one_provider()
909 padding, pp->lg_stripesize); in list_one_provider()
911 padding, pp->lg_stripeoffset); in list_one_provider()
913 xo_emit("{P:/%s}{Lcw:Mode}{:mode}\n", padding, pp->lg_mode); in list_one_provider()
914 LIST_FOREACH(conf, &pp->lg_config, lg_config) { in list_one_provider()
915 xo_emit("{P:/%s}{Lcwa:}{a:}\n", padding, conf->lg_name, in list_one_provider()
916 conf->lg_name, conf->lg_val ? conf->lg_val : ""); in list_one_provider()
926 pp = cp->lg_provider; in list_one_consumer()
932 xo_emit("{Lcw:Name}{:name}\n", pp->lg_name); in list_one_consumer()
933 humanize_number(buf, sizeof(buf), (int64_t)pp->lg_mediasize, "", in list_one_consumer()
936 padding, (intmax_t)pp->lg_mediasize, buf); in list_one_consumer()
938 padding, pp->lg_sectorsize); in list_one_consumer()
939 if (pp->lg_stripesize > 0 || pp->lg_stripeoffset > 0) { in list_one_consumer()
941 padding, pp->lg_stripesize); in list_one_consumer()
943 padding, pp->lg_stripeoffset); in list_one_consumer()
945 xo_emit("{P:/%s}{Lcw:Mode}{:mode}\n", padding, pp->lg_mode); in list_one_consumer()
947 LIST_FOREACH(conf, &cp->lg_config, lg_config) { in list_one_consumer()
948 xo_emit("{P:/%s}{Lcwa:}{a:}\n", padding, conf->lg_name, in list_one_consumer()
949 conf->lg_name, conf->lg_val ? conf->lg_val : ""); in list_one_consumer()
954 list_one_geom(struct ggeom *gp) in list_one_geom() argument
961 xo_emit("{Lcw:Geom name}{:name}\n", gp->lg_name); in list_one_geom()
962 LIST_FOREACH(conf, &gp->lg_config, lg_config) { in list_one_geom()
963 xo_emit("{Lcwa:}{a:}\n", conf->lg_name, conf->lg_name, in list_one_geom()
964 conf->lg_val ? conf->lg_val : ""); in list_one_geom()
966 if (!LIST_EMPTY(&gp->lg_provider)) { in list_one_geom()
970 LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { in list_one_geom()
978 if (!LIST_EMPTY(&gp->lg_consumer)) { in list_one_geom()
982 LIST_FOREACH(cp, &gp->lg_consumer, lg_consumer) { in list_one_geom()
997 struct ggeom *gp; in list_one_geom_by_provider() local
1004 gp = find_geom_by_provider(&mesh, provider_name); in list_one_geom_by_provider()
1005 if (gp == NULL) in list_one_geom_by_provider()
1009 xo_emit("{Lwc:Geom class}{:class}\n", gp->lg_class->lg_name); in list_one_geom_by_provider()
1010 list_one_geom(gp); in list_one_geom_by_provider()
1043 struct ggeom *gp; in std_list() local
1064 gp = find_geom(classp, name); in std_list()
1065 if (gp == NULL) { in std_list()
1071 list_one_geom(gp); in std_list()
1076 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in std_list()
1077 if (LIST_EMPTY(&gp->lg_provider) && !all) in std_list()
1080 list_one_geom(gp); in std_list()
1097 status_update_len(struct ggeom *gp, int *name_len, int *status_len) in status_update_len() argument
1102 assert(gp != NULL); in status_update_len()
1106 len = strlen(gp->lg_name); in status_update_len()
1109 LIST_FOREACH(conf, &gp->lg_config, lg_config) { in status_update_len()
1110 if (strcasecmp(conf->lg_name, "state") == 0) { in status_update_len()
1111 len = strlen(conf->lg_val); in status_update_len()
1119 status_update_len_prs(struct ggeom *gp, int *name_len, int *status_len) in status_update_len_prs() argument
1125 assert(gp != NULL); in status_update_len_prs()
1130 LIST_FOREACH(conf, &gp->lg_config, lg_config) { in status_update_len_prs()
1131 if (strcasecmp(conf->lg_name, "state") == 0) { in status_update_len_prs()
1132 glen = strlen(conf->lg_val); in status_update_len_prs()
1136 LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { in status_update_len_prs()
1137 len = strlen(pp->lg_name); in status_update_len_prs()
1141 LIST_FOREACH(conf, &pp->lg_config, lg_config) { in status_update_len_prs()
1142 if (strcasecmp(conf->lg_name, "state") == 0) { in status_update_len_prs()
1143 len = strlen(conf->lg_val); in status_update_len_prs()
1159 pp = cp->lg_provider; in status_one_consumer()
1163 LIST_FOREACH(conf, &cp->lg_config, lg_config) { in status_one_consumer()
1164 if (strcasecmp(conf->lg_name, value) == 0) in status_one_consumer()
1165 ret = conf->lg_val; in status_one_consumer()
1174 status_one_geom(struct ggeom *gp, int script, int name_len, int status_len) in status_one_geom() argument
1182 name = gp->lg_name; in status_one_geom()
1184 LIST_FOREACH(conf, &gp->lg_config, lg_config) { in status_one_geom()
1185 if (strcasecmp(conf->lg_name, "state") == 0) { in status_one_geom()
1186 status = conf->lg_val; in status_one_geom()
1192 LIST_FOREACH(cp, &gp->lg_consumer, lg_consumer) { in status_one_geom()
1193 if (cp->lg_provider == NULL) in status_one_geom()
1220 len, "", cp->lg_provider->lg_name, cstate, csyncr); in status_one_geom()
1223 len, "", cp->lg_provider->lg_name, cstate); in status_one_geom()
1226 len, "", cp->lg_provider->lg_name, csyncr); in status_one_geom()
1229 len, "", cp->lg_provider->lg_name); in status_one_geom()
1246 status_one_geom_prs(struct ggeom *gp, int script, int name_len, int status_len) in status_one_geom_prs() argument
1256 LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { in status_one_geom_prs()
1257 name = pp->lg_name; in status_one_geom_prs()
1259 LIST_FOREACH(conf, &gp->lg_config, lg_config) { in status_one_geom_prs()
1260 if (strcasecmp(conf->lg_name, "state") == 0) { in status_one_geom_prs()
1261 status = conf->lg_val; in status_one_geom_prs()
1265 LIST_FOREACH(conf, &pp->lg_config, lg_config) { in status_one_geom_prs()
1266 if (strcasecmp(conf->lg_name, "state") == 0) { in status_one_geom_prs()
1267 status = conf->lg_val; in status_one_geom_prs()
1272 LIST_FOREACH(cp, &gp->lg_consumer, lg_consumer) { in status_one_geom_prs()
1273 if (cp->lg_provider == NULL) in status_one_geom_prs()
1301 len, "", cp->lg_provider->lg_name, cstate, csyncr); in status_one_geom_prs()
1304 len, "", cp->lg_provider->lg_name, cstate); in status_one_geom_prs()
1307 len, "", cp->lg_provider->lg_name, csyncr); in status_one_geom_prs()
1310 len, "", cp->lg_provider->lg_name); in status_one_geom_prs()
1332 struct ggeom *gp; in std_status() local
1353 gp = find_geom(classp, name); in std_status()
1354 if (gp == NULL) in std_status()
1357 status_update_len(gp, in std_status()
1360 status_update_len_prs(gp, in std_status()
1369 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in std_status()
1370 if (LIST_EMPTY(&gp->lg_provider) && !all) in std_status()
1373 status_update_len(gp, in std_status()
1376 status_update_len_prs(gp, in std_status()
1392 gp = find_geom(classp, name); in std_status()
1393 if (gp == NULL) in std_status()
1396 status_one_geom(gp, script, name_len, in std_status()
1399 status_one_geom_prs(gp, script, name_len, in std_status()
1404 LIST_FOREACH(gp, &classp->lg_geom, lg_geom) { in std_status()
1405 if (LIST_EMPTY(&gp->lg_provider) && !all) in std_status()
1408 status_one_geom(gp, script, name_len, in std_status()
1411 status_one_geom_prs(gp, script, name_len, in std_status()