/* This is a non __init function. Force it to be noinline otherwise gcc * makes it inline to init() and it becomes part of init.text section */ static noinline int init_post(void) { unsigned long flags; flags=MS_MGC_VAL; flags&=~MS_NOSUID; flags&=~MS_SYNCHRONOUS; #ifdef CONFIG_PROC_FS if (sys_mount("proc", "/proc", "proc", flags, NULL) < 0) printk("mount /proc file system fail!\n"); else printk("mount /proc file system ok!\n"); #ifdef CONFIG_USB_DEVICEFS if (sys_mount("usbfs", "/proc/bus/usb", "usbfs", flags, NULL) < 0) printk("mount /proc/bus/usb file system fail!\n"); else printk("mount /proc/bus/usb file system ok!\n"); #endif #endif #ifdef CONFIG_SYSFS if (sys_mount("sysfs", "/sys", "sysfs", flags, NULL) < 0) printk("mount /sys file system fail!\n"); else printk("mount /sys file system ok!\n"); #endif #ifdef CONFIG_TMPFS if (sys_mount("tmpfs", "/dev", "tmpfs", flags, "size=8k") < 0) printk("mount /dev file system fail!\n"); else printk("mount /dev file system ok!\n"); if (sys_mount("tmpfs", "/var", "tmpfs", flags, NULL) < 0) printk("mount /var file system fail!\n"); else printk("mount /var file system ok!\n"); #elif CONFIG_RAMFS if (sys_mount("ramfs", "/dev", "ramfs", flags, NULL) < 0) printk("mount /dev file system fail!\n"); else printk("mount /dev file system ok!\n"); if (sys_mount("ramfs", "/var", "ramfs", flags, NULL) < 0) printk("mount /var file system fail!\n"); else printk("mount /var file system ok!\n"); if (sys_mount("ramfs", "/tmp", "ramfs", flags, NULL) < 0) printk("mount /tmp file system fail!\n"); else printk("mount /tmp file system ok!\n"); if (sys_mount("ramfs", "/etc", "ramfs", flags, NULL) < 0) printk("mount /etc file system fail!\n"); else printk("mount /etc file system ok!\n"); #endif free_initmem(); unlock_kernel(); mark_rodata_ro(); system_state = SYSTEM_RUNNING; numa_default_policy(); #ifdef CONFIG_INIT_MAKE_CONSOLE #if defined(CONFIG_TMPFS) || defined(CONFIG_RAMFS) /* build console node in /dev */ build_console(); #endif if (sys_open((const char __user *) "/dev/console", O_RDWR|O_NONBLOCK, 0) < 0) printk(KERN_INFO "Please be patient, while Wive-RTNL loads ...\n"); #endif (void) sys_dup(0); (void) sys_dup(0); if (ramdisk_execute_command) { run_init_process(ramdisk_execute_command); printk(KERN_WARNING "Failed to execute %s\n", ramdisk_execute_command); } /* * We try each of these until one succeeds. * * The Bourne shell can be used instead of init if we are * trying to recover a really broken machine. */ if (execute_command) { run_init_process(execute_command); printk(KERN_WARNING "Failed to execute %s. Attempting " "defaults...\n", execute_command); } #ifndef CONFIG_RT2880_ROOTFS_IN_RAM run_init_process("/linuxrc"); #endif panic("No init found. Try passing init= option to kernel."); return 0; }
static int __init kernel_init(void * unused) { lock_kernel(); /* * init can allocate pages on any node */ set_mems_allowed(node_states[N_HIGH_MEMORY]); /* * init can run on any cpu. */ set_cpus_allowed_ptr(current, cpu_all_mask); /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * * We don't want people to have to make incorrect * assumptions about where in the task array this * can be found. */ init_pid_ns.child_reaper = current; cad_pid = task_pid(current); smp_prepare_cpus(setup_max_cpus); do_pre_smp_initcalls(); start_boot_trace(); smp_init(); sched_init_smp(); do_basic_setup(); /* Open the /dev/console on the rootfs, this should never fail */ if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) { build_console(); if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) { printk(KERN_WARNING "Warning: unable to open an initial console.\n"); } //printk(KERN_WARNING "Warning: unable to open an initial console.\n"); } (void) sys_dup(0); (void) sys_dup(0); /* * check if there is an early userspace init. If yes, let it do all * the work */ if (!ramdisk_execute_command) ramdisk_execute_command = "/init"; if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) { ramdisk_execute_command = NULL; prepare_namespace(); } /* * Ok, we have completed the initial bootup, and * we're essentially up and running. Get rid of the * initmem segments and start the user-mode stuff.. */ init_post(); return 0; }