歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> AT91SAM9261EK Linux 3.10.12 yaffs2 移植成功

AT91SAM9261EK Linux 3.10.12 yaffs2 移植成功

日期:2017/3/1 9:09:08   编辑:Linux編程

經過測試,發現最新版本的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)) /* edit here use NEW PROCFS */
#define YAFFS_NEW_PROCFS
#include <linux/seq_file.h>
#endif

把:KERNEL_VERSION(3,12,0)->KERNEL_VERSION(3,10,0))這裡因為在3.10版本裡,已經使用 YAFFS_NEW_PROCFS了。
修改後,就可以正常編譯並下載成功了。

Copyright © Linux教程網 All Rights Reserved