Commit ac7576f4b1da8c9c6bc1ae026c2b9e86ae617ba5

Authored by Miklos Szeredi
Committed by Al Viro
1 parent 9f2f7d4c8d

vfs: make first argument of dir_context.actor typed

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 19 changed files with 100 additions and 67 deletions Side-by-side Diff

arch/alpha/kernel/osf_sys.c
... ... @@ -104,11 +104,12 @@
104 104 };
105 105  
106 106 static int
107   -osf_filldir(void *__buf, const char *name, int namlen, loff_t offset,
108   - u64 ino, unsigned int d_type)
  107 +osf_filldir(struct dir_context *ctx, const char *name, int namlen,
  108 + loff_t offset, u64 ino, unsigned int d_type)
109 109 {
110 110 struct osf_dirent __user *dirent;
111   - struct osf_dirent_callback *buf = (struct osf_dirent_callback *) __buf;
  111 + struct osf_dirent_callback *buf =
  112 + container_of(ctx, struct osf_dirent_callback, ctx);
112 113 unsigned int reclen = ALIGN(NAME_OFFSET + namlen + 1, sizeof(u32));
113 114 unsigned int d_ino;
114 115  
arch/parisc/hpux/fs.c
... ... @@ -56,11 +56,12 @@
56 56  
57 57 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
58 58  
59   -static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60   - u64 ino, unsigned d_type)
  59 +static int filldir(struct dir_context *ctx, const char *name, int namlen,
  60 + loff_t offset, u64 ino, unsigned d_type)
61 61 {
62 62 struct hpux_dirent __user * dirent;
63   - struct getdents_callback * buf = (struct getdents_callback *) __buf;
  63 + struct getdents_callback *buf =
  64 + container_of(ctx, struct getdents_callback, ctx);
64 65 ino_t d_ino;
65 66 int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, sizeof(long));
66 67  
drivers/staging/lustre/lustre/llite/llite_nfs.c
... ... @@ -207,13 +207,15 @@
207 207 return LUSTRE_NFS_FID;
208 208 }
209 209  
210   -static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen,
211   - loff_t hash, u64 ino, unsigned type)
  210 +static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name,
  211 + int namelen, loff_t hash, u64 ino,
  212 + unsigned type)
212 213 {
213 214 /* It is hack to access lde_fid for comparison with lgd_fid.
214 215 * So the input 'name' must be part of the 'lu_dirent'. */
215 216 struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
216   - struct ll_getname_data *lgd = cookie;
  217 + struct ll_getname_data *lgd =
  218 + container_of(ctx, struct ll_getname_data, ctx);
217 219 struct lu_fid fid;
218 220  
219 221 fid_le_to_cpu(&fid, &lde->lde_fid);
... ... @@ -26,7 +26,7 @@
26 26 static int afs_d_revalidate(struct dentry *dentry, unsigned int flags);
27 27 static int afs_d_delete(const struct dentry *dentry);
28 28 static void afs_d_release(struct dentry *dentry);
29   -static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
  29 +static int afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
30 30 loff_t fpos, u64 ino, unsigned dtype);
31 31 static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
32 32 bool excl);
33 33  
... ... @@ -391,10 +391,11 @@
391 391 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
392 392 * uniquifier through dtype
393 393 */
394   -static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
395   - loff_t fpos, u64 ino, unsigned dtype)
  394 +static int afs_lookup_filldir(struct dir_context *ctx, const char *name,
  395 + int nlen, loff_t fpos, u64 ino, unsigned dtype)
396 396 {
397   - struct afs_lookup_cookie *cookie = _cookie;
  397 + struct afs_lookup_cookie *cookie =
  398 + container_of(ctx, struct afs_lookup_cookie, ctx);
398 399  
399 400 _enter("{%s,%u},%s,%u,,%llu,%u",
400 401 cookie->name.name, cookie->name.len, name, nlen,
... ... @@ -847,10 +847,12 @@
847 847 int result;
848 848 };
849 849  
850   -static int compat_fillonedir(void *__buf, const char *name, int namlen,
851   - loff_t offset, u64 ino, unsigned int d_type)
  850 +static int compat_fillonedir(struct dir_context *ctx, const char *name,
  851 + int namlen, loff_t offset, u64 ino,
  852 + unsigned int d_type)
852 853 {
853   - struct compat_readdir_callback *buf = __buf;
  854 + struct compat_readdir_callback *buf =
  855 + container_of(ctx, struct compat_readdir_callback, ctx);
854 856 struct compat_old_linux_dirent __user *dirent;
855 857 compat_ulong_t d_ino;
856 858  
857 859  
... ... @@ -915,11 +917,12 @@
915 917 int error;
916 918 };
917 919  
918   -static int compat_filldir(void *__buf, const char *name, int namlen,
  920 +static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
919 921 loff_t offset, u64 ino, unsigned int d_type)
920 922 {
921 923 struct compat_linux_dirent __user * dirent;
922   - struct compat_getdents_callback *buf = __buf;
  924 + struct compat_getdents_callback *buf =
  925 + container_of(ctx, struct compat_getdents_callback, ctx);
923 926 compat_ulong_t d_ino;
924 927 int reclen = ALIGN(offsetof(struct compat_linux_dirent, d_name) +
925 928 namlen + 2, sizeof(compat_long_t));
926 929  
... ... @@ -1001,11 +1004,13 @@
1001 1004 int error;
1002 1005 };
1003 1006  
1004   -static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t offset,
1005   - u64 ino, unsigned int d_type)
  1007 +static int compat_filldir64(struct dir_context *ctx, const char *name,
  1008 + int namlen, loff_t offset, u64 ino,
  1009 + unsigned int d_type)
