summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2001-10-12 22:39:02 +0000
committerjkh <jkh@FreeBSD.org>2001-10-12 22:39:02 +0000
commit6323844d2c5c0697037f495f7d9f2a3d5919727e (patch)
tree1de88d0eb3af3bdcd0214ac3e9d0bc80424a5711 /usr.sbin/sysinstall
parenteed0e0a1c4043b4a8a5e72e86202bc3f0e6832b3 (diff)
downloadFreeBSD-src-6323844d2c5c0697037f495f7d9f2a3d5919727e.zip
FreeBSD-src-6323844d2c5c0697037f495f7d9f2a3d5919727e.tar.gz
Add the ability to load klds from a floppy as part of the installation.
Submitted by: "Daniel O'Connor" <doconnor@gsoft.com.au> MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r--usr.sbin/sysinstall/menus.c12
-rw-r--r--usr.sbin/sysinstall/modules.c114
-rw-r--r--usr.sbin/sysinstall/sysinstall.h2
3 files changed, 128 insertions, 0 deletions
diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c
index f4a827f..7da5e2d 100644
--- a/usr.sbin/sysinstall/menus.c
+++ b/usr.sbin/sysinstall/menus.c
@@ -698,6 +698,16 @@ DMenu MenuNetworkDevice = {
{ { NULL } },
};
+/* Prototype KLD load menu */
+DMenu MenuKLD = {
+ DMENU_NORMAL_TYPE,
+ "KLD Menu",
+ "Load a KLD from a floppy\n",
+ NULL,
+ NULL,
+ { { NULL } },
+};
+
/* The media selection menu */
DMenu MenuMedia = {
DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
@@ -1263,6 +1273,8 @@ DMenu MenuConfigure = {
NULL, configXDesktop },
{ " HTML Docs", "Go to the HTML documentation menu (post-install)",
NULL, docBrowser },
+ { " Load KLD", "Load a KLD from a floppy",
+ NULL, kldBrowser },
{ NULL } },
};
diff --git a/usr.sbin/sysinstall/modules.c b/usr.sbin/sysinstall/modules.c
index a61e02e..f18beb5 100644
--- a/usr.sbin/sysinstall/modules.c
+++ b/usr.sbin/sysinstall/modules.c
@@ -34,8 +34,14 @@
#include <sys/linker.h>
#include <fcntl.h>
#include <dirent.h>
+#include <fcntl.h>
+#include <fnmatch.h>
+
+/* Prototypes */
+static int kldModuleFire(dialogMenuItem *self);
#define MODULESDIR "/stand/modules"
+#define DISTMOUNT "/dist"
void
moduleInitialize(void)
@@ -89,3 +95,111 @@ moduleInitialize(void)
closedir(dirp);
}
}
+
+int
+kldBrowser(dialogMenuItem *self)
+{
+ DMenu *menu;
+ int i, what = DITEM_SUCCESS, msize, count;
+ DIR *dir;
+ struct dirent *de;
+ char *err;
+
+ err = NULL;
+
+ if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
+ msgConfirm("Unable to set media device to floppy.");
+ what |= DITEM_FAILURE;
+ mediaClose();
+ return what;
+ }
+
+ if (!DEVICE_INIT(mediaDevice)) {
+ msgConfirm("Unable to mount floppy filesystem.");
+ what |= DITEM_FAILURE;
+ mediaClose();
+ return what;
+ }
+
+ msize = sizeof(DMenu) + (sizeof(dialogMenuItem) * 2);
+ count = 0;
+ if ((menu = malloc(msize)) == NULL) {
+ err = "Failed to allocate memory for menu";
+ goto errout;
+ }
+
+ bcopy(&MenuKLD, menu, sizeof(DMenu));
+
+ bzero(&menu->items[count], sizeof(menu->items[0]));
+ menu->items[count].prompt = strdup("X Exit");
+ menu->items[count].title = strdup("Exit this menu (returning to previous)");
+ menu->items[count].fire = dmenuExit;
+ count++;
+
+ if ((dir = opendir(DISTMOUNT)) == NULL) {
+ err = "Couldn't open directory";
+ goto errout;
+ }
+
+ while ((de = readdir(dir)) != NULL) {
+ if (fnmatch("*.ko", de->d_name, FNM_CASEFOLD))
+ continue;
+
+ msize += sizeof(dialogMenuItem);
+ if ((menu = realloc(menu, msize)) == NULL) {
+ err = "Failed to allocate memory for menu item";
+ goto errout;
+ }
+
+ bzero(&menu->items[count], sizeof(menu->items[0]));
+ menu->items[count].fire = kldModuleFire;
+
+ menu->items[count].prompt = strdup(de->d_name);
+ menu->items[count].title = menu->items[count].prompt;
+
+ count++;
+ }
+
+ closedir(dir);
+
+ menu->items[count].prompt = NULL;
+ menu->items[count].title = NULL;
+
+ dmenuOpenSimple(menu, FALSE);
+
+ mediaClose();
+
+ deviceRescan();
+
+ errout:
+ for (i = 0; i < count; i++)
+ free(menu->items[i].prompt);
+
+ free(menu);
+
+ if (err != NULL) {
+ what |= DITEM_FAILURE;
+ if (!variable_get(VAR_NO_ERROR))
+ msgConfirm(err);
+ }
+
+ return (what);
+}
+
+static int
+kldModuleFire(dialogMenuItem *self) {
+ char fname[256];
+
+ bzero(fname, sizeof(fname));
+ snprintf(fname, sizeof(fname), "%s/%s", DISTMOUNT, self->prompt);
+
+ if (kldload(fname) < 0) {
+ if (!variable_get(VAR_NO_ERROR))
+ msgConfirm("Loading module %s failed\n", fname);
+ } else {
+ if (!variable_get(VAR_NO_ERROR))
+ msgConfirm("Loaded module %s OK", fname);
+ }
+
+ return(0);
+ }
diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h
index f143b38..3653c32 100644
--- a/usr.sbin/sysinstall/sysinstall.h
+++ b/usr.sbin/sysinstall/sysinstall.h
@@ -371,6 +371,7 @@ extern DMenu MenuFTPOptions; /* FTP Installation options */
extern DMenu MenuIndex; /* Index menu */
extern DMenu MenuOptions; /* Installation options */
extern DMenu MenuOptionsLanguage; /* Language options menu */
+extern DMenu MenuKLD; /* Prototype KLD menu */
extern DMenu MenuMedia; /* Media type menu */
extern DMenu MenuMouse; /* Mouse type menu */
extern DMenu MenuMediaCDROM; /* CDROM media menu */
@@ -674,6 +675,7 @@ extern char *sstrncpy(char *dst, const char *src, int size);
/* modules.c */
extern void moduleInitialize(void);
+extern int kldBrowser(dialogMenuItem *self);
/* mouse.c */
extern int mousedTest(dialogMenuItem *self);
OpenPOWER on IntegriCloud