aboutsummaryrefslogtreecommitdiffstats
path: root/fs/openpromfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-05-16 01:52:12 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-06-29 04:56:32 -0400
commit68c61471138402e34489edc5efde4f0fc5beaa25 (patch)
treedc79e4f8194663bd40c6c414b4f54124dd8d8cdb /fs/openpromfs
parent7aa123a0dc3a856ef5e6f015571f11cd70b77213 (diff)
[readdir] convert openpromfs
what the hell is op_mutex for, BTW? Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/openpromfs')
-rw-r--r--fs/openpromfs/inode.c95
1 files changed, 44 insertions, 51 deletions
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 75885ffde44e..8c0ceb8dd1f7 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -162,11 +162,11 @@ static const struct file_operations openpromfs_prop_ops = {
162 .release = seq_release, 162 .release = seq_release,
163}; 163};
164 164
165static int openpromfs_readdir(struct file *, void *, filldir_t); 165static int openpromfs_readdir(struct file *, struct dir_context *);
166 166
167static const struct file_operations openprom_operations = { 167static const struct file_operations openprom_operations = {
168 .read = generic_read_dir, 168 .read = generic_read_dir,
169 .readdir = openpromfs_readdir, 169 .iterate = openpromfs_readdir,
170 .llseek = generic_file_llseek, 170 .llseek = generic_file_llseek,
171}; 171};
172 172
@@ -260,71 +260,64 @@ found:
260 return NULL; 260 return NULL;
261} 261}
262 262
263static int openpromfs_readdir(struct file * filp, void * dirent, filldir_t filldir) 263static int openpromfs_readdir(struct file *file, struct dir_context *ctx)
264{ 264{
265 struct inode *inode = file_inode(filp); 265 struct inode *inode = file_inode(file);
266 struct op_inode_info *oi = OP_I(inode); 266 struct op_inode_info *oi = OP_I(inode);
267 struct device_node *dp = oi->u.node; 267 struct device_node *dp = oi->u.node;
268 struct device_node *child; 268 struct device_node *child;
269 struct property *prop; 269 struct property *prop;
270 unsigned int ino;
271 int i; 270 int i;
272 271
273 mutex_lock(&op_mutex); 272 mutex_lock(&op_mutex);
274 273
275 ino = inode->i_ino; 274 if (ctx->pos == 0) {
276 i = filp->f_pos; 275 if (!dir_emit(ctx, ".", 1, inode->i_ino, DT_DIR))
277 switch (i) {
278 case 0:
279 if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0)
280 goto out; 276 goto out;
281 i++; 277 ctx->pos = 1;
282 filp->f_pos++; 278 }
283 /* fall thru */ 279 if (ctx->pos == 1) {
284 case 1: 280 if (!dir_emit(ctx, "..", 2,
285 if (filldir(dirent, "..", 2, i,
286 (dp->parent == NULL ? 281 (dp->parent == NULL ?
287 OPENPROM_ROOT_INO : 282 OPENPROM_ROOT_INO :
288 dp->parent->unique_id), DT_DIR) < 0) 283 dp->parent->unique_id), DT_DIR))
289 goto out; 284 goto out;
290 i++; 285 ctx->pos = 2;
291 filp->f_pos++; 286 }
292 /* fall thru */ 287 i = ctx->pos - 2;
293 default:
294 i -= 2;
295
296 /* First, the children nodes as directories. */
297 child = dp->child;
298 while (i && child) {
299 child = child->sibling;
300 i--;
301 }
302 while (child) {
303 if (filldir(dirent,
304 child->path_component_name,
305 strlen(child->path_component_name),
306 filp->f_pos, child->unique_id, DT_DIR) < 0)
307 goto out;
308
309 filp->f_pos++;
310 child = child->sibling;
311 }
312 288
313 /* Next, the properties as files. */ 289 /* First, the children nodes as directories. */
314 prop = dp->properties; 290 child = dp->child;
315 while (i && prop) { 291 while (i && child) {
316 prop = prop->next; 292 child = child->sibling;
317 i--; 293 i--;
318 } 294 }
319 while (prop) { 295 while (child) {
320 if (filldir(dirent, prop->name, strlen(prop->name), 296 if (!dir_emit(ctx,
321 filp->f_pos, prop->unique_id, DT_REG) < 0) 297 child->path_component_name,
322 goto out; 298 strlen(child->path_component_name),
299 child->unique_id, DT_DIR))
300 goto out;
323 301
324 filp->f_pos++; 302 ctx->pos++;
325 prop = prop->next; 303 child = child->sibling;
326 } 304 }
305
306 /* Next, the properties as files. */
307 prop = dp->properties;
308 while (i && prop) {
309 prop = prop->next;
310 i--;
327 } 311 }
312 while (prop) {
313 if (!dir_emit(ctx, prop->name, strlen(prop->name),
314 prop->unique_id, DT_REG))
315 goto out;
316
317 ctx->pos++;
318 prop = prop->next;
319 }
320
328out: 321out:
329 mutex_unlock(&op_mutex); 322 mutex_unlock(&op_mutex);
330 return 0; 323 return 0;