Forward-port the old mdstart tool from the Gentoo Busybox-1.1.3. Only fires the RAID_AUTORUN ioctl on existing /dev/md nodes. Signed-off-by: Robin H. Johnson diff -Nuar --exclude '*.orig' busybox-1.7.4/include/applets.h busybox-1.7.4+gentoo/include/applets.h --- busybox-1.7.4/include/applets.h 2007-09-03 04:48:46.000000000 -0700 +++ busybox-1.7.4+gentoo/include/applets.h 2008-03-11 10:25:43.000000000 -0700 @@ -222,6 +222,7 @@ USE_MATCHPATHCON(APPLET(matchpathcon, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum)) USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) +USE_MDSTART(APPLET(mdstart, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_MKDIR(APPLET_NOFORK(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_NEVER, mkdir)) //USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) diff -Nuar --exclude '*.orig' busybox-1.7.4/include/usage.h busybox-1.7.4+gentoo/include/usage.h --- busybox-1.7.4/include/usage.h 2007-09-03 04:48:46.000000000 -0700 +++ busybox-1.7.4+gentoo/include/usage.h 2008-03-11 10:19:04.000000000 -0700 @@ -2072,6 +2072,11 @@ "the last line match .* to override this.)\n\n" \ ) +#define mdstart_trivial_usage \ + "{[PARTITION] MD-NODE}..." +#define mdstart_full_usage \ + "Run the RAID_AUTORUN ioctl on the given MD number" + #define mesg_trivial_usage \ "[y|n]" #define mesg_full_usage \ diff -Nuar --exclude '*.orig' busybox-1.7.4/util-linux/Config.in busybox-1.7.4+gentoo/util-linux/Config.in --- busybox-1.7.4/util-linux/Config.in 2007-09-03 04:48:56.000000000 -0700 +++ busybox-1.7.4+gentoo/util-linux/Config.in 2008-03-11 10:26:20.000000000 -0700 @@ -305,6 +305,13 @@ /lib/firmware/ and if it exists, send it to the kernel for loading into the hardware. +config MDSTART + bool "mdstart" + default n + help + Allows you to autostart /dev/md devices if using an initramfs to + boot. + config MKSWAP bool "mkswap" default n diff -Nuar --exclude '*.orig' busybox-1.7.4/util-linux/Kbuild busybox-1.7.4+gentoo/util-linux/Kbuild --- busybox-1.7.4/util-linux/Kbuild 2007-09-03 04:48:56.000000000 -0700 +++ busybox-1.7.4+gentoo/util-linux/Kbuild 2008-03-11 10:28:47.000000000 -0700 @@ -18,6 +18,7 @@ lib-$(CONFIG_IPCRM) +=ipcrm.o lib-$(CONFIG_IPCS) +=ipcs.o lib-$(CONFIG_LOSETUP) +=losetup.o +lib-$(CONFIG_MDSTART) +=mdStart.o lib-$(CONFIG_MDEV) +=mdev.o lib-$(CONFIG_MKFS_MINIX) +=mkfs_minix.o lib-$(CONFIG_MKSWAP) +=mkswap.o diff -Nuar --exclude '*.orig' busybox-1.7.4/util-linux/mdStart.c busybox-1.7.4+gentoo/util-linux/mdStart.c --- busybox-1.7.4/util-linux/mdStart.c 1969-12-31 16:00:00.000000000 -0800 +++ busybox-1.7.4+gentoo/util-linux/mdStart.c 2008-03-11 10:19:04.000000000 -0700 @@ -0,0 +1,59 @@ +/* + * Linux 2.6(+) RAID Autostarter + * + * Copyright (C) 2005 by Tim Yamin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include + +extern int +mdstart_main(int argc, char *argv[]) +{ + int i, fd, part = 0, retval = 0; + + if(argc < 2) + { + bb_show_usage(); + } + + for(i = 1; i < argc; i++) + { + if(sscanf(argv[i], "%d", &part) == 1) + continue; + + fd = open(argv[i], 0, 0); + if (fd >= 0) + { + ioctl(fd, RAID_AUTORUN, part); + close(fd); + } else + { + printf("Error: Failed to open %s!\n", argv[i]); + retval=1; + } + + part = 0; + } + + return retval; +}