aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-18 02:58:57 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:56:51 -0400
commit568f8f5ec5f1ac70850e27bc31eacaecaf9fb548 (patch)
treeff41ecfe261dd4c398cf2a049297efc1a9a6a430 /fs/hpfs
parentcd62cdae0bd7fb76cae66347dc4fc00e87ffc1c4 (diff)
[readdir] convert hpfs
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hpfs')
-rw-r--r--fs/hpfs/dir.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 834ac13c04b7..292b1acb9b81 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -57,14 +57,14 @@ fail:
57 return -ESPIPE; 57 return -ESPIPE;
58} 58}
59 59
60static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 60static int hpfs_readdir(struct file *file, struct dir_context *ctx)
61{ 61{
62 struct inode *inode = file_inode(filp); 62 struct inode *inode = file_inode(file);
63 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); 63 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
64 struct quad_buffer_head qbh; 64 struct quad_buffer_head qbh;
65 struct hpfs_dirent *de; 65 struct hpfs_dirent *de;
66 int lc; 66 int lc;
67 long old_pos; 67 loff_t next_pos;
68 unsigned char *tempname; 68 unsigned char *tempname;
69 int c1, c2 = 0; 69 int c1, c2 = 0;
70 int ret = 0; 70 int ret = 0;
@@ -105,11 +105,11 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
105 } 105 }
106 } 106 }
107 lc = hpfs_sb(inode->i_sb)->sb_lowercase; 107 lc = hpfs_sb(inode->i_sb)->sb_lowercase;
108 if (filp->f_pos == 12) { /* diff -r requires this (note, that diff -r */ 108 if (ctx->pos == 12) { /* diff -r requires this (note, that diff -r */
109 filp->f_pos = 13; /* also fails on msdos filesystem in 2.0) */ 109 ctx->pos = 13; /* also fails on msdos filesystem in 2.0) */
110 goto out; 110 goto out;
111 } 111 }
112 if (filp->f_pos == 13) { 112 if (ctx->pos == 13) {
113 ret = -ENOENT; 113 ret = -ENOENT;
114 goto out; 114 goto out;
115 } 115 }
@@ -120,33 +120,34 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
120 accepted by filldir, but what can I do? 120 accepted by filldir, but what can I do?
121 maybe killall -9 ls helps */ 121 maybe killall -9 ls helps */
122 if (hpfs_sb(inode->i_sb)->sb_chk) 122 if (hpfs_sb(inode->i_sb)->sb_chk)
123 if (hpfs_stop_cycles(inode->i_sb, filp->f_pos, &c1, &c2, "hpfs_readdir")) { 123 if (hpfs_stop_cycles(inode->i_sb, ctx->pos, &c1, &c2, "hpfs_readdir")) {
124 ret = -EFSERROR; 124 ret = -EFSERROR;
125 goto out; 125 goto out;
126 } 126 }
127 if (filp->f_pos == 12) 127 if (ctx->pos == 12)
128 goto out; 128 goto out;
129 if (filp->f_pos == 3 || filp->f_pos == 4 || filp->f_pos == 5) { 129 if (ctx->pos == 3 || ctx->pos == 4 || ctx->pos == 5) {
130 printk("HPFS: warning: pos==%d\n",(int)filp->f_pos); 130 printk("HPFS: warning: pos==%d\n",(int)ctx->pos);
131 goto out; 131 goto out;
132 } 132 }
133 if (filp->f_pos == 0) { 133 if (ctx->pos == 0) {
134 if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0) 134 if (!dir_emit_dot(file, ctx))
135 goto out; 135 goto out;
136 filp->f_pos = 11; 136 ctx->pos = 11;
137 } 137 }
138 if (filp->f_pos == 11) { 138 if (ctx->pos == 11) {
139 if (filldir(dirent, "..", 2, filp->f_pos, hpfs_inode->i_parent_dir, DT_DIR) < 0) 139 if (!dir_emit(ctx, "..", 2, hpfs_inode->i_parent_dir, DT_DIR))
140 goto out; 140 goto out;
141 filp->f_pos = 1; 141 ctx->pos = 1;
142 } 142 }
143 if (filp->f_pos == 1) { 143 if (ctx->pos == 1) {
144 filp->f_pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1; 144 ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1;
145 hpfs_add_pos(inode, &filp->f_pos); 145 hpfs_add_pos(inode, &file->f_pos);
146 filp->f_version = inode->i_version; 146 file->f_version = inode->i_version;
147 } 147 }
148 old_pos = filp->f_pos; 148 next_pos = ctx->pos;
149 if (!(de = map_pos_dirent(inode, &filp->f_pos, &qbh))) { 149 if (!(de = map_pos_dirent(inode, &next_pos, &qbh))) {
150 ctx->pos = next_pos;
150 ret = -EIOERROR; 151 ret = -EIOERROR;
151 goto out; 152 goto out;
152 } 153 }
@@ -154,20 +155,21 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
154 if (hpfs_sb(inode->i_sb)->sb_chk) { 155 if (hpfs_sb(inode->i_sb)->sb_chk) {
155 if (de->first && !de->last && (de->namelen != 2 156 if (de->first && !de->last && (de->namelen != 2
156 || de ->name[0] != 1 || de->name[1] != 1)) 157 || de ->name[0] != 1 || de->name[1] != 1))
157 hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", old_pos); 158 hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", (unsigned long)ctx->pos);
158 if (de->last && (de->namelen != 1 || de ->name[0] != 255)) 159 if (de->last && (de->namelen != 1 || de ->name[0] != 255))
159 hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", old_pos); 160 hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", (unsigned long)ctx->pos);
160 } 161 }
161 hpfs_brelse4(&qbh); 162 hpfs_brelse4(&qbh);
163 ctx->pos = next_pos;
162 goto again; 164 goto again;
163 } 165 }
164 tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); 166 tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3);
165 if (filldir(dirent, tempname, de->namelen, old_pos, le32_to_cpu(de->fnode), DT_UNKNOWN) < 0) { 167 if (!dir_emit(ctx, tempname, de->namelen, le32_to_cpu(de->fnode), DT_UNKNOWN)) {
166 filp->f_pos = old_pos;
167 if (tempname != de->name) kfree(tempname); 168 if (tempname != de->name) kfree(tempname);
168 hpfs_brelse4(&qbh); 169 hpfs_brelse4(&qbh);
169 goto out; 170 goto out;
170 } 171 }
172 ctx->pos = next_pos;
171 if (tempname != de->name) kfree(tempname); 173 if (tempname != de->name) kfree(tempname);
172 hpfs_brelse4(&qbh); 174 hpfs_brelse4(&qbh);
173 } 175 }
@@ -322,7 +324,7 @@ const struct file_operations hpfs_dir_ops =
322{ 324{
323 .llseek = hpfs_dir_lseek, 325 .llseek = hpfs_dir_lseek,
324 .read = generic_read_dir, 326 .read = generic_read_dir,
325 .readdir = hpfs_readdir, 327 .iterate = hpfs_readdir,
326 .release = hpfs_dir_release, 328 .release = hpfs_dir_release,
327 .fsync = hpfs_file_fsync, 329 .fsync = hpfs_file_fsync,
328}; 330};