Lines 38-83
typedef u64 inode_num_t;
Link Here
|
38 |
typedef ino_t inode_num_t; |
38 |
typedef ino_t inode_num_t; |
39 |
#endif |
39 |
#endif |
40 |
|
40 |
|
41 |
/* Specifically for our filldir_t callback */ |
|
|
42 |
typedef struct FilldirInfo { |
43 |
filldir_t filldir; |
44 |
void *dirent; |
45 |
} FilldirInfo; |
46 |
|
47 |
|
48 |
/* |
49 |
*---------------------------------------------------------------------------- |
50 |
* |
51 |
* Filldir -- |
52 |
* |
53 |
* Callback function for readdir that we use in place of the one provided. |
54 |
* This allows us to specify that each dentry is a symlink, but pass through |
55 |
* everything else to the original filldir function. |
56 |
* |
57 |
* Results: |
58 |
* Original filldir's return value. |
59 |
* |
60 |
* Side effects: |
61 |
* Directory information gets copied to user's buffer. |
62 |
* |
63 |
*---------------------------------------------------------------------------- |
64 |
*/ |
65 |
|
66 |
static int |
67 |
Filldir(void *buf, // IN: Dirent buffer passed from FileOpReaddir |
68 |
const char *name, // IN: Dirent name |
69 |
int namelen, // IN: len of dirent's name |
70 |
loff_t offset, // IN: Offset |
71 |
inode_num_t ino, // IN: Inode number of dirent |
72 |
unsigned int d_type) // IN: Type of file |
73 |
{ |
74 |
FilldirInfo *info = buf; |
75 |
|
76 |
/* Specify DT_LNK regardless */ |
77 |
return info->filldir(info->dirent, name, namelen, offset, ino, DT_LNK); |
78 |
} |
79 |
|
80 |
|
81 |
/* File operations */ |
41 |
/* File operations */ |
82 |
|
42 |
|
83 |
/* |
43 |
/* |
Lines 166-176
FileOpOpen(struct inode *inode, // IN
Link Here
|
166 |
|
126 |
|
167 |
static int |
127 |
static int |
168 |
FileOpReaddir(struct file *file, // IN |
128 |
FileOpReaddir(struct file *file, // IN |
169 |
void *dirent, // IN |
129 |
struct dir_context *ctx) // IN |
170 |
filldir_t filldir) // IN |
|
|
171 |
{ |
130 |
{ |
172 |
int ret; |
131 |
int ret; |
173 |
FilldirInfo info; |
132 |
|
174 |
struct file *actualFile; |
133 |
struct file *actualFile; |
175 |
|
134 |
|
176 |
if (!file) { |
135 |
if (!file) { |
Lines 184-195
FileOpReaddir(struct file *file, // IN
Link Here
|
184 |
return -EINVAL; |
143 |
return -EINVAL; |
185 |
} |
144 |
} |
186 |
|
145 |
|
187 |
info.filldir = filldir; |
146 |
/* Ricky Wong Yung Fei: |
188 |
info.dirent = dirent; |
147 |
* Manipulation of pos is now handled internally by iterate_dir(). |
189 |
|
148 |
*/ |
190 |
actualFile->f_pos = file->f_pos; |
149 |
ret = iterate_dir(actualFile, ctx); |
191 |
ret = vfs_readdir(actualFile, Filldir, &info); |
|
|
192 |
file->f_pos = actualFile->f_pos; |
193 |
|
150 |
|
194 |
return ret; |
151 |
return ret; |
195 |
} |
152 |
} |
Lines 237-243
FileOpRelease(struct inode *inode, // IN
Link Here
|
237 |
|
194 |
|
238 |
|
195 |
|
239 |
struct file_operations RootFileOps = { |
196 |
struct file_operations RootFileOps = { |
240 |
.readdir = FileOpReaddir, |
197 |
.iterate = FileOpReaddir, |
241 |
.open = FileOpOpen, |
198 |
.open = FileOpOpen, |
242 |
.release = FileOpRelease, |
199 |
.release = FileOpRelease, |
243 |
}; |
200 |
}; |