summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall/modules.c
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/modules.c
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/modules.c')
-rw-r--r--usr.sbin/sysinstall/modules.c114
1 files changed, 114 insertions, 0 deletions
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);
+ }
OpenPOWER on IntegriCloud