diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-15 18:49:12 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-29 04:46:47 -0400 |
commit | bb6f619b3a49f940d7478112500da312d70866eb (patch) | |
tree | 4e17d6ed5b965eaec2e55b11b61145b200d28f0f /fs/coda | |
parent | 5c0ba4e0762e6dabd14a5c276652e2defec38de7 (diff) |
[readdir] introduce ->iterate(), ctx->pos, dir_emit()
New method - ->iterate(file, ctx). That's the replacement for ->readdir();
it takes callback from ctx->actor, uses ctx->pos instead of file->f_pos and
calls dir_emit(ctx, ...) instead of filldir(data, ...). It does *not*
update file->f_pos (or look at it, for that matter); iterate_dir() does the
update.
Note that dir_emit() takes the offset from ctx->pos (and eventually
filldir_t will lose that argument).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/coda')
-rw-r--r-- | fs/coda/dir.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index b7d3a05c062c..fc66861b3598 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -391,8 +391,7 @@ static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir) | |||
391 | if (!host_file->f_op) | 391 | if (!host_file->f_op) |
392 | return -ENOTDIR; | 392 | return -ENOTDIR; |
393 | 393 | ||
394 | if (host_file->f_op->readdir) | 394 | if (host_file->f_op->readdir) { |
395 | { | ||
396 | /* potemkin case: we were handed a directory inode. | 395 | /* potemkin case: we were handed a directory inode. |
397 | * We can't use vfs_readdir because we have to keep the file | 396 | * We can't use vfs_readdir because we have to keep the file |
398 | * position in sync between the coda_file and the host_file. | 397 | * position in sync between the coda_file and the host_file. |
@@ -410,8 +409,20 @@ static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir) | |||
410 | 409 | ||
411 | coda_file->f_pos = host_file->f_pos; | 410 | coda_file->f_pos = host_file->f_pos; |
412 | mutex_unlock(&host_inode->i_mutex); | 411 | mutex_unlock(&host_inode->i_mutex); |
413 | } | 412 | } else if (host_file->f_op->iterate) { |
414 | else /* Venus: we must read Venus dirents from a file */ | 413 | struct inode *host_inode = file_inode(host_file); |
414 | struct dir_context *ctx = buf; | ||
415 | |||
416 | mutex_lock(&host_inode->i_mutex); | ||
417 | ret = -ENOENT; | ||
418 | if (!IS_DEADDIR(host_inode)) { | ||
419 | ret = host_file->f_op->iterate(host_file, ctx); | ||
420 | file_accessed(host_file); | ||
421 | } | ||
422 | mutex_unlock(&host_inode->i_mutex); | ||
423 | |||
424 | coda_file->f_pos = ctx->pos; | ||
425 | } else /* Venus: we must read Venus dirents from a file */ | ||
415 | ret = coda_venus_readdir(coda_file, buf, filldir); | 426 | ret = coda_venus_readdir(coda_file, buf, filldir); |
416 | 427 | ||
417 | return ret; | 428 | return ret; |