1 --- a/fs/yaffs2/yaffs_vfs.c
2 +++ b/fs/yaffs2/yaffs_vfs.c
3 @@ -1701,6 +1701,110 @@ static void yaffs_remove_obj_callback(st
5 /*-----------------------------------------------------------------*/
7 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
8 +static int yaffs_readdir(struct file *file, struct dir_context *ctx)
10 + struct yaffs_obj *obj;
11 + struct yaffs_dev *dev;
12 + struct yaffs_search_context *sc;
13 + struct inode *inode = file->f_dentry->d_inode;
14 + unsigned long offset, curoffs;
15 + struct yaffs_obj *l;
18 + char name[YAFFS_MAX_NAME_LENGTH + 1];
20 + obj = yaffs_dentry_to_obj(file->f_dentry);
23 + yaffs_gross_lock(dev);
25 + yaffs_dev_to_lc(dev)->readdir_process = current;
29 + sc = yaffs_new_search(obj);
35 + yaffs_trace(YAFFS_TRACE_OS,
36 + "yaffs_readdir: starting at %d", (int)offset);
39 + yaffs_trace(YAFFS_TRACE_OS,
40 + "yaffs_readdir: entry . ino %d",
42 + yaffs_gross_unlock(dev);
43 + if (!dir_emit_dot(file, ctx)) {
44 + yaffs_gross_lock(dev);
47 + yaffs_gross_lock(dev);
52 + yaffs_trace(YAFFS_TRACE_OS,
53 + "yaffs_readdir: entry .. ino %d",
54 + (int)file->f_dentry->d_parent->d_inode->i_ino);
55 + yaffs_gross_unlock(dev);
56 + if (!dir_emit_dotdot(file, ctx)) {
57 + yaffs_gross_lock(dev);
60 + yaffs_gross_lock(dev);
67 + /* If the directory has changed since the open or last call to
68 + readdir, rewind to after the 2 canned entries. */
69 + if (file->f_version != inode->i_version) {
72 + file->f_version = inode->i_version;
75 + while (sc->next_return) {
77 + l = sc->next_return;
78 + if (curoffs >= offset) {
79 + int this_inode = yaffs_get_obj_inode(l);
80 + int this_type = yaffs_get_obj_type(l);
82 + yaffs_get_obj_name(l, name, YAFFS_MAX_NAME_LENGTH + 1);
83 + yaffs_trace(YAFFS_TRACE_OS,
84 + "yaffs_readdir: %s inode %d",
85 + name, yaffs_get_obj_inode(l));
87 + yaffs_gross_unlock(dev);
89 + if (!dir_emit(ctx, name, strlen(name),
90 + this_inode, this_type) < 0) {
91 + yaffs_gross_lock(dev);
95 + yaffs_gross_lock(dev);
100 + yaffs_search_advance(sc);
104 + yaffs_search_end(sc);
105 + yaffs_dev_to_lc(dev)->readdir_process = NULL;
106 + yaffs_gross_unlock(dev);
111 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
113 struct yaffs_obj *obj;
114 @@ -1807,10 +1911,15 @@ out:
120 static const struct file_operations yaffs_dir_operations = {
121 .read = generic_read_dir,
122 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
123 + .iterate = yaffs_readdir,
125 .readdir = yaffs_readdir,
127 .fsync = yaffs_sync_object,
128 .llseek = generic_file_llseek,