diff options
-rw-r--r-- | mdk-stage1/mkinitrd_helper/Makefile | 2 | ||||
-rw-r--r-- | mdk-stage1/mkinitrd_helper/mkinitrd_helper.c | 39 |
2 files changed, 38 insertions, 3 deletions
diff --git a/mdk-stage1/mkinitrd_helper/Makefile b/mdk-stage1/mkinitrd_helper/Makefile index 470a371ae..985229ba0 100644 --- a/mdk-stage1/mkinitrd_helper/Makefile +++ b/mdk-stage1/mkinitrd_helper/Makefile @@ -18,7 +18,7 @@ top_dir = .. include $(top_dir)/Makefile.common -VERSION = 1.0.1 +VERSION = 1.1.0 DEFS = -DVERSION=\"$(VERSION)\" diff --git a/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c b/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c index 5a0ce4a28..8d4c60b19 100644 --- a/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c +++ b/mdk-stage1/mkinitrd_helper/mkinitrd_helper.c @@ -55,10 +55,15 @@ void log_perror(char *msg) static void fatal_error(char *msg) { - printf("[] fatal: %s\n[] giving hand to kernel.\n", msg); + printf("[] E: %s\n[] giving hand to kernel.\n", msg); exit(-1); } +static void warning(char *msg) +{ + printf("[] W: %s\n", msg); +} + static void parse_parms(const char * parm, char ** parm1, char ** parm2, char ** parm3) { char * ptr; @@ -71,6 +76,9 @@ static void parse_parms(const char * parm, char ** parm1, char ** parm2, char ** memcpy(*parm1, parm, ptr-parm); (*parm1)[ptr-parm] = '\0'; + if (!parm2) + return; + *parm2 = strchr(*parm1, ' '); if (!*parm2) return; @@ -199,6 +207,32 @@ static void set_loop_(const char * parm) } +#define MD_MAJOR 9 +#define RAID_AUTORUN _IO (MD_MAJOR, 0x14) +#include <linux/raid/md_u.h> + +static void raidautorun_(const char * parm) +{ + char * device; + int fd; + + parse_parms(parm, &device, NULL, NULL); + + printf("[] Calling raid autorun for %s\n", device); + + fd = open(device, O_RDWR, 0); + if (fd < 0) { + printf("raidautorun: failed to open %s: %d\n", device, errno); + return; + } + + if (ioctl(fd, RAID_AUTORUN, 0)) { + printf("raidautorun: RAID_AUTORUN failed: %d\n", errno); + } + + close(fd); +} + static int handle_command(char ** ptr, char * cmd_name, void (*cmd_func)(const char * parm)) { if (!strncmp(*ptr, cmd_name, strlen(cmd_name))) { @@ -239,8 +273,9 @@ int main(int argc, char **argv) while (*ptr) if (!(handle_command(&ptr, "insmod", insmod_) + handle_command(&ptr, "mount", mount_) + + handle_command(&ptr, "raidautorun", raidautorun_) + handle_command(&ptr, "set_loop", set_loop_))) - fatal_error("unkown command"); + warning("unkown command (trying to continue)"); return 0; } |