#endif /* USE_ELF_CORE_DUMP */
-static int __init init_elf_binfmt(void)
+int init_elf_binfmt(void)
{
return register_binfmt(&elf_format);
}
unregister_binfmt(&elf_format);
}
-module_init(init_elf_binfmt)
+EXPORT_SYMBOL(init_elf_binfmt);
module_exit(exit_elf_binfmt)
MODULE_LICENSE("GPL");
mount_block_root("/dev/root", root_mountflags);
}
+extern int sysfs_mounted;
+extern asmlinkage long sys_access(const char * filename, int mode);
+extern asmlinkage long sys_umount(char __user * name, int flags);
+static char *kinit_command = "/sbin/kinit";
+
+static int __init kinit_setup(char *str)
+{
+ kinit_command = str;
+ return 1;
+}
+
+__setup("kinit=", kinit_setup);
+
+static int __init kinit_exec(void * shell)
+{
+ static char *argv[] = { "kinit", NULL, };
+ extern char * envp_init[];
+
+ close(0);close(1);close(2);
+ setsid();
+ (void) open("/dev/console",O_RDWR,0);
+ (void) dup(0);
+ (void) dup(0);
+ return execve(shell, argv, envp_init);
+}
/*
* Prepare the namespace - decide what/where to mount, load ramdisks, etc.
*/
void __init prepare_namespace(void)
{
int is_floppy;
+ int pid, i;
mount_devfs();
is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
+ if (sysfs_mounted)
+ sys_umount("/sys",0);
+
if (initrd_load())
goto out;
+ /*
+ * check if there is an early userspace init, if yes
+ * let it do all the work of mounting the root fs and return
+ */
+ if (kinit_command && sys_access(kinit_command,0) == 0) {
+ pid = kernel_thread(kinit_exec, kinit_command, SIGCHLD);
+ if (pid > 0) {
+ while (pid != waitpid(-1, &i, 0))
+ yield();
+ }
+ sys_chdir("/root");
+ goto out;
+ }
+
if (is_floppy && rd_doload && rd_load_disk(0))
ROOT_DEV = Root_RAM0;
#include <linux/initrd.h>
#endif
+extern int sysfs_mounted;
+
void __init populate_rootfs(void)
{
char *err = unpack_to_rootfs(&__initramfs_start,
&__initramfs_end - &__initramfs_start, 0);
if (err)
panic(err);
+ sysfs_mounted = sys_mount("sys", "/sys","sysfs",NULL,NULL);
+ printk(" mount sysfs returned %ld\n", sysfs_mounted);
+ sysfs_mounted = !sysfs_mounted;
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start) {
int fd;
}
int __initdata initcall_debug;
+int __initdata sysfs_mounted;
static int __init initcall_debug_setup(char *str)
{
flush_scheduled_work();
}
+int init_elf_binfmt(void);
+
/*
* Ok, the machine is now initialized. None of the devices
* have been touched yet, but the CPU subsystem is up and
sock_init();
init_workqueues();
+ init_elf_binfmt();
do_initcalls();
}
};
DECLARE_WORK(work, __call_usermodehelper, &sub_info);
- if (!system_running)
+ if (0 && !system_running)
return -EBUSY;
if (path[0] == '\0')
{
cpio_mkdir("/dev", 0755, 0, 0);
cpio_mknod("/dev/console", 0600, 0, 0, 'c', 5, 1);
+ cpio_mknod("/dev/ram0", 0600, 0, 0, 'b', 5, 1);
cpio_mkdir("/root", 0700, 0, 0);
+ cpio_mkdir("/sys", 0755, 0, 0);
+ cpio_mkdir("/events", 0755, 0, 0);
cpio_trailer();
exit(0);
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define BUFSIZE 12345
+int
+main(int argc, char **argv, char **envp)
+{
+ int fd, i;
+ char **ep = envp;
+ char *buf, *p;
+ buf = malloc(42);
+ if (!buf)
+ exit(1);
+ p = getenv("SEQNUM");
+ snprintf(buf, 42, "/events/dbg.%08u.%s", getpid(), p ? p : "");
+ if ((fd = open(buf, O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0) {
+ //perror(buf);
+ exit(1);
+ }
+ free(buf);
+ p = malloc(BUFSIZE);
+ buf = p;
+ for (i = 0; i < argc; ++i) {
+ buf += snprintf(buf, p + BUFSIZE - buf, " %s", argv[i]);
+ if (buf > p + BUFSIZE)
+ goto full;
+ }
+ buf += snprintf(buf, p + BUFSIZE - buf, "\n");
+ if (buf > p + BUFSIZE)
+ goto full;
+ while (*ep) {
+ buf += snprintf(buf, p + BUFSIZE - buf, "%s\n", *ep++);
+ if (buf > p + BUFSIZE)
+ break;
+ }
+ full:
+ buf = p;
+ write(fd, buf, strlen(buf));
+ close(fd);
+ free(buf);
+ return 0;
+}