-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdir.c
68 lines (53 loc) · 1.45 KB
/
dir.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Chunkfs directory routines
*
* (C) 2007-2008 Valerie Henson <[email protected]>
*/
#include <linux/module.h>
#include "chunkfs.h"
#include "chunkfs_i.h"
/*
* Currently we're reusing the client directory ops. We'll probably
* have to implement our own directories on top.
*/
static loff_t
chunkfs_dir_llseek(struct file *file, loff_t offset, int origin)
{
struct file *client_file;
struct chunkfs_continuation *cont;
int err;
/* XXX... should only do top-level file struct? */
chunkfs_debug("enter\n");
err = chunkfs_open_cont_file(file, &offset, &client_file, &cont);
if (err)
return err;
if (client_file->f_op->llseek)
err = client_file->f_op->llseek(client_file, offset, origin);
else
err = default_llseek(client_file, offset, origin);
chunkfs_close_cont_file(file, client_file, cont);
return err;
}
static int
chunkfs_iterate(struct file *file, struct dir_context *ctx)
{
struct file *client_file;
struct chunkfs_continuation *cont;
int err;
chunkfs_debug("enter\n");
err = chunkfs_open_cont_file(file, &file->f_pos, &client_file, &cont);
if (err)
return err;
err = client_file->f_op->iterate(client_file, ctx);
/* If we read off the end, no problemo */
if (err == -ENODATA)
err = 0;
chunkfs_close_cont_file(file, client_file, cont);
return err;
}
struct file_operations chunkfs_dir_fops = {
.llseek = chunkfs_dir_llseek,
.read = generic_read_dir,
.open = chunkfs_open,
.iterate = chunkfs_iterate,
};