aboutsummaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2007-11-04 00:32:54 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2007-11-04 00:32:54 +0000
commita16f9b367d9c86fee4cf605d5757cb2a8dabeec6 (patch)
tree39bd6447af5779e5d5f8008faa8cd7b63166dfc0 /sbin
parenta3393da7bf1953d0d833ffa9ac62bd3003c11dc7 (diff)
downloadsrc-a16f9b367d9c86fee4cf605d5757cb2a8dabeec6.tar.gz
src-a16f9b367d9c86fee4cf605d5757cb2a8dabeec6.zip
Allow building of a special rescue version of geom that
has a subset of the classes compiled-in.
Notes
Notes: svn path=/head/; revision=173313
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 95f00d914756..af2b77bbec28 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 f70b4879260d..8e8a77bbd704 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 cfa1e6074ad4..2345be37fbf9 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();
}