To compile the linux3.11 kernel, but download the latest YAFFS2, and then compile the error: Error:unknown field ' Readdir ' specified in initializer
Read the source found, in the linux3.11 source of the file_operations structure inside no readdir, replaced by iterate, but in yaffs inside (fs/yaffs2/yaffs_ VFS.C) or use the Readdir, so rewrite the file.
The specific changes are as follows:
#if (Linux_version_code >= kernel_version (3, 0)) static int yaffs_iterate (struct file *file, struct dir_context, *c
TX) {struct yaffs_obj *obj;
struct Yaffs_dev *dev;
struct Yaffs_search_context *sc;
struct Inode *inode = file->f_dentry->d_inode;
unsigned long offset, curoffs;
struct Yaffs_obj *l;
int ret_val = 0;
Char name[yaffs_max_name_length + 1];
obj = Yaffs_dentry_to_obj (file->f_dentry);
dev = obj->my_dev;
Yaffs_gross_lock (Dev);
YAFFS_DEV_TO_LC (dev)->readdir_process = current;
offset = ctx->pos;
sc = yaffs_new_search (obj);
if (!SC) {ret_val =-enomem;
Goto out;
Yaffs_trace (Yaffs_trace_os, "yaffs_readdir:starting at%d", (int) offset); if (offset = = 0) {yaffs_trace (Yaffs_trace_os, "yaffs_readdir:entry.")
Ino%d ", (int) inode->i_ino);
Yaffs_gross_unlock (Dev);
if (!dir_emit_dot (file, ctx)) {yaffs_gross_lock (dev); Goto out;
} yaffs_gross_lock (Dev);
offset++;
ctx->pos++; } if (offset = = 1) {yaffs_trace (Yaffs_trace_os, Yaffs_readdir:entry).
Ino%d ", (int) file->f_dentry->d_parent->d_inode->i_ino);
Yaffs_gross_unlock (Dev);
if (!dir_emit_dotdot (file, ctx)) {yaffs_gross_lock (dev);
Goto out;
} yaffs_gross_lock (Dev);
offset++;
ctx->pos++;
} curoffs = 1; /* If The directory has changed since the "open" and "Readdir", rewind to after the 2 canned entries.
*/if (file->f_version!= inode->i_version) {offset = 2;
Ctx->pos = offset;
File->f_version = inode->i_version;
while (Sc->next_return) {curoffs++;
L = sc->next_return;
if (curoffs >= offset) {int this_inode = Yaffs_get_obj_inode (l);
int this_type = Yaffs_get_obj_type (l);
Yaffs_get_obj_name (l, Name, Yaffs_max_name_length + 1); Yaffs_trAce (Yaffs_trace_os, "Yaffs_readdir:%s inode%d", Name, Yaffs_get_obj_inode (l));
Yaffs_gross_unlock (Dev);
if (!dir_emit (CTX, Name, strlen (name), This_inode, This_type) < 0) {yaffs_gross_lock (dev);
Goto out;
} yaffs_gross_lock (Dev);
offset++;
ctx->pos++;
} yaffs_search_advance (SC);
} out:yaffs_search_end (SC);
YAFFS_DEV_TO_LC (dev)->readdir_process = NULL;
Yaffs_gross_unlock (Dev);
return ret_val; #else static int yaffs_readdir (struct file *f, void *dirent, filldir_t filldir) {...} #endif
static const struct File_operations yaffs_dir_operations = {
. Read = Generic_read_dir,
// . Readdir = Yaffs_ Readdir,
//add by JXM begin
#if (Linux_version_code >= kernel_version (3, one, 0))
. Iterate = Yaffs_iterate ,
#else
. Readdir = Yaffs_readdir,
#endif
//add by jxm end
. Fsync = Yaffs_sync_object
. Llseek = Generic_file_llseek,
};
And then compile it, it's not a mistake.
Reference URL: https://dev.openwrt.org/browser/trunk/target/linux/generic/patches-3.12/503- yaffs-3.12-convert-readdir-to-iterate.patch?rev=39084#l1911
And it's going to be a mistake: fs/yaffs2/yaffs_vfs.c:3501:error:implicit declaration of the function ' Create_proc_entry ', the solution can be seen in this article I reproduced
http://blog.csdn.net/xiaominthere/article/details/17549607