geom.c (687b001501d8a25f0257be8b3988781fc042ce39) geom.c (3bad06e9baeb48e351b485cc8cc7045c870d0cae)
1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 432 unchanged lines hidden (view full) ---

441 if (*buf != '\0')
442 printf("%s", buf);
443 gctl_free(req);
444 if (verbose)
445 printf("Done.\n");
446 exit(EXIT_SUCCESS);
447}
448
1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 432 unchanged lines hidden (view full) ---

441 if (*buf != '\0')
442 printf("%s", buf);
443 gctl_free(req);
444 if (verbose)
445 printf("Done.\n");
446 exit(EXIT_SUCCESS);
447}
448
449static const char *
450library_path(void)
451{
452 const char *path;
453
454 path = getenv("GEOM_LIBRARY_PATH");
455 if (path == NULL)
456 path = CLASS_DIR;
457 return (path);
458}
459
449static void
450load_library(void)
451{
452 char path[MAXPATHLEN];
453 uint32_t *lib_version;
454 void *dlh;
455
460static void
461load_library(void)
462{
463 char path[MAXPATHLEN];
464 uint32_t *lib_version;
465 void *dlh;
466
456 snprintf(path, sizeof(path), "%s/geom_%s.so", CLASS_DIR, class_name);
467 snprintf(path, sizeof(path), "%s/geom_%s.so", library_path(),
468 class_name);
457 dlh = dlopen(path, RTLD_NOW);
458 if (dlh == NULL) {
459#if 0
460 fprintf(stderr, "Cannot open library %s, but continuing "
461 "anyway.\n", path);
462#endif
463 /*
464 * Even if library cannot be loaded, standard commands are

--- 200 unchanged lines hidden (view full) ---

665static int
666std_list_available(void)
667{
668 struct gmesh mesh;
669 struct gclass *classp;
670 int error;
671
672 error = geom_gettree(&mesh);
469 dlh = dlopen(path, RTLD_NOW);
470 if (dlh == NULL) {
471#if 0
472 fprintf(stderr, "Cannot open library %s, but continuing "
473 "anyway.\n", path);
474#endif
475 /*
476 * Even if library cannot be loaded, standard commands are

--- 200 unchanged lines hidden (view full) ---

677static int
678std_list_available(void)
679{
680 struct gmesh mesh;
681 struct gclass *classp;
682 int error;
683
684 error = geom_gettree(&mesh);
673 if (error != 0)
685 if (error != 0) {
686 fprintf(stderr, "Cannot get GEOM tree: %s.\n", strerror(error));
674 exit(EXIT_FAILURE);
687 exit(EXIT_FAILURE);
688 }
675 classp = find_class(&mesh, gclass_name);
676 geom_deletetree(&mesh);
677 if (classp != NULL)
678 return (1);
679 return (0);
680}
681
682static void
683std_list(struct gctl_req *req, unsigned flags __unused)
684{
685 struct gmesh mesh;
686 struct gclass *classp;
687 struct ggeom *gp;
688 int error, *nargs;
689
690 error = geom_gettree(&mesh);
689 classp = find_class(&mesh, gclass_name);
690 geom_deletetree(&mesh);
691 if (classp != NULL)
692 return (1);
693 return (0);
694}
695
696static void
697std_list(struct gctl_req *req, unsigned flags __unused)
698{
699 struct gmesh mesh;
700 struct gclass *classp;
701 struct ggeom *gp;
702 int error, *nargs;
703
704 error = geom_gettree(&mesh);
691 if (error != 0)
705 if (error != 0) {
706 fprintf(stderr, "Cannot get GEOM tree: %s.\n", strerror(error));
692 exit(EXIT_FAILURE);
707 exit(EXIT_FAILURE);
708 }
693 classp = find_class(&mesh, gclass_name);
694 if (classp == NULL) {
695 geom_deletetree(&mesh);
696 fprintf(stderr, "Class %s not found.\n", gclass_name);
697 return;
698 }
699 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
700 if (nargs == NULL) {

--- 116 unchanged lines hidden ---
709 classp = find_class(&mesh, gclass_name);
710 if (classp == NULL) {
711 geom_deletetree(&mesh);
712 fprintf(stderr, "Class %s not found.\n", gclass_name);
713 return;
714 }
715 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
716 if (nargs == NULL) {

--- 116 unchanged lines hidden ---