mount_devfs_fs(): unable to mount devfs, err: -2

长平狐 发布于 2013/06/03 14:52
阅读 113
收藏 0
mount_devfs_fs(): unable to mount devfs, err: -2

内核版本

2.6.14

交叉编译器

arm-linux-gcc 3.4.1

错误:


Freeing init memory: 92K
Warning: unable to open an initial console.
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

分析:

关于mount_devfs_fs(): unable to mount devfs, err: -2错误,在网上找了很多资料,主要是nand的ECC问题。如下修改即可:
  • 在driver/mtd/nand/s3c2410.c文件中把NAND_ECC_SOFT改成NAND_ECC_NONE;
  • 裁剪内核时选中Lets Yaffs do its own ECC。
但这样修改后还是出现上面的错误,没办法,只能分析内核源码。通过 mount_devfs_fs(): unable to mount devfs, err: -2,定位到fs/Base.c中的mount_devfs_fs函数:
void __init mount_devfs_fs(void)
{
	int err;

	if (!(boot_options & OPTION_MOUNT))
		return;
	err = do_mount("none", "/dev", "devfs", 0, NULL);
	if (err == 0)
		printk(KERN_INFO "Mounted devfs on /dev\n");
	else
		PRINTK("(): unable to mount devfs, err: %d\n", err);
}
继续跟踪到fs/namespace.c的do_mount函数
/*
 * Flags is a 32-bit value that allows up to 31 non-fs dependent flags to
 * be given to the mount() call (ie: read-only, no-dev, no-suid etc).
 *
 * data is a (void *) that can point to any structure up to
 * PAGE_SIZE-1 bytes, which can contain arbitrary fs-dependent
 * information (or be NULL).
 *
 * Pre-0.97 versions of mount() didn't have a flags word.
 * When the flags word was introduced its top half was required
 * to have the magic value 0xC0ED, and this remained so until 2.4.0-test9.
 * Therefore, if this magic number is present, it carries no information
 * and must be discarded.
 */
long do_mount(char * dev_name, char * dir_name, char *type_page,
		  unsigned long flags, void *data_page)
{
	struct nameidata nd;
	int retval = 0;
	int mnt_flags = 0;

	/* Discard magic */
	if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
		flags &= ~MS_MGC_MSK;

	/* Basic sanity checks */

	if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE))
		return -EINVAL;
	if (dev_name && !memchr(dev_name, 0, PAGE_SIZE))
		return -EINVAL;

	if (data_page)
		((char *)data_page)[PAGE_SIZE - 1] = 0;

	/* Separate the per-mountpoint flags */
	if (flags & MS_NOSUID)
		mnt_flags |= MNT_NOSUID;
	if (flags & MS_NODEV)
		mnt_flags |= MNT_NODEV;
	if (flags & MS_NOEXEC)
		mnt_flags |= MNT_NOEXEC;
	flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);

	/* ... and get the mountpoint */
	retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
	if (retval)
		return retval;

	retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
	if (retval)
		goto dput_out;

	if (flags & MS_REMOUNT)
		retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
				    data_page);
	else if (flags & MS_BIND)
		retval = do_loopback(&nd, dev_name, flags & MS_REC);
	else if (flags & MS_MOVE)
		retval = do_move_mount(&nd, dev_name);
	else
		retval = do_new_mount(&nd, type_page, flags, mnt_flags,
				      dev_name, data_page);
dput_out:
	path_release(&nd);
	return retval;
}
do_mount函数中通过最简单的方法printk函数进行具体的定位,发现是path_lookup函数返回-2,并return。path_lookup函数在VFS中用于查找文件在这里即查找/dev。path_lookup函数成功时返回0和nd,返回其他值时失败(/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */)。path_lookup函数返回-2说明没有找到/dev目录,应该是文件系统没有做好,换了一个mkyaffs2image制作文件系统,烧写进nand,启动后的错误信息如下:
Mounted devfs on /dev
Freeing init memory: 92K
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
接下来的错误可能是BusyBox没有弄好,从一个错误到了另一个错误。
由于时间紧迫,这个问题暂时放一下,最后通过成功挂载了NFS,会在另一篇博客中具体讲解如何移植CS8900网卡和挂载NFS。

原文链接:http://blog.csdn.net/ce123/article/details/8424002
加载中
返回顶部
顶部