aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/dir.c')
-rw-r--r--fs/reiserfs/dir.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 66c53b642a88..03e4ca5624d6 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -13,14 +13,14 @@
13 13
14extern const struct reiserfs_key MIN_KEY; 14extern const struct reiserfs_key MIN_KEY;
15 15
16static int reiserfs_readdir(struct file *, void *, filldir_t); 16static int reiserfs_readdir(struct file *, struct dir_context *);
17static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end, 17static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
18 int datasync); 18 int datasync);
19 19
20const struct file_operations reiserfs_dir_operations = { 20const struct file_operations reiserfs_dir_operations = {
21 .llseek = generic_file_llseek, 21 .llseek = generic_file_llseek,
22 .read = generic_read_dir, 22 .read = generic_read_dir,
23 .readdir = reiserfs_readdir, 23 .iterate = reiserfs_readdir,
24 .fsync = reiserfs_dir_fsync, 24 .fsync = reiserfs_dir_fsync,
25 .unlocked_ioctl = reiserfs_ioctl, 25 .unlocked_ioctl = reiserfs_ioctl,
26#ifdef CONFIG_COMPAT 26#ifdef CONFIG_COMPAT
@@ -50,18 +50,15 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
50 50
51#define store_ih(where,what) copy_item_head (where, what) 51#define store_ih(where,what) copy_item_head (where, what)
52 52
53static inline bool is_privroot_deh(struct dentry *dir, 53static inline bool is_privroot_deh(struct inode *dir, struct reiserfs_de_head *deh)
54 struct reiserfs_de_head *deh)
55{ 54{
56 struct dentry *privroot = REISERFS_SB(dir->d_sb)->priv_root; 55 struct dentry *privroot = REISERFS_SB(dir->i_sb)->priv_root;
57 return (dir == dir->d_parent && privroot->d_inode && 56 return (privroot->d_inode &&
58 deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid); 57 deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid);
59} 58}
60 59
61int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent, 60int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
62 filldir_t filldir, loff_t *pos)
63{ 61{
64 struct inode *inode = dentry->d_inode;
65 struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */ 62 struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
66 INITIALIZE_PATH(path_to_entry); 63 INITIALIZE_PATH(path_to_entry);
67 struct buffer_head *bh; 64 struct buffer_head *bh;
@@ -81,7 +78,7 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
81 78
82 /* form key for search the next directory entry using f_pos field of 79 /* form key for search the next directory entry using f_pos field of
83 file structure */ 80 file structure */
84 make_cpu_key(&pos_key, inode, *pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3); 81 make_cpu_key(&pos_key, inode, ctx->pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3);
85 next_pos = cpu_key_k_offset(&pos_key); 82 next_pos = cpu_key_k_offset(&pos_key);
86 83
87 path_to_entry.reada = PATH_READA; 84 path_to_entry.reada = PATH_READA;
@@ -126,7 +123,6 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
126 entry_num++, deh++) { 123 entry_num++, deh++) {
127 int d_reclen; 124 int d_reclen;
128 char *d_name; 125 char *d_name;
129 off_t d_off;
130 ino_t d_ino; 126 ino_t d_ino;
131 127
132 if (!de_visible(deh)) 128 if (!de_visible(deh))
@@ -155,11 +151,10 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
155 } 151 }
156 152
157 /* Ignore the .reiserfs_priv entry */ 153 /* Ignore the .reiserfs_priv entry */
158 if (is_privroot_deh(dentry, deh)) 154 if (is_privroot_deh(inode, deh))
159 continue; 155 continue;
160 156
161 d_off = deh_offset(deh); 157 ctx->pos = deh_offset(deh);
162 *pos = d_off;
163 d_ino = deh_objectid(deh); 158 d_ino = deh_objectid(deh);
164 if (d_reclen <= 32) { 159 if (d_reclen <= 32) {
165 local_buf = small_buf; 160 local_buf = small_buf;
@@ -187,9 +182,9 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
187 * the write lock here for other waiters 182 * the write lock here for other waiters
188 */ 183 */
189 reiserfs_write_unlock(inode->i_sb); 184 reiserfs_write_unlock(inode->i_sb);
190 if (filldir 185 if (!dir_emit
191 (dirent, local_buf, d_reclen, d_off, d_ino, 186 (ctx, local_buf, d_reclen, d_ino,
192 DT_UNKNOWN) < 0) { 187 DT_UNKNOWN)) {
193 reiserfs_write_lock(inode->i_sb); 188 reiserfs_write_lock(inode->i_sb);
194 if (local_buf != small_buf) { 189 if (local_buf != small_buf) {
195 kfree(local_buf); 190 kfree(local_buf);
@@ -204,6 +199,8 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
204 next_pos = deh_offset(deh) + 1; 199 next_pos = deh_offset(deh) + 1;
205 200
206 if (item_moved(&tmp_ih, &path_to_entry)) { 201 if (item_moved(&tmp_ih, &path_to_entry)) {
202 set_cpu_key_k_offset(&pos_key,
203 next_pos);
207 goto research; 204 goto research;
208 } 205 }
209 } /* for */ 206 } /* for */
@@ -235,7 +232,7 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
235 } /* while */ 232 } /* while */
236 233
237end: 234end:
238 *pos = next_pos; 235 ctx->pos = next_pos;
239 pathrelse(&path_to_entry); 236 pathrelse(&path_to_entry);
240 reiserfs_check_path(&path_to_entry); 237 reiserfs_check_path(&path_to_entry);
241out: 238out:
@@ -243,10 +240,9 @@ out:
243 return ret; 240 return ret;
244} 241}
245 242
246static int reiserfs_readdir(struct file *file, void *dirent, filldir_t filldir) 243static int reiserfs_readdir(struct file *file, struct dir_context *ctx)
247{ 244{
248 struct dentry *dentry = file->f_path.dentry; 245 return reiserfs_readdir_inode(file_inode(file), ctx);
249 return reiserfs_readdir_dentry(dentry, dirent, filldir, &file->f_pos);
250} 246}
251 247
252/* compose directory item containing "." and ".." entries (entries are 248/* compose directory item containing "." and ".." entries (entries are