2024-09-09 08:52:07 +00:00
|
|
|
/*
|
|
|
|
* init/noinitramfs.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, NXP Semiconductors, All Rights Reserved
|
|
|
|
* Author: Jean-Paul Saman <jean-paul.saman@nxp.com>
|
|
|
|
*
|
|
|
|
* 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* 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 <linux/init.h>
|
|
|
|
#include <linux/stat.h>
|
|
|
|
#include <linux/kdev_t.h>
|
|
|
|
#include <linux/syscalls.h>
|
2024-09-09 08:57:42 +00:00
|
|
|
#include <linux/kconfig.h>
|
|
|
|
#include <linux/initramfs.h>
|
2024-09-09 08:52:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a simple rootfs that is similar to the default initramfs
|
|
|
|
*/
|
2024-09-09 08:57:42 +00:00
|
|
|
#if !IS_BUILTIN(CONFIG_BLK_DEV_INITRD)
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
int __init default_rootfs(void)
|
2024-09-09 08:52:07 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = sys_mkdir((const char __user __force *) "/dev", 0755);
|
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = sys_mknod((const char __user __force *) "/dev/console",
|
|
|
|
S_IFCHR | S_IRUSR | S_IWUSR,
|
|
|
|
new_encode_dev(MKDEV(5, 1)));
|
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = sys_mkdir((const char __user __force *) "/root", 0700);
|
|
|
|
if (err < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
printk(KERN_WARNING "Failed to create a rootfs\n");
|
|
|
|
return err;
|
|
|
|
}
|
2024-09-09 08:57:42 +00:00
|
|
|
#if !IS_BUILTIN(CONFIG_BLK_DEV_INITRD)
|
2024-09-09 08:52:07 +00:00
|
|
|
rootfs_initcall(default_rootfs);
|
2024-09-09 08:57:42 +00:00
|
|
|
#endif
|