aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/kernel/osf_sys.c13
-rw-r--r--arch/parisc/hpux/fs.c12
-rw-r--r--fs/compat.c33
-rw-r--r--fs/exportfs/expfs.c10
-rw-r--r--fs/gfs2/export.c8
-rw-r--r--fs/nfsd/nfs4recover.c7
-rw-r--r--fs/nfsd/vfs.c7
-rw-r--r--fs/readdir.c33
-rw-r--r--include/linux/fs.h2
9 files changed, 57 insertions, 68 deletions
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index ac19c7299d8e..1402fcc11c2c 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -147,17 +147,16 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd,
147{ 147{
148 int error; 148 int error;
149 struct fd arg = fdget(fd); 149 struct fd arg = fdget(fd);
150 struct osf_dirent_callback buf; 150 struct osf_dirent_callback buf = {
151 .ctx.actor = osf_filldir,
152 .dirent = dirent,
153 .basep = basep,
154 .count = count
155 };
151 156
152 if (!arg.file) 157 if (!arg.file)
153 return -EBADF; 158 return -EBADF;
154 159
155 buf.dirent = dirent;
156 buf.basep = basep;
157 buf.count = count;
158 buf.error = 0;
159 buf.ctx.actor = osf_filldir;
160
161 error = iterate_dir(arg.file, &buf.ctx); 160 error = iterate_dir(arg.file, &buf.ctx);
162 if (error >= 0) 161 if (error >= 0)
163 error = buf.error; 162 error = buf.error;
diff --git a/arch/parisc/hpux/fs.c b/arch/parisc/hpux/fs.c
index eca8230267cc..88d0962de65a 100644
--- a/arch/parisc/hpux/fs.c
+++ b/arch/parisc/hpux/fs.c
@@ -111,19 +111,17 @@ int hpux_getdents(unsigned int fd, struct hpux_dirent __user *dirent, unsigned i
111{ 111{
112 struct fd arg; 112 struct fd arg;
113 struct hpux_dirent __user * lastdirent; 113 struct hpux_dirent __user * lastdirent;
114 struct getdents_callback buf; 114 struct getdents_callback buf = {
115 .ctx.actor = filldir,
116 .current_dir = dirent,
117 .count = count
118 };
115 int error; 119 int error;
116 120
117 arg = fdget(fd); 121 arg = fdget(fd);
118 if (!arg.file) 122 if (!arg.file)
119 return -EBADF; 123 return -EBADF;
120 124
121 buf.current_dir = dirent;
122 buf.previous = NULL;
123 buf.count = count;
124 buf.error = 0;
125 buf.ctx.actor = filldir;
126
127 error = iterate_dir(arg.file, &buf.ctx); 125 error = iterate_dir(arg.file, &buf.ctx);
128 if (error >= 0) 126 if (error >= 0)
129 error = buf.error; 127 error = buf.error;
diff --git a/fs/compat.c b/fs/compat.c
index 69ca1e301766..6af20de2c1a3 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -874,15 +874,14 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
874{ 874{
875 int error; 875 int error;
876 struct fd f = fdget(fd); 876 struct fd f = fdget(fd);
877 struct compat_readdir_callback buf; 877 struct compat_readdir_callback buf = {
878 .ctx.actor = compat_fillonedir,
879 .dirent = dirent
880 };
878 881
879 if (!f.file) 882 if (!f.file)
880 return -EBADF; 883 return -EBADF;
881 884
882 buf.result = 0;
883 buf.dirent = dirent;
884 buf.ctx.actor = compat_fillonedir;
885
886 error = iterate_dir(f.file, &buf.ctx); 885 error = iterate_dir(f.file, &buf.ctx);
887 if (buf.result) 886 if (buf.result)
888 error = buf.result; 887 error = buf.result;
@@ -954,7 +953,11 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
954{ 953{
955 struct fd f; 954 struct fd f;
956 struct compat_linux_dirent __user * lastdirent; 955 struct compat_linux_dirent __user * lastdirent;
957 struct compat_getdents_callback buf; 956 struct compat_getdents_callback buf = {
957 .ctx.actor = compat_filldir,
958 .current_dir = dirent,
959 .count = count
960 };
958 int error; 961 int error;
959 962
960 if (!access_ok(VERIFY_WRITE, dirent, count)) 963 if (!access_ok(VERIFY_WRITE, dirent, count))
@@ -964,12 +967,6 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
964 if (!f.file) 967 if (!f.file)
965 return -EBADF; 968 return -EBADF;
966 969
967 buf.current_dir = dirent;
968 buf.previous = NULL;
969 buf.count = count;
970 buf.error = 0;
971 buf.ctx.actor = compat_filldir;
972
973 error = iterate_dir(f.file, &buf.ctx); 970 error = iterate_dir(f.file, &buf.ctx);
974 if (error >= 0) 971 if (error >= 0)
975 error = buf.error; 972 error = buf.error;
@@ -1041,7 +1038,11 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
1041{ 1038{
1042 struct fd f; 1039 struct fd f;
1043 struct linux_dirent64 __user * lastdirent; 1040 struct linux_dirent64 __user * lastdirent;
1044 struct compat_getdents_callback64 buf; 1041 struct compat_getdents_callback64 buf = {
1042 .ctx.actor = compat_filldir64,
1043 .current_dir = dirent,
1044 .count = count
1045 };
1045 int error; 1046 int error;
1046 1047
1047 if (!access_ok(VERIFY_WRITE, dirent, count)) 1048 if (!access_ok(VERIFY_WRITE, dirent, count))
@@ -1051,12 +1052,6 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
1051 if (!f.file) 1052 if (!f.file)
1052 return -EBADF; 1053 return -EBADF;
1053 1054
1054 buf.current_dir = dirent;
1055 buf.previous = NULL;
1056 buf.count = count;
1057 buf.error = 0;
1058 buf.ctx.actor = compat_filldir64;
1059
1060 error = iterate_dir(f.file, &buf.ctx); 1055 error = iterate_dir(f.file, &buf.ctx);
1061 if (error >= 0) 1056 if (error >= 0)
1062 error = buf.error; 1057 error = buf.error;
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 78072e65f926..293bc2e47a73 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -255,7 +255,11 @@ static int get_name(const struct path *path, char *name, struct dentry *child)
255 struct inode *dir = path->dentry->d_inode; 255 struct inode *dir = path->dentry->d_inode;
256 int error; 256 int error;
257 struct file *file; 257 struct file *file;
258 struct getdents_callback buffer; 258 struct getdents_callback buffer = {
259 .ctx.actor = filldir_one,
260 .name = name,
261 .ino = child->d_inode->i_ino
262 };
259 263
260 error = -ENOTDIR; 264 error = -ENOTDIR;
261 if (!dir || !S_ISDIR(dir->i_mode)) 265 if (!dir || !S_ISDIR(dir->i_mode))
@@ -275,11 +279,7 @@ static int get_name(const struct path *path, char *name, struct dentry *child)
275 if (!file->f_op->iterate) 279 if (!file->f_op->iterate)
276 goto out_close; 280 goto out_close;
277 281
278 buffer.name = name;
279 buffer.ino = child->d_inode->i_ino;
280 buffer.found = 0;
281 buffer.sequence = 0; 282 buffer.sequence = 0;
282 buffer.ctx.actor = filldir_one;
283 while (1) { 283 while (1) {
284 int old_seq = buffer.sequence; 284 int old_seq = buffer.sequence;
285 285
diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
index aed4003486d6..8b9b3775e2e7 100644
--- a/fs/gfs2/export.c
+++ b/fs/gfs2/export.c
@@ -89,7 +89,10 @@ static int gfs2_get_name(struct dentry *parent, char *name,
89 struct inode *dir = parent->d_inode; 89 struct inode *dir = parent->d_inode;
90 struct inode *inode = child->d_inode; 90 struct inode *inode = child->d_inode;
91 struct gfs2_inode *dip, *ip; 91 struct gfs2_inode *dip, *ip;
92 struct get_name_filldir gnfd; 92 struct get_name_filldir gnfd = {
93 .ctx.actor = get_name_filldir,
94 .name = name
95 };
93 struct gfs2_holder gh; 96 struct gfs2_holder gh;
94 int error; 97 int error;
95 struct file_ra_state f_ra = { .start = 0 }; 98 struct file_ra_state f_ra = { .start = 0 };
@@ -106,9 +109,6 @@ static int gfs2_get_name(struct dentry *parent, char *name,
106 *name = 0; 109 *name = 0;
107 gnfd.inum.no_addr = ip->i_no_addr; 110 gnfd.inum.no_addr = ip->i_no_addr;
108 gnfd.inum.no_formal_ino = ip->i_no_formal_ino; 111 gnfd.inum.no_formal_ino = ip->i_no_formal_ino;
109 gnfd.name = name;
110 gnfd.ctx.actor = get_name_filldir;
111 gnfd.ctx.pos = 0;
112 112
113 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &gh); 113 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &gh);
114 if (error) 114 if (error)
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 2fa2e2eb190b..105a3b080d12 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -268,7 +268,10 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
268{ 268{
269 const struct cred *original_cred; 269 const struct cred *original_cred;
270 struct dentry *dir = nn->rec_file->f_path.dentry; 270 struct dentry *dir = nn->rec_file->f_path.dentry;
271 struct nfs4_dir_ctx ctx; 271 struct nfs4_dir_ctx ctx = {
272 .ctx.actor = nfsd4_build_namelist,
273 .names = LIST_HEAD_INIT(ctx.names)
274 };
272 int status; 275 int status;
273 276
274 status = nfs4_save_creds(&original_cred); 277 status = nfs4_save_creds(&original_cred);
@@ -281,8 +284,6 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
281 return status; 284 return status;
282 } 285 }
283 286
284 INIT_LIST_HEAD(&ctx.names);
285 ctx.ctx.actor = nfsd4_build_namelist;
286 status = iterate_dir(nn->rec_file, &ctx.ctx); 287 status = iterate_dir(nn->rec_file, &ctx.ctx);
287 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); 288 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
288 while (!list_empty(&ctx.names)) { 289 while (!list_empty(&ctx.names)) {
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index f939ba9bf8e8..a6bc8a7423db 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1944,14 +1944,15 @@ static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
1944static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func, 1944static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func,
1945 struct readdir_cd *cdp, loff_t *offsetp) 1945 struct readdir_cd *cdp, loff_t *offsetp)
1946{ 1946{
1947 struct readdir_data buf;
1948 struct buffered_dirent *de; 1947 struct buffered_dirent *de;
1949 int host_err; 1948 int host_err;
1950 int size; 1949 int size;
1951 loff_t offset; 1950 loff_t offset;
1951 struct readdir_data buf = {
1952 .ctx.actor = nfsd_buffered_filldir,
1953 .dirent = (void *)__get_free_page(GFP_KERNEL)
1954 };
1952 1955
1953 buf.ctx.actor = nfsd_buffered_filldir;
1954 buf.dirent = (void *)__get_free_page(GFP_KERNEL);
1955 if (!buf.dirent) 1956 if (!buf.dirent)
1956 return nfserrno(-ENOMEM); 1957 return nfserrno(-ENOMEM);
1957 1958
diff --git a/fs/readdir.c b/fs/readdir.c
index a6245c9fd0e6..93d71e574310 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -109,15 +109,14 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
109{ 109{
110 int error; 110 int error;
111 struct fd f = fdget(fd); 111 struct fd f = fdget(fd);
112 struct readdir_callback buf; 112 struct readdir_callback buf = {
113 .ctx.actor = fillonedir,
114 .dirent = dirent
115 };
113 116
114 if (!f.file) 117 if (!f.file)
115 return -EBADF; 118 return -EBADF;
116 119
117 buf.ctx.actor = fillonedir;
118 buf.result = 0;
119 buf.dirent = dirent;
120
121 error = iterate_dir(f.file, &buf.ctx); 120 error = iterate_dir(f.file, &buf.ctx);
122 if (buf.result) 121 if (buf.result)
123 error = buf.result; 122 error = buf.result;
@@ -195,7 +194,11 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
195{ 194{
196 struct fd f; 195 struct fd f;
197 struct linux_dirent __user * lastdirent; 196 struct linux_dirent __user * lastdirent;
198 struct getdents_callback buf; 197 struct getdents_callback buf = {
198 .ctx.actor = filldir,
199 .count = count,
200 .current_dir = dirent
201 };
199 int error; 202 int error;
200 203
201 if (!access_ok(VERIFY_WRITE, dirent, count)) 204 if (!access_ok(VERIFY_WRITE, dirent, count))
@@ -205,12 +208,6 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
205 if (!f.file) 208 if (!f.file)
206 return -EBADF; 209 return -EBADF;
207 210
208 buf.current_dir = dirent;
209 buf.previous = NULL;
210 buf.count = count;
211 buf.error = 0;
212 buf.ctx.actor = filldir;
213
214 error = iterate_dir(f.file, &buf.ctx); 211 error = iterate_dir(f.file, &buf.ctx);
215 if (error >= 0) 212 if (error >= 0)
216 error = buf.error; 213 error = buf.error;
@@ -277,7 +274,11 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
277{ 274{
278 struct fd f; 275 struct fd f;
279 struct linux_dirent64 __user * lastdirent; 276 struct linux_dirent64 __user * lastdirent;
280 struct getdents_callback64 buf; 277 struct getdents_callback64 buf = {
278 .ctx.actor = filldir64,
279 .count = count,
280 .current_dir = dirent
281 };
281 int error; 282 int error;
282 283
283 if (!access_ok(VERIFY_WRITE, dirent, count)) 284 if (!access_ok(VERIFY_WRITE, dirent, count))
@@ -287,12 +288,6 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
287 if (!f.file) 288 if (!f.file)
288 return -EBADF; 289 return -EBADF;
289 290
290 buf.current_dir = dirent;
291 buf.previous = NULL;
292 buf.count = count;
293 buf.error = 0;
294 buf.ctx.actor = filldir64;
295
296 error = iterate_dir(f.file, &buf.ctx); 291 error = iterate_dir(f.file, &buf.ctx);
297 if (error >= 0) 292 if (error >= 0)
298 error = buf.error; 293 error = buf.error;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 237af62976a6..7c30e3a62baf 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1507,7 +1507,7 @@ int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
1507 */ 1507 */
1508typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); 1508typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
1509struct dir_context { 1509struct dir_context {
1510 filldir_t actor; 1510 const filldir_t actor;
1511 loff_t pos; 1511 loff_t pos;
1512}; 1512};
1513 1513