summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2007-11-04 00:32:54 +0000
committermarcel <marcel@FreeBSD.org>2007-11-04 00:32:54 +0000
commite52d34f074eb45508929484728604bbb8fb94593 (patch)
tree39bd6447af5779e5d5f8008faa8cd7b63166dfc0 /sbin
parent46608d3cace876f78956135d50fcacc0c45d9a8e (diff)
downloadFreeBSD-src-e52d34f074eb45508929484728604bbb8fb94593.zip
FreeBSD-src-e52d34f074eb45508929484728604bbb8fb94593.tar.gz
Allow building of a special rescue version of geom that
has a subset of the classes compiled-in.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/geom/Makefile18
-rw-r--r--sbin/geom/class/part/geom_part.c12
-rw-r--r--sbin/geom/core/geom.c18
3 files changed, 44 insertions, 4 deletions
diff --git a/sbin/geom/Makefile b/sbin/geom/Makefile
index 95f00d9..af2b77b 100644
--- a/sbin/geom/Makefile
+++ b/sbin/geom/Makefile
@@ -1,5 +1,23 @@
# $FreeBSD$
+.if defined(RESCUE)
+
+.PATH: ${.CURDIR}/class/part ${.CURDIR}/core ${.CURDIR}/misc
+
+PROG= geom
+SRCS= geom.c geom_part.c subr.c
+
+CFLAGS+=-I${.CURDIR} -I${.CURDIR}/core
+
+DPADD= ${LIBGEOM} ${LIBSBUF} ${LIBBSDXML} ${LIBUTIL}
+LDADD= -lgeom -lsbuf -lbsdxml -lutil
+
+.include <bsd.prog.mk>
+
+.else
+
SUBDIR= core class
.include <bsd.subdir.mk>
+
+.endif
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index f70b487..8e8a77b 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -43,15 +43,21 @@ __FBSDID("$FreeBSD$");
#include "core/geom.h"
#include "misc/subr.h"
-uint32_t lib_version = G_LIB_VERSION;
-uint32_t version = 0;
+#ifdef RESCUE
+#define PUBSYM(x) gpart_##x
+#else
+#define PUBSYM(x) x
+#endif
+
+uint32_t PUBSYM(lib_version) = G_LIB_VERSION;
+uint32_t PUBSYM(version) = 0;
static char optional[] = "";
static char flags[] = "C";
static void gpart_show(struct gctl_req *, unsigned);
-struct g_command class_commands[] = {
+struct g_command PUBSYM(class_commands)[] = {
{ "add", 0, NULL, {
{ 'b', "start", NULL, G_TYPE_STRING },
{ 's', "size", NULL, G_TYPE_STRING },
diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c
index cfa1e60..2345be3 100644
--- a/sbin/geom/core/geom.c
+++ b/sbin/geom/core/geom.c
@@ -51,6 +51,10 @@ __FBSDID("$FreeBSD$");
#include "misc/subr.h"
+#ifdef RESCUE
+extern uint32_t gpart_version;
+extern struct g_command gpart_class_commands[];
+#endif
static char comm[MAXPATHLEN], *class_name = NULL, *gclass_name = NULL;
static uint32_t *version = NULL;
@@ -466,6 +470,7 @@ run_command(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
+#ifndef RESCUE
static const char *
library_path(void)
{
@@ -524,6 +529,7 @@ load_library(void)
exit(EXIT_FAILURE);
}
}
+#endif /* !RESCUE */
/*
* Class name should be all capital letters.
@@ -571,8 +577,18 @@ get_class(int *argc, char ***argv)
} else {
errx(EXIT_FAILURE, "Invalid utility name.");
}
- set_class_name();
+
+#ifndef RESCUE
load_library();
+#else
+ if (!strcasecmp(class_name, "part")) {
+ version = &gpart_version;
+ class_commands = gpart_class_commands;
+ } else
+ errx(EXIT_FAILURE, "Invalid class name.");
+#endif /* !RESCUE */
+
+ set_class_name();
if (*argc < 1)
usage();
}
OpenPOWER on IntegriCloud