diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-22 21:23:40 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-29 04:57:04 -0400 |
commit | 2de5f059c4422e357b7df021b487a37b1d61356b (patch) | |
tree | 2cb4cc8544d9d80fd8b14e14814c984966cbadd7 /fs/ecryptfs | |
parent | e924f251264bec0b73c32f15ed27a7fbb9912beb (diff) |
[readdir] convert ecryptfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/file.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 041379a646b3..9aa05e08060b 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -69,9 +69,8 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, | |||
69 | 69 | ||
70 | struct ecryptfs_getdents_callback { | 70 | struct ecryptfs_getdents_callback { |
71 | struct dir_context ctx; | 71 | struct dir_context ctx; |
72 | void *dirent; | 72 | struct dir_context *caller; |
73 | struct dentry *dentry; | 73 | struct dentry *dentry; |
74 | filldir_t filldir; | ||
75 | int filldir_called; | 74 | int filldir_called; |
76 | int entries_written; | 75 | int entries_written; |
77 | }; | 76 | }; |
@@ -97,9 +96,10 @@ ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen, | |||
97 | rc); | 96 | rc); |
98 | goto out; | 97 | goto out; |
99 | } | 98 | } |
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); | ||
101 | kfree(name); | 101 | kfree(name); |
102 | if (rc >= 0) | 102 | if (!rc) |
103 | buf->entries_written++; | 103 | buf->entries_written++; |
104 | out: | 104 | out: |
105 | return rc; | 105 | return rc; |
@@ -108,28 +108,23 @@ out: | |||
108 | /** | 108 | /** |
109 | * ecryptfs_readdir | 109 | * ecryptfs_readdir |
110 | * @file: The eCryptfs directory file | 110 | * @file: The eCryptfs directory file |
111 | * @dirent: Directory entry handle | 111 | * @ctx: The actor to feed the entries to |
112 | * @filldir: The filldir callback function | ||
113 | */ | 112 | */ |
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) |
115 | { | 114 | { |
116 | int rc; | 115 | int rc; |
117 | struct file *lower_file; | 116 | struct file *lower_file; |
118 | struct inode *inode; | 117 | struct inode *inode; |
119 | struct ecryptfs_getdents_callback buf; | 118 | struct ecryptfs_getdents_callback buf = { |
120 | 119 | .ctx.actor = ecryptfs_filldir, | |
120 | .caller = ctx, | ||
121 | .dentry = file->f_path.dentry | ||
122 | }; | ||
121 | lower_file = ecryptfs_file_to_lower(file); | 123 | lower_file = ecryptfs_file_to_lower(file); |
122 | lower_file->f_pos = file->f_pos; | 124 | lower_file->f_pos = ctx->pos; |
123 | inode = file_inode(file); | 125 | 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; | ||
131 | rc = iterate_dir(lower_file, &buf.ctx); | 126 | rc = iterate_dir(lower_file, &buf.ctx); |
132 | file->f_pos = lower_file->f_pos; | 127 | ctx->pos = buf.ctx.pos; |
133 | if (rc < 0) | 128 | if (rc < 0) |
134 | goto out; | 129 | goto out; |
135 | if (buf.filldir_called && !buf.entries_written) | 130 | if (buf.filldir_called && !buf.entries_written) |
@@ -346,7 +341,7 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
346 | #endif | 341 | #endif |
347 | 342 | ||
348 | const struct file_operations ecryptfs_dir_fops = { | 343 | const struct file_operations ecryptfs_dir_fops = { |
349 | .readdir = ecryptfs_readdir, | 344 | .iterate = ecryptfs_readdir, |
350 | .read = generic_read_dir, | 345 | .read = generic_read_dir, |
351 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, | 346 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, |
352 | #ifdef CONFIG_COMPAT | 347 | #ifdef CONFIG_COMPAT |
@@ -367,7 +362,7 @@ const struct file_operations ecryptfs_main_fops = { | |||
367 | .aio_read = ecryptfs_read_update_atime, | 362 | .aio_read = ecryptfs_read_update_atime, |
368 | .write = do_sync_write, | 363 | .write = do_sync_write, |
369 | .aio_write = generic_file_aio_write, | 364 | .aio_write = generic_file_aio_write, |
370 | .readdir = ecryptfs_readdir, | 365 | .iterate = ecryptfs_readdir, |
371 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, | 366 | .unlocked_ioctl = ecryptfs_unlocked_ioctl, |
372 | #ifdef CONFIG_COMPAT | 367 | #ifdef CONFIG_COMPAT |
373 | .compat_ioctl = ecryptfs_compat_ioctl, | 368 | .compat_ioctl = ecryptfs_compat_ioctl, |