你好,游客 登录 注册 搜索
背景:
阅读新闻

AT91SAM9261EK Linux 3.10.12 yaffs2 移植成功

[日期:2016-11-23] 来源:Linux社区  作者:tcjy1000 [字体:大 中 小]

 

经过测试,发现最新版本的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了。
修改后,就可以正常编译并下载成功了。

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-11/137465.htm

linux
相关资讯       yaffs2移植  AT91SAM9261 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款