Commit 4acf381e1b6c01d6058d353191259c952bd6f3e7
1 parent
956ce2083c
Exists in
smarc_imx_lf-5.15.y
and in
34 other branches
[readdir] convert reiserfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 3 changed files with 19 additions and 23 deletions Side-by-side Diff
fs/reiserfs/dir.c
... | ... | @@ -13,14 +13,14 @@ |
13 | 13 | |
14 | 14 | extern const struct reiserfs_key MIN_KEY; |
15 | 15 | |
16 | -static int reiserfs_readdir(struct file *, void *, filldir_t); | |
16 | +static int reiserfs_readdir(struct file *, struct dir_context *); | |
17 | 17 | static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end, |
18 | 18 | int datasync); |
19 | 19 | |
20 | 20 | const struct file_operations reiserfs_dir_operations = { |
21 | 21 | .llseek = generic_file_llseek, |
22 | 22 | .read = generic_read_dir, |
23 | - .readdir = reiserfs_readdir, | |
23 | + .iterate = reiserfs_readdir, | |
24 | 24 | .fsync = reiserfs_dir_fsync, |
25 | 25 | .unlocked_ioctl = reiserfs_ioctl, |
26 | 26 | #ifdef CONFIG_COMPAT |
... | ... | @@ -58,8 +58,7 @@ |
58 | 58 | deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid); |
59 | 59 | } |
60 | 60 | |
61 | -int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent, | |
62 | - filldir_t filldir, loff_t *pos) | |
61 | +int reiserfs_readdir_dentry(struct dentry *dentry, struct dir_context *ctx) | |
63 | 62 | { |
64 | 63 | struct inode *inode = dentry->d_inode; |
65 | 64 | struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */ |
... | ... | @@ -81,7 +80,7 @@ |
81 | 80 | |
82 | 81 | /* form key for search the next directory entry using f_pos field of |
83 | 82 | file structure */ |
84 | - make_cpu_key(&pos_key, inode, *pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3); | |
83 | + make_cpu_key(&pos_key, inode, ctx->pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3); | |
85 | 84 | next_pos = cpu_key_k_offset(&pos_key); |
86 | 85 | |
87 | 86 | path_to_entry.reada = PATH_READA; |
... | ... | @@ -126,7 +125,6 @@ |
126 | 125 | entry_num++, deh++) { |
127 | 126 | int d_reclen; |
128 | 127 | char *d_name; |
129 | - off_t d_off; | |
130 | 128 | ino_t d_ino; |
131 | 129 | |
132 | 130 | if (!de_visible(deh)) |
... | ... | @@ -158,8 +156,7 @@ |
158 | 156 | if (is_privroot_deh(dentry, deh)) |
159 | 157 | continue; |
160 | 158 | |
161 | - d_off = deh_offset(deh); | |
162 | - *pos = d_off; | |
159 | + ctx->pos = deh_offset(deh); | |
163 | 160 | d_ino = deh_objectid(deh); |
164 | 161 | if (d_reclen <= 32) { |
165 | 162 | local_buf = small_buf; |
... | ... | @@ -187,9 +184,9 @@ |
187 | 184 | * the write lock here for other waiters |
188 | 185 | */ |
189 | 186 | reiserfs_write_unlock(inode->i_sb); |
190 | - if (filldir | |
191 | - (dirent, local_buf, d_reclen, d_off, d_ino, | |
192 | - DT_UNKNOWN) < 0) { | |
187 | + if (!dir_emit | |
188 | + (ctx, local_buf, d_reclen, d_ino, | |
189 | + DT_UNKNOWN)) { | |
193 | 190 | reiserfs_write_lock(inode->i_sb); |
194 | 191 | if (local_buf != small_buf) { |
195 | 192 | kfree(local_buf); |
... | ... | @@ -237,7 +234,7 @@ |
237 | 234 | } /* while */ |
238 | 235 | |
239 | 236 | end: |
240 | - *pos = next_pos; | |
237 | + ctx->pos = next_pos; | |
241 | 238 | pathrelse(&path_to_entry); |
242 | 239 | reiserfs_check_path(&path_to_entry); |
243 | 240 | out: |
244 | 241 | |
... | ... | @@ -245,10 +242,9 @@ |
245 | 242 | return ret; |
246 | 243 | } |
247 | 244 | |
248 | -static int reiserfs_readdir(struct file *file, void *dirent, filldir_t filldir) | |
245 | +static int reiserfs_readdir(struct file *file, struct dir_context *ctx) | |
249 | 246 | { |
250 | - struct dentry *dentry = file->f_path.dentry; | |
251 | - return reiserfs_readdir_dentry(dentry, dirent, filldir, &file->f_pos); | |
247 | + return reiserfs_readdir_dentry(file->f_path.dentry, ctx); | |
252 | 248 | } |
253 | 249 | |
254 | 250 | /* compose directory item containing "." and ".." entries (entries are |
fs/reiserfs/reiserfs.h
... | ... | @@ -2709,7 +2709,7 @@ |
2709 | 2709 | extern const struct inode_operations reiserfs_symlink_inode_operations; |
2710 | 2710 | extern const struct inode_operations reiserfs_special_inode_operations; |
2711 | 2711 | extern const struct file_operations reiserfs_dir_operations; |
2712 | -int reiserfs_readdir_dentry(struct dentry *, void *, filldir_t, loff_t *); | |
2712 | +int reiserfs_readdir_dentry(struct dentry *, struct dir_context *); | |
2713 | 2713 | |
2714 | 2714 | /* tail_conversion.c */ |
2715 | 2715 | int direct2indirect(struct reiserfs_transaction_handle *, struct inode *, |
fs/reiserfs/xattr.c
... | ... | @@ -171,6 +171,7 @@ |
171 | 171 | * modifying extended attributes. This includes operations such as permissions |
172 | 172 | * or ownership changes, object deletions, etc. */ |
173 | 173 | struct reiserfs_dentry_buf { |
174 | + struct dir_context ctx; | |
174 | 175 | struct dentry *xadir; |
175 | 176 | int count; |
176 | 177 | struct dentry *dentries[8]; |
177 | 178 | |
... | ... | @@ -223,9 +224,8 @@ |
223 | 224 | { |
224 | 225 | struct dentry *dir; |
225 | 226 | int i, err = 0; |
226 | - loff_t pos = 0; | |
227 | 227 | struct reiserfs_dentry_buf buf = { |
228 | - .count = 0, | |
228 | + .ctx.actor = fill_with_dentries, | |
229 | 229 | }; |
230 | 230 | |
231 | 231 | /* Skip out, an xattr has no xattrs associated with it */ |
... | ... | @@ -249,7 +249,7 @@ |
249 | 249 | reiserfs_write_lock(inode->i_sb); |
250 | 250 | |
251 | 251 | buf.xadir = dir; |
252 | - err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos); | |
252 | + err = reiserfs_readdir_dentry(dir, &buf.ctx); | |
253 | 253 | while ((err == 0 || err == -ENOSPC) && buf.count) { |
254 | 254 | err = 0; |
255 | 255 | |
... | ... | @@ -266,8 +266,7 @@ |
266 | 266 | } |
267 | 267 | buf.count = 0; |
268 | 268 | if (!err) |
269 | - err = reiserfs_readdir_dentry(dir, &buf, | |
270 | - fill_with_dentries, &pos); | |
269 | + err = reiserfs_readdir_dentry(dir, &buf.ctx); | |
271 | 270 | } |
272 | 271 | mutex_unlock(&dir->d_inode->i_mutex); |
273 | 272 | |
... | ... | @@ -800,6 +799,7 @@ |
800 | 799 | } |
801 | 800 | |
802 | 801 | struct listxattr_buf { |
802 | + struct dir_context ctx; | |
803 | 803 | size_t size; |
804 | 804 | size_t pos; |
805 | 805 | char *buf; |
806 | 806 | |
... | ... | @@ -845,8 +845,8 @@ |
845 | 845 | { |
846 | 846 | struct dentry *dir; |
847 | 847 | int err = 0; |
848 | - loff_t pos = 0; | |
849 | 848 | struct listxattr_buf buf = { |
849 | + .ctx.actor = listxattr_filler, | |
850 | 850 | .dentry = dentry, |
851 | 851 | .buf = buffer, |
852 | 852 | .size = buffer ? size : 0, |
... | ... | @@ -868,7 +868,7 @@ |
868 | 868 | } |
869 | 869 | |
870 | 870 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR); |
871 | - err = reiserfs_readdir_dentry(dir, &buf, listxattr_filler, &pos); | |
871 | + err = reiserfs_readdir_dentry(dir, &buf.ctx); | |
872 | 872 | mutex_unlock(&dir->d_inode->i_mutex); |
873 | 873 | |
874 | 874 | if (!err) |