Skip to content

Commit 2de5f05

Browse files
author
Al Viro
committed
[readdir] convert ecryptfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e924f25 commit 2de5f05

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

‎fs/ecryptfs/file.c‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb,
6969

7070
struct ecryptfs_getdents_callback {
7171
struct dir_context ctx;
72-
void *dirent;
72+
struct dir_context *caller;
7373
struct dentry *dentry;
74-
filldir_t filldir;
7574
int filldir_called;
7675
int entries_written;
7776
};
@@ -97,9 +96,10 @@ ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen,
9796
rc);
9897
goto out;
9998
}
100-
rc = buf->filldir(buf->dirent, name, name_size, offset, ino, d_type);
99+
buf->caller->pos = buf->ctx.pos;
100+
rc = !dir_emit(buf->caller, name, name_size, ino, d_type);
101101
kfree(name);
102-
if (rc >= 0)
102+
if (!rc)
103103
buf->entries_written++;
104104
out:
105105
return rc;
@@ -108,28 +108,23 @@ ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen,
108108
/**
109109
* ecryptfs_readdir
110110
* @file: The eCryptfs directory file
111-
* @dirent: Directory entry handle
112-
* @filldir: The filldir callback function
111+
* @ctx: The actor to feed the entries to
113112
*/
114-
static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
113+
static int ecryptfs_readdir(struct file *file, struct dir_context *ctx)
115114
{
116115
int rc;
117116
struct file *lower_file;
118117
struct inode *inode;
119-
struct ecryptfs_getdents_callback buf;
120-
118+
struct ecryptfs_getdents_callback buf = {
119+
.ctx.actor = ecryptfs_filldir,
120+
.caller = ctx,
121+
.dentry = file->f_path.dentry
122+
};
121123
lower_file = ecryptfs_file_to_lower(file);
122-
lower_file->f_pos = file->f_pos;
124+
lower_file->f_pos = ctx->pos;
123125
inode = file_inode(file);
124-
memset(&buf, 0, sizeof(buf));
125-
buf.dirent = dirent;
126-
buf.dentry = file->f_path.dentry;
127-
buf.filldir = filldir;
128-
buf.filldir_called = 0;
129-
buf.entries_written = 0;
130-
buf.ctx.actor = ecryptfs_filldir;
131126
rc = iterate_dir(lower_file, &buf.ctx);
132-
file->f_pos = lower_file->f_pos;
127+
ctx->pos = buf.ctx.pos;
133128
if (rc < 0)
134129
goto out;
135130
if (buf.filldir_called && !buf.entries_written)
@@ -346,7 +341,7 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
346341
#endif
347342

348343
const struct file_operations ecryptfs_dir_fops = {
349-
.readdir = ecryptfs_readdir,
344+
.iterate = ecryptfs_readdir,
350345
.read = generic_read_dir,
351346
.unlocked_ioctl = ecryptfs_unlocked_ioctl,
352347
#ifdef CONFIG_COMPAT
@@ -367,7 +362,7 @@ const struct file_operations ecryptfs_main_fops = {
367362
.aio_read = ecryptfs_read_update_atime,
368363
.write = do_sync_write,
369364
.aio_write = generic_file_aio_write,
370-
.readdir = ecryptfs_readdir,
365+
.iterate = ecryptfs_readdir,
371366
.unlocked_ioctl = ecryptfs_unlocked_ioctl,
372367
#ifdef CONFIG_COMPAT
373368
.compat_ioctl = ecryptfs_compat_ioctl,

0 commit comments

Comments
 (0)