1006 1010 {
1007 1011 struct linux_dirent64 __user *dirent;
1008   - struct compat_getdents_callback64 *buf = __buf;
  1012 + struct compat_getdents_callback64 *buf =
  1013 + container_of(ctx, struct compat_getdents_callback64, ctx);
1009 1014 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
1010 1015 sizeof(u64));
1011 1016 u64 off;
... ... @@ -75,11 +75,11 @@
75 75  
76 76 /* Inspired by generic filldir in fs/readdir.c */
77 77 static int
78   -ecryptfs_filldir(void *dirent, const char *lower_name, int lower_namelen,
79   - loff_t offset, u64 ino, unsigned int d_type)
  78 +ecryptfs_filldir(struct dir_context *ctx, const char *lower_name,
  79 + int lower_namelen, loff_t offset, u64 ino, unsigned int d_type)
80 80 {
81 81 struct ecryptfs_getdents_callback *buf =
82   - (struct ecryptfs_getdents_callback *)dirent;
  82 + container_of(ctx, struct ecryptfs_getdents_callback, ctx);
83 83 size_t name_size;
84 84 char *name;
85 85 int rc;
... ... @@ -241,10 +241,11 @@
241 241 * A rather strange filldir function to capture
242 242 * the name matching the specified inode number.
243 243 */
244   -static int filldir_one(void * __buf, const char * name, int len,
  244 +static int filldir_one(struct dir_context *ctx, const char *name, int len,
245 245 loff_t pos, u64 ino, unsigned int d_type)
246 246 {
247   - struct getdents_callback *buf = __buf;
  247 + struct getdents_callback *buf =
  248 + container_of(ctx, struct getdents_callback, ctx);
248 249 int result = 0;
249 250  
250 251 buf->sequence++;
... ... @@ -702,10 +702,11 @@
702 702 }
703 703  
704 704 #define FAT_IOCTL_FILLDIR_FUNC(func, dirent_type) \
705   -static int func(void *__buf, const char *name, int name_len, \
  705 +static int func(struct dir_context *ctx, const char *name, int name_len, \
706 706 loff_t offset, u64 ino, unsigned int d_type) \
707 707 { \
708   - struct fat_ioctl_filldir_callback *buf = __buf; \
  708 + struct fat_ioctl_filldir_callback *buf = \
  709 + container_of(ctx, struct fat_ioctl_filldir_callback, ctx); \
709 710 struct dirent_type __user *d1 = buf->dirent; \
710 711 struct dirent_type __user *d2 = d1 + 1; \
711 712 \
... ... @@ -69,10 +69,12 @@
69 69 char *name;
70 70 };
71 71  
72   -static int get_name_filldir(void *opaque, const char *name, int length,
73   - loff_t offset, u64 inum, unsigned int type)
  72 +static int get_name_filldir(struct dir_context *ctx, const char *name,
  73 + int length, loff_t offset, u64 inum,
  74 + unsigned int type)
74 75 {
75   - struct get_name_filldir *gnfd = opaque;
  76 + struct get_name_filldir *gnfd =
  77 + container_of(ctx, struct get_name_filldir, ctx);
76 78  
77 79 if (inum != gnfd->inum.no_addr)
78 80 return 0;
... ... @@ -548,10 +548,11 @@
548 548 struct dentry *dentry;
549 549 };
550 550  
551   -static int hppfs_filldir(void *d, const char *name, int size,
  551 +static int hppfs_filldir(struct dir_context *ctx, const char *name, int size,
552 552 loff_t offset, u64 inode, unsigned int type)
553 553 {
554   - struct hppfs_dirent *dirent = d;
  554 + struct hppfs_dirent *dirent =
  555 + container_of(ctx, struct hppfs_dirent, ctx);
555 556  
556 557 if (file_removed(dirent->dentry, name))
557 558 return 0;
fs/nfsd/nfs4recover.c
... ... @@ -245,10 +245,11 @@
245 245 };
246 246  
247 247 static int
248   -nfsd4_build_namelist(void *arg, const char *name, int namlen,
  248 +nfsd4_build_namelist(struct dir_context *__ctx, const char *name, int namlen,
249 249 loff_t offset, u64 ino, unsigned int d_type)
250 250 {
251   - struct nfs4_dir_ctx *ctx = arg;
  251 + struct nfs4_dir_ctx *ctx =
  252 + container_of(__ctx, struct nfs4_dir_ctx, ctx);
252 253 struct name_list *entry;
253 254  
254 255 if (namlen != HEXDIR_LEN - 1)
... ... @@ -1819,10 +1819,12 @@
1819 1819 int full;
1820 1820 };
1821 1821  
1822   -static int nfsd_buffered_filldir(void *__buf, const char *name, int namlen,
1823   - loff_t offset, u64 ino, unsigned int d_type)
  1822 +static int nfsd_buffered_filldir(struct dir_context *ctx, const char *name,
  1823 + int namlen, loff_t offset, u64 ino,
  1824 + unsigned int d_type)
1824 1825 {
1825   - struct readdir_data *buf = __buf;
  1826 + struct readdir_data *buf =
  1827 + container_of(ctx, struct readdir_data, ctx);
1826 1828 struct buffered_dirent *de = (void *)(buf->dirent + buf->used);
1827 1829 unsigned int reclen;
1828 1830  
... ... @@ -1842,7 +1844,7 @@
1842 1844 return 0;
1843 1845 }
1844 1846  
1845   -static __be32 nfsd_buffered_readdir(struct file *file, filldir_t func,
  1847 +static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
1846 1848 struct readdir_cd *cdp, loff_t *offsetp)
1847 1849 {
1848 1850 struct buffered_dirent *de;
... ... @@ -1926,7 +1928,7 @@
1926 1928 */
1927 1929 __be32
1928 1930 nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
1929   - struct readdir_cd *cdp, filldir_t func)
  1931 + struct readdir_cd *cdp, nfsd_filldir_t func)
1930 1932 {
1931 1933 __be32 err;
1932 1934 struct file *file;
... ... @@ -36,7 +36,7 @@
36 36 /*
37 37 * Callback function for readdir
38 38 */
39   -typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
  39 +typedef int (*nfsd_filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
40 40  
41 41 /* nfsd/vfs.c */
42 42 int nfsd_racache_init(int);
... ... @@ -95,7 +95,7 @@
95 95 __be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
96 96 char *name, int len);
97 97 __be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
98   - loff_t *, struct readdir_cd *, filldir_t);
  98 + loff_t *, struct readdir_cd *, nfsd_filldir_t);
99 99 __be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
100 100 struct kstatfs *, int access);
101 101  
... ... @@ -2073,10 +2073,12 @@
2073 2073 unsigned seen_other;
2074 2074 unsigned dx_dir;
2075 2075 };
2076   -static int ocfs2_empty_dir_filldir(void *priv, const char *name, int name_len,
2077   - loff_t pos, u64 ino, unsigned type)
  2076 +static int ocfs2_empty_dir_filldir(struct dir_context *ctx, const char *name,
  2077 + int name_len, loff_t pos, u64 ino,
  2078 + unsigned type)
2078 2079 {
2079   - struct ocfs2_empty_dir_priv *p = priv;
  2080 + struct ocfs2_empty_dir_priv *p =
  2081 + container_of(ctx, struct ocfs2_empty_dir_priv, ctx);
2080 2082  
2081 2083 /*
2082 2084 * Check the positions of "." and ".." records to be sure
... ... @@ -1982,10 +1982,12 @@
1982 1982 struct ocfs2_super *osb;
1983 1983 };
1984 1984  
1985   -static int ocfs2_orphan_filldir(void *priv, const char *name, int name_len,
1986   - loff_t pos, u64 ino, unsigned type)
  1985 +static int ocfs2_orphan_filldir(struct dir_context *ctx, const char *name,
  1986 + int name_len, loff_t pos, u64 ino,
  1987 + unsigned type)
1987 1988 {
1988   - struct ocfs2_orphan_filldir_priv *p = priv;
  1989 + struct ocfs2_orphan_filldir_priv *p =
  1990 + container_of(ctx, struct ocfs2_orphan_filldir_priv, ctx);
1989 1991 struct inode *iter;
1990 1992  
1991 1993 if (name_len == 1 && !strncmp(".", name, 1))
fs/overlayfs/readdir.c
... ... @@ -180,10 +180,12 @@
180 180 }
181 181 }
182 182  
183   -static int ovl_fill_merge(void *buf, const char *name, int namelen,
184   - loff_t offset, u64 ino, unsigned int d_type)
  183 +static int ovl_fill_merge(struct dir_context *ctx, const char *name,
  184 + int namelen, loff_t offset, u64 ino,
  185 + unsigned int d_type)
185 186 {
186   - struct ovl_readdir_data *rdd = buf;
  187 + struct ovl_readdir_data *rdd =
  188 + container_of(ctx, struct ovl_readdir_data, ctx);
187 189  
188 190 rdd->count++;
189 191 if (!rdd->is_merge)
... ... @@ -74,10 +74,11 @@
74 74 int result;
75 75 };
76 76  
77   -static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset,
78   - u64 ino, unsigned int d_type)
  77 +static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
  78 + loff_t offset, u64 ino, unsigned int d_type)
79 79 {
80   - struct readdir_callback *buf = (struct readdir_callback *) __buf;
  80 + struct readdir_callback *buf =
  81 + container_of(ctx, struct readdir_callback, ctx);
81 82 struct old_linux_dirent __user * dirent;
82 83 unsigned long d_ino;
83 84  
84 85  
... ... @@ -148,11 +149,12 @@
148 149 int error;
149 150 };
150 151  
151   -static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
152   - u64 ino, unsigned int d_type)
  152 +static int filldir(struct dir_context *ctx, const char *name, int namlen,
  153 + loff_t offset, u64 ino, unsigned int d_type)
153 154 {
154 155 struct linux_dirent __user * dirent;
155   - struct getdents_callback * buf = (struct getdents_callback *) __buf;
  156 + struct getdents_callback *buf =
  157 + container_of(ctx, struct getdents_callback, ctx);
156 158 unsigned long d_ino;
157 159 int reclen = ALIGN(offsetof(struct linux_dirent, d_name) + namlen + 2,
158 160 sizeof(long));
159 161  
... ... @@ -232,11 +234,12 @@
232 234 int error;
233 235 };
234 236  
235   -static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
236   - u64 ino, unsigned int d_type)
  237 +static int filldir64(struct dir_context *ctx, const char *name, int namlen,
  238 + loff_t offset, u64 ino, unsigned int d_type)
237 239 {
238 240 struct linux_dirent64 __user *dirent;
239   - struct getdents_callback64 * buf = (struct getdents_callback64 *) __buf;
  241 + struct getdents_callback64 *buf =
  242 + container_of(ctx, struct getdents_callback64, ctx);
240 243 int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
241 244 sizeof(u64));
242 245  
... ... @@ -188,10 +188,11 @@
188 188 };
189 189  
190 190 static int
191   -fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
192   - u64 ino, unsigned int d_type)
  191 +fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
  192 + loff_t offset, u64 ino, unsigned int d_type)
193 193 {
194   - struct reiserfs_dentry_buf *dbuf = buf;
  194 + struct reiserfs_dentry_buf *dbuf =
  195 + container_of(ctx, struct reiserfs_dentry_buf, ctx);
195 196 struct dentry *dentry;
196 197  
197 198 WARN_ON_ONCE(!mutex_is_locked(&dbuf->xadir->d_inode->i_mutex));
198 199  
... ... @@ -824,10 +825,12 @@
824 825 struct dentry *dentry;
825 826 };
826 827  
827   -static int listxattr_filler(void *buf, const char *name, int namelen,
828   - loff_t offset, u64 ino, unsigned int d_type)
  828 +static int listxattr_filler(struct dir_context *ctx, const char *name,
  829 + int namelen, loff_t offset, u64 ino,
  830 + unsigned int d_type)
829 831 {
830   - struct listxattr_buf *b = (struct listxattr_buf *)buf;
  832 + struct listxattr_buf *b =
  833 + container_of(ctx, struct listxattr_buf, ctx);
831 834 size_t size;
832 835  
833 836 if (name[0] != '.' ||
... ... @@ -1467,7 +1467,10 @@
1467 1467 * This allows the kernel to read directories into kernel space or
1468 1468 * to have different dirent layouts depending on the binary type.
1469 1469 */
1470   -typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
  1470 +struct dir_context;
  1471 +typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64,
  1472 + unsigned);
  1473 +
1471 1474 struct dir_context {
1472 1475 const filldir_t actor;
1473 1476 loff_t pos;