aboutsummaryrefslogtreecommitdiffstats
path: root/fs/minix
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-15 18:51:49 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:46:47 -0400
commit80886298c07234331458e963b5f9f57c68edd700 (patch)
tree89b2df2d0ad43dc2e6a0091b4b04c1105433cf4d /fs/minix
parentbb6f619b3a49f940d7478112500da312d70866eb (diff)
[readdir] simple local unixlike: switch to ->iterate()
ext2, ufs, minix, sysv Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/minix')
-rw-r--r--fs/minix/dir.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index a9ed6f36e6ea..08c442902fcd 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -16,12 +16,12 @@
16typedef struct minix_dir_entry minix_dirent; 16typedef struct minix_dir_entry minix_dirent;
17typedef struct minix3_dir_entry minix3_dirent; 17typedef struct minix3_dir_entry minix3_dirent;
18 18
19static int minix_readdir(struct file *, void *, filldir_t); 19static int minix_readdir(struct file *, struct dir_context *);
20 20
21const struct file_operations minix_dir_operations = { 21const struct file_operations minix_dir_operations = {
22 .llseek = generic_file_llseek, 22 .llseek = generic_file_llseek,
23 .read = generic_read_dir, 23 .read = generic_read_dir,
24 .readdir = minix_readdir, 24 .iterate = minix_readdir,
25 .fsync = generic_file_fsync, 25 .fsync = generic_file_fsync,
26}; 26};
27 27
@@ -82,22 +82,23 @@ static inline void *minix_next_entry(void *de, struct minix_sb_info *sbi)
82 return (void*)((char*)de + sbi->s_dirsize); 82 return (void*)((char*)de + sbi->s_dirsize);
83} 83}
84 84
85static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir) 85static int minix_readdir(struct file *file, struct dir_context *ctx)
86{ 86{
87 unsigned long pos = filp->f_pos; 87 struct inode *inode = file_inode(file);
88 struct inode *inode = file_inode(filp);
89 struct super_block *sb = inode->i_sb; 88 struct super_block *sb = inode->i_sb;
90 unsigned offset = pos & ~PAGE_CACHE_MASK;
91 unsigned long n = pos >> PAGE_CACHE_SHIFT;
92 unsigned long npages = dir_pages(inode);
93 struct minix_sb_info *sbi = minix_sb(sb); 89 struct minix_sb_info *sbi = minix_sb(sb);
94 unsigned chunk_size = sbi->s_dirsize; 90 unsigned chunk_size = sbi->s_dirsize;
95 char *name; 91 unsigned long npages = dir_pages(inode);
96 __u32 inumber; 92 unsigned long pos = ctx->pos;
93 unsigned offset;
94 unsigned long n;
97 95
98 pos = (pos + chunk_size-1) & ~(chunk_size-1); 96 ctx->pos = pos = (pos + chunk_size-1) & ~(chunk_size-1);
99 if (pos >= inode->i_size) 97 if (pos >= inode->i_size)
100 goto done; 98 return 0;
99
100 offset = pos & ~PAGE_CACHE_MASK;
101 n = pos >> PAGE_CACHE_SHIFT;
101 102
102 for ( ; n < npages; n++, offset = 0) { 103 for ( ; n < npages; n++, offset = 0) {
103 char *p, *kaddr, *limit; 104 char *p, *kaddr, *limit;
@@ -109,6 +110,8 @@ static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir)
109 p = kaddr+offset; 110 p = kaddr+offset;
110 limit = kaddr + minix_last_byte(inode, n) - chunk_size; 111 limit = kaddr + minix_last_byte(inode, n) - chunk_size;
111 for ( ; p <= limit; p = minix_next_entry(p, sbi)) { 112 for ( ; p <= limit; p = minix_next_entry(p, sbi)) {
113 const char *name;
114 __u32 inumber;
112 if (sbi->s_version == MINIX_V3) { 115 if (sbi->s_version == MINIX_V3) {
113 minix3_dirent *de3 = (minix3_dirent *)p; 116 minix3_dirent *de3 = (minix3_dirent *)p;
114 name = de3->name; 117 name = de3->name;
@@ -119,24 +122,17 @@ static int minix_readdir(struct file * filp, void * dirent, filldir_t filldir)
119 inumber = de->inode; 122 inumber = de->inode;
120 } 123 }
121 if (inumber) { 124 if (inumber) {
122 int over;
123
124 unsigned l = strnlen(name, sbi->s_namelen); 125 unsigned l = strnlen(name, sbi->s_namelen);
125 offset = p - kaddr; 126 if (!dir_emit(ctx, name, l,
126 over = filldir(dirent, name, l, 127 inumber, DT_UNKNOWN)) {
127 (n << PAGE_CACHE_SHIFT) | offset,
128 inumber, DT_UNKNOWN);
129 if (over) {
130 dir_put_page(page); 128 dir_put_page(page);
131 goto done; 129 return 0;
132 } 130 }
133 } 131 }
132 ctx->pos += chunk_size;
134 } 133 }
135 dir_put_page(page); 134 dir_put_page(page);
136 } 135 }
137
138done:
139 filp->f_pos = (n << PAGE_CACHE_SHIFT) | offset;
140 return 0; 136 return 0;
141} 137}
142 138