经过测试,发现最新版本的yaffs2很容易移植到Linux 2.xx与Linux 3.xx的版本上。

我使用Linux 3.10.12之前的版本,打上yaffs2最新版本补丁后,直接编译通过。但Linux 3.10.12却提示错误:


fs/yaffs2/yaffs_vfs.c: In function 'init_yaffs_fs':
fs/yaffs2/yaffs_vfs.c:3398: error: implicit declaration of function 'create_proc_entry'
fs/yaffs2/yaffs_vfs.c:3399: warning: assignment makes pointer from integer without a cast
fs/yaffs2/yaffs_vfs.c:3402: error: dereferencing pointer to incomplete type
fs/yaffs2/yaffs_vfs.c:3403: error: dereferencing pointer to incomplete type
fs/yaffs2/yaffs_vfs.c:3404: error: dereferencing pointer to incomplete type
make[2]: * [fs/yaffs2/yaffs_vfs.o] Error 1
make[1]: * [fs/yaffs2] Error 2
make: * [fs] Error 2




       经过查找并搜索相应的代码,发现内核改了。

create_proc_entry()/create_proc_read_entry() are killed off; use proc_create().

因此需要用:proc_create来代替原来的:


# gedit ./fs/yaffs2/yaffs_vfs.c



#ifdef YAFFS_NEW_PROCFS
static int yaffs_proc_show(struct seq_file *m, void *v)
{
	/* FIXME: Unify in a better way? */
	char buffer[512];
	char *start;
	int len;

	len = yaffs_proc_read(buffer, &start, 0, sizeof(buffer), NULL, NULL);
	seq_puts(m, buffer);
	return 0;
}

static int yaffs_proc_open(struct inode *inode, struct file *file)
{
	return single_open(file, yaffs_proc_show, NULL);
}

static struct file_operations procfs_ops = {
	.owner = THIS_MODULE,
	.open  = yaffs_proc_open,
	.read  = seq_read,
	.write = yaffs_proc_write,
};

static int yaffs_procfs_init(void)
{
	/* Install the proc_fs entries */
	my_proc_entry = proc_create("yaffs",
				    S_IRUGO | S_IFREG,
				    YPROC_ROOT,
				    &procfs_ops);

	if (my_proc_entry) {
		return 0;
	} else {
		return -ENOMEM;
	}
}

#else

static int yaffs_procfs_init(void)
{
	/* Install the proc_fs entries */
	my_proc_entry = create_proc_entry("yaffs",
					S_IRUGO | S_IFREG, 
					YPROC_ROOT);

	if (my_proc_entry) {
		my_proc_entry->write_proc = yaffs_proc_write;
		my_proc_entry->read_proc = yaffs_proc_read;
		my_proc_entry->data = NULL;
		return 0;
	} else {
		return -ENOMEM;
	}
}

#endif




         因此,只要打开编译开关  YAFFS_NEW_PROCFS 即可!经过进一步搜索:YAFFS_NEW_PROCFS,发现有版本宏控制,因此修改如下:


#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) 
 
 
#define YAFFS_NEW_PROCFS
 
 
#include <linux/seq_file.h>
 
 
#endif


这里因为在3.10版本里,已经使用 YAFFS_NEW_PROCFS了。

修改后,就可以正常编译并下载成功了。