summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2011-01-19 15:01:20 +0000
committerAntoine Ginies <aginies@mandriva.com>2011-01-19 15:01:20 +0000
commitd537f12b889835df055a2053e37686b77545834d (patch)
treee97eedbd60e428f8440ce2d84c1ad61714ec9920 /mdk-stage1
parent530a16ec071db0e24e6e949e265a96848864967c (diff)
downloaddrakx-backup-do-not-use-d537f12b889835df055a2053e37686b77545834d.tar
drakx-backup-do-not-use-d537f12b889835df055a2053e37686b77545834d.tar.gz
drakx-backup-do-not-use-d537f12b889835df055a2053e37686b77545834d.tar.bz2
drakx-backup-do-not-use-d537f12b889835df055a2053e37686b77545834d.tar.xz
drakx-backup-do-not-use-d537f12b889835df055a2053e37686b77545834d.zip
backport more stuff from 2010.1
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/modules.c36
-rw-r--r--mdk-stage1/modules.h6
-rw-r--r--mdk-stage1/probing.c21
-rw-r--r--mdk-stage1/stage1.c2
4 files changed, 45 insertions, 20 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c
index 53bc87d4c..5f02d2a6d 100644
--- a/mdk-stage1/modules.c
+++ b/mdk-stage1/modules.c
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc@mandriva.com)
*
- * Copyright 2000 Mandrakesoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -39,8 +39,8 @@
#include "modules.h"
-#define FIRMWARE_TIMEOUT_FILE "/sys/class/firmware/timeout"
-#define FIRMWARE_TIMEOUT_VALUE "1"
+#define UEVENT_HELPER_FILE "/sys/kernel/uevent_helper"
+#define UEVENT_HELPER_VALUE "/sbin/hotplug"
static char modules_directory[100];
static struct module_deps_elem * modules_deps = NULL;
@@ -156,12 +156,12 @@ static int load_modules_dependencies(void)
while (*ptr && (*ptr == ' ')) ptr++;
/* sort of a good line */
- modules_deps[line].filename = strdup(start);
+ modules_deps[line].filename = start[0] == '/' ? strdup(start) : asprintf_("%s/%s", modules_directory, start);
modules_deps[line].modname = filename2modname(start);
start = ptr;
i = 0;
- while (start && *start) {
+ while (start && *start && i < sizeof(tmp_deps)/sizeof(char *)) {
ptr = strchr(start, ' ');
if (ptr) *ptr = '\0';
tmp_deps[i++] = filename2modname(start);
@@ -172,6 +172,12 @@ static int load_modules_dependencies(void)
while (start && *start && *start == ' ')
start++;
}
+ if(i >= sizeof(tmp_deps)/sizeof(char *)-1) {
+ log_message("warning, more than %zu dependencies for module %s",
+ sizeof(tmp_deps)/sizeof(char *)-1,
+ modules_deps[line].modname);
+ i = sizeof(tmp_deps)/sizeof(char *)-1;
+ }
tmp_deps[i++] = NULL;
modules_deps[line].deps = memdup(tmp_deps, sizeof(char *) * i);
@@ -229,14 +235,14 @@ static int load_modules_descriptions(void)
return 0;
}
-void init_firmware_timeout(void)
+void init_firmware_loader(void)
{
- int fd = open(FIRMWARE_TIMEOUT_FILE, O_WRONLY|O_TRUNC, 0666);
+ int fd = open(UEVENT_HELPER_FILE, O_WRONLY|O_TRUNC, 0666);
if (!fd) {
- log_message("warning, unable to set firmware timeout");
+ log_message("warning, unable to set firmware loader");
return;
}
- write(fd, FIRMWARE_TIMEOUT_VALUE, strlen(FIRMWARE_TIMEOUT_VALUE));
+ write(fd, UEVENT_HELPER_VALUE, strlen(UEVENT_HELPER_VALUE));
close(fd);
}
@@ -247,7 +253,7 @@ void init_modules_insmoding(void)
fatal_error("warning, error initing modules stuff, modules loading disabled");
}
if (load_modules_descriptions()) {
- log_message("warning, error initing modules stuff, modules loading disabled");
+ log_message("warning, error initing modules stuff");
}
}
@@ -420,6 +426,11 @@ static enum return_type insmod_with_options(char * mod, enum driver_type type)
return RETURN_OK;
}
+static int strsortfunc(const void *a, const void *b)
+{
+ return strcmp(* (char * const *) a, * (char * const *) b);
+}
+
enum return_type ask_insmod(enum driver_type type)
{
enum return_type results;
@@ -431,11 +442,12 @@ enum return_type ask_insmod(enum driver_type type)
char ** p_modules = modules;
char ** p_descrs = descrs;
+ qsort(dlist, string_array_length(dlist), sizeof(char *), strsortfunc);
+
unset_automatic(); /* we are in a fallback mode */
while (p_dlist && *p_dlist) {
struct module_descr_elem * descr;
-
if (!strstr(*p_dlist, kernel_module_extension())) {
p_dlist++;
continue;
diff --git a/mdk-stage1/modules.h b/mdk-stage1/modules.h
index 8a57b9e41..4bddb2452 100644
--- a/mdk-stage1/modules.h
+++ b/mdk-stage1/modules.h
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc@mandriva.com)
*
- * Copyright 2000 Mandrakesoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -21,7 +21,7 @@
enum insmod_return { INSMOD_OK, INSMOD_FAILED, INSMOD_FAILED_FILE_NOT_FOUND };
void init_modules_insmoding(void);
-void init_firmware_timeout(void);
+void init_firmware_loader(void);
int insmod_local_file(char * path, char * options);
enum insmod_return my_insmod(const char * mod_name, enum driver_type type, char * options, int allow_modules_floppy);
enum return_type ask_insmod(enum driver_type);
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c
index fd0f39c50..0db75ffbd 100644
--- a/mdk-stage1/probing.c
+++ b/mdk-stage1/probing.c
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc@mandriva.com)
*
- * Copyright 2000 Mandrakesoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -768,10 +768,23 @@ void find_media(enum media_bus bus)
while (fgets(buf, sizeof(buf), f)) {
char name[100];
int major, minor, blocks;
+ struct stat statbuf;
+ char *ptr;
memset(name, 0, sizeof(name));
- sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, name);
- if (streq(name, tmp_name) && tmp[count].type == DISK && ((blocks == 1048575) || (blocks == 1440)))
+ strcpy(name, "/dev/");
+ sscanf(buf, " %d %d %d %s", &major, &minor, &blocks, &name[5]);
+ if (streq(&name[5], tmp_name) && tmp[count].type == DISK && ((blocks == 1048575) || (blocks == 1440)))
tmp[count].type = FLOPPY;
+ /* Try to create all devices while we have major/minor */
+ if ((ptr = strchr(&name[5], '/'))) {
+ *ptr = '\0';
+ if (stat(name, &statbuf))
+ mkdir(name, 0755);
+ *ptr = '/';
+ }
+ if (stat(name, &statbuf) && mknod(name, S_IFBLK | 0600, makedev(major, minor))) {
+ log_perror(name);
+ }
}
fclose(f);
}
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 63f9d2ed2..80961d426 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -410,7 +410,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))
spawn_shell();
#endif
init_modules_insmoding();
- init_firmware_timeout();
+// init_firmware_timeout();
init_frontend("Welcome to " DISTRIB_DESCR ", " __DATE__ " " __TIME__);
probe_that_type(VIRTIO_DEVICES, BUS_ANY);