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