1 | /* |
---|
2 | * vfs.h - Virtual File System definition. |
---|
3 | * |
---|
4 | * Author Mohamed Lamine Karaoui (2014,2015) |
---|
5 | * Alain Greiner (2016,2017) |
---|
6 | * |
---|
7 | * Copyright (c) UPMC Sorbonne Universites |
---|
8 | * |
---|
9 | * This file is part of ALMOS-MKH. |
---|
10 | * |
---|
11 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
12 | * under the terms of the GNU General Public License as published by |
---|
13 | * the Free Software Foundation; version 2.0 of the License. |
---|
14 | * |
---|
15 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | * General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU General Public License |
---|
21 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef _VFS_H_ |
---|
26 | #define _VFS_H_ |
---|
27 | |
---|
28 | #include <kernel_config.h> |
---|
29 | #include <hal_types.h> |
---|
30 | #include <hal_atomic.h> |
---|
31 | #include <remote_rwlock.h> |
---|
32 | #include <remote_spinlock.h> |
---|
33 | #include <spinlock.h> |
---|
34 | #include <list.h> |
---|
35 | #include <xlist.h> |
---|
36 | #include <slist.h> |
---|
37 | #include <bits.h> |
---|
38 | #include <xhtab.h> |
---|
39 | #include <errno.h> |
---|
40 | #include <metafs.h> |
---|
41 | |
---|
42 | #include <fatfs.h> |
---|
43 | #include <ramfs.h> |
---|
44 | #include <devfs.h> |
---|
45 | |
---|
46 | /**** Forward declarations ***/ |
---|
47 | |
---|
48 | struct vfs_inode_s; |
---|
49 | struct vfs_dentry_t; |
---|
50 | struct vfs_ctx_t; |
---|
51 | struct vfs_file_ref_s; |
---|
52 | struct vfs_file_s; |
---|
53 | |
---|
54 | struct vfs_inode_op_s; |
---|
55 | struct vfs_dentry_op_s; |
---|
56 | struct vfs_file_op_s; |
---|
57 | struct vfs_ctx_op_s; |
---|
58 | |
---|
59 | struct vfs_lookup_cmd_s; |
---|
60 | struct vfs_lookup_rsp_s; |
---|
61 | |
---|
62 | struct mapper_s; |
---|
63 | struct process_s; |
---|
64 | struct device_s; |
---|
65 | struct vseg_s; |
---|
66 | struct page_s; |
---|
67 | |
---|
68 | |
---|
69 | /****************************************************************************************** |
---|
70 | * These flags are used to define the working mode of the vfs_lookup() function. |
---|
71 | *****************************************************************************************/ |
---|
72 | |
---|
73 | #define VFS_LOOKUP_DIR 0x01 /* the searched inode is a directory */ |
---|
74 | #define VFS_LOOKUP_OPEN 0x02 /* the search is for an open/opendir */ |
---|
75 | #define VFS_LOOKUP_PARENT 0x04 /* return the parent inode (not the inode itself) */ |
---|
76 | #define VFS_LOOKUP_CREATE 0x10 /* file must be created if missing */ |
---|
77 | #define VFS_LOOKUP_EXCL 0x20 /* file cannot previously exist */ |
---|
78 | |
---|
79 | /****************************************************************************************** |
---|
80 | * This define the masks for the POSIX access rights to inodes |
---|
81 | *****************************************************************************************/ |
---|
82 | |
---|
83 | #define VFS_ISUID 0x0004000 |
---|
84 | #define VFS_ISGID 0x0002000 |
---|
85 | #define VFS_ISVTX 0x0001000 |
---|
86 | |
---|
87 | #define VFS_IRWXU 0x0000700 |
---|
88 | #define VFS_IRUSR 0x0000400 |
---|
89 | #define VFS_IWUSR 0x0000200 |
---|
90 | #define VFS_IXUSR 0x0000100 |
---|
91 | |
---|
92 | #define VFS_IRWXG 0x0000070 |
---|
93 | #define VFS_IRGRP 0x0000040 |
---|
94 | #define VFS_IWGRP 0x0000020 |
---|
95 | #define VFS_IXGRP 0x0000010 |
---|
96 | |
---|
97 | #define VFS_IRWXO 0x0000007 |
---|
98 | #define VFS_IROTH 0x0000004 |
---|
99 | #define VFS_IWOTH 0x0000002 |
---|
100 | #define VFS_IXOTH 0x0000001 |
---|
101 | |
---|
102 | #define VFS_IREAD VFS_IRUSR |
---|
103 | #define VFS_IWRITE VFS_IWUSR |
---|
104 | #define VFS_IEXEC VFS_IXUSR |
---|
105 | |
---|
106 | |
---|
107 | /****************************************************************************************** |
---|
108 | * This structure defines informations common to all inodes and dentries |
---|
109 | * of a given file system. As it is declared a global variable in the kdata segment, |
---|
110 | * it is replicated in all clusters and handled as private by each OS intance. |
---|
111 | *****************************************************************************************/ |
---|
112 | |
---|
113 | typedef enum |
---|
114 | { |
---|
115 | FS_TYPE_DEVFS = 0, |
---|
116 | FS_TYPE_FATFS = 1, |
---|
117 | FS_TYPE_RAMFS = 2, |
---|
118 | |
---|
119 | FS_TYPES_NR = 3, |
---|
120 | } |
---|
121 | vfs_fs_type_t; |
---|
122 | |
---|
123 | typedef enum |
---|
124 | { |
---|
125 | CTX_ATTR_READ_ONLY = 0x01, /*! write access prohibited */ |
---|
126 | CTX_ATTR_SYNC = 0x10, /*! synchronise FS on each write */ |
---|
127 | } |
---|
128 | vfs_ctx_attr_t; |
---|
129 | |
---|
130 | typedef struct vfs_ctx_s |
---|
131 | { |
---|
132 | vfs_fs_type_t type; /*! File System type */ |
---|
133 | uint32_t attr; /*! global attributes for all files in FS */ |
---|
134 | uint32_t count; /*! total number of clusters on device */ |
---|
135 | uint32_t blksize; /*! device cluster size (bytes) */ |
---|
136 | xptr_t root_xp; /*! extended pointer on root inode */ |
---|
137 | spinlock_t lock; /*! lock protecting inum allocator */ |
---|
138 | uint32_t bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)]; /* inum allocator */ |
---|
139 | void * extend; /*! FS specific context extension */ |
---|
140 | } |
---|
141 | vfs_ctx_t; |
---|
142 | |
---|
143 | /****************************************************************************************** |
---|
144 | * This structure define a VFS inode. |
---|
145 | * It contains an extended pointer on the parent dentry, and (for directory only) |
---|
146 | * an hash table xhtab refering all children dentries. |
---|
147 | * The <parent> inode is unique for a directory (not hard links for directories). |
---|
148 | * For a file, the parent field points to the first dentry who created this inode. |
---|
149 | * Syncrhonisation: |
---|
150 | * - the main_lock (spinlock) is used during the inode tree traversal or for inode |
---|
151 | * modification (add/remove children). |
---|
152 | * - the data_lock (rwlock) is used during read/write accesses to the data stored |
---|
153 | * in the mapper. |
---|
154 | * - the mapper lock (rwlock) is only used during the radix tree traversal to return |
---|
155 | * the relevant page for read/write. |
---|
156 | *****************************************************************************************/ |
---|
157 | |
---|
158 | /* this enum define the VFS inode types values */ |
---|
159 | |
---|
160 | typedef enum |
---|
161 | { |
---|
162 | INODE_TYPE_FILE = 0x001, /*! file */ |
---|
163 | INODE_TYPE_DIR = 0x002, /*! directory */ |
---|
164 | INODE_TYPE_FIFO = 0x004, /*! POSIX named pipe */ |
---|
165 | INODE_TYPE_PIPE = 0x008, /*! POSIX anonymous pipe */ |
---|
166 | INODE_TYPE_SOCKET = 0x010, /*! POSIX socket */ |
---|
167 | INODE_TYPE_DEV = 0x020, /*! character peripheral channel */ |
---|
168 | INODE_TYPE_SYML = 0x080, /*! symbolic link */ |
---|
169 | } |
---|
170 | vfs_inode_type_t; |
---|
171 | |
---|
172 | /* this enum define the VFS inode attributes values */ |
---|
173 | |
---|
174 | typedef enum |
---|
175 | { |
---|
176 | INODE_ATTR_DIRTY = 0x01, /* modified versus the value on device */ |
---|
177 | INODE_ATTR_INLOAD = 0x04, /* loading from device in progress */ |
---|
178 | INODE_ATTR_NEW = 0x08, /* not saved on device yet */ |
---|
179 | } |
---|
180 | vfs_inode_attr_t; |
---|
181 | |
---|
182 | typedef struct vfs_inode_s |
---|
183 | { |
---|
184 | struct vfs_ctx_s * ctx; /*! local pointer on FS context */ |
---|
185 | uint32_t gc; /*! generation counter */ |
---|
186 | uint32_t inum; /*! inode identifier (unique in file system) */ |
---|
187 | uint32_t attr; /*! inode attributes (see above) */ |
---|
188 | vfs_inode_type_t type; /*! inode type (see above) */ |
---|
189 | uint32_t size; /*! number of bytes */ |
---|
190 | uint32_t links; /*! number of alias dentry */ |
---|
191 | uid_t uid; /*! user owner identifier */ |
---|
192 | gid_t gid; /*! group owner identifier */ |
---|
193 | uint32_t rights; /*! access rights */ |
---|
194 | uint32_t refcount; /*! reference counter (all pointers) */ |
---|
195 | xptr_t parent_xp; /*! extended pointer on parent dentry */ |
---|
196 | xhtab_t children; /*! embedded xhtab of vfs_dentry_t */ |
---|
197 | remote_rwlock_t data_lock; /*! protect read/write to data and to size */ |
---|
198 | remote_spinlock_t main_lock; /*! protect inode tree traversal and modifs */ |
---|
199 | list_entry_t list; /*! member of set of inodes in same cluster */ |
---|
200 | xlist_entry_t wait_root; /*! root of threads waiting on this inode */ |
---|
201 | struct vfs_inode_op_s * op; /*! TODO ??? */ |
---|
202 | struct mapper_s * mapper; /*! associated file cache */ |
---|
203 | void * extend; /*! FS specific inode extension */ |
---|
204 | } |
---|
205 | vfs_inode_t; |
---|
206 | |
---|
207 | /****************************************************************************************** |
---|
208 | * This structure defines a directory entry. |
---|
209 | * A dentry contains the name of a remote file/dir, an extended pointer on the |
---|
210 | * inode representing this file/dir, and a local pointer on the inode representing |
---|
211 | * the parent directory. |
---|
212 | *****************************************************************************************/ |
---|
213 | |
---|
214 | typedef struct vfs_dentry_s |
---|
215 | { |
---|
216 | struct vfs_ctx_s * ctx; /*! local pointer on FS context */ |
---|
217 | char name[CONFIG_VFS_MAX_NAME_LENGTH]; |
---|
218 | uint32_t length; /*! name length (bytes) */ |
---|
219 | uint32_t refcount; /*! reference counter (all pointers) */ |
---|
220 | struct vfs_inode_s * parent; /*! local pointer on parent inode */ |
---|
221 | xptr_t child_xp; /*! extended pointer on child inode */ |
---|
222 | xlist_entry_t xlist; /*! member of xlist of dentries with same key */ |
---|
223 | struct vfs_dentry_op_s * op; /*! TODO */ |
---|
224 | void * extend; /*! FS specific extension */ |
---|
225 | } |
---|
226 | vfs_dentry_t; |
---|
227 | |
---|
228 | /****************************************************************************************** |
---|
229 | * This file structure describes an open file/directory for a given process. |
---|
230 | * It is not replicated, and is dynamically allocated in the cluster that contains |
---|
231 | * the inode, when a thread makes an open() or opendir() system call. |
---|
232 | * It cannot exist a file structure without an inode structure. |
---|
233 | * Aa the fd_array (containing extended pointers on the open file descriptors) |
---|
234 | * is replicated in all process descriptors, we need a references counter. |
---|
235 | *****************************************************************************************/ |
---|
236 | |
---|
237 | typedef enum |
---|
238 | { |
---|
239 | FD_ATTR_READ_ENABLE = 0x01, /*! read access possible */ |
---|
240 | FD_ATTR_WRITE_ENABLE = 0x02, /*! write access possible */ |
---|
241 | FD_ATTR_APPEND = 0x04, /*! append on each write */ |
---|
242 | FD_ATTR_CLOSE_EXEC = 0x08, /*! close file on exec */ |
---|
243 | FD_ATTR_SYNC = 0x10, /*! synchronise FS on each write */ |
---|
244 | FD_ATTR_IS_DIR = 0x20, /*! this is a directory */ |
---|
245 | } |
---|
246 | vfs_file_attr_t; |
---|
247 | |
---|
248 | typedef struct vfs_file_s |
---|
249 | { |
---|
250 | struct vfs_ctx_s * ctx; /*! local pointer on FS context. */ |
---|
251 | uint32_t gc; /*! generation counter */ |
---|
252 | vfs_file_attr_t attr; /*! file attributes bit vector (see above) */ |
---|
253 | vfs_inode_type_t type; /*! same type as inode */ |
---|
254 | uint32_t offset; /*! seek position in file */ |
---|
255 | uint32_t refcount; /*! all pointers on this file descriptor */ |
---|
256 | remote_rwlock_t lock; /*! protect offset modifications */ |
---|
257 | struct mapper_s * mapper; /*! associated file cache */ |
---|
258 | struct vfs_inode_s * inode; /*! local pointer on associated inode */ |
---|
259 | void * extend; /*! FS specific extension */ |
---|
260 | } |
---|
261 | vfs_file_t; |
---|
262 | |
---|
263 | /****************************************************************************************** |
---|
264 | * This structure define the informations associated to a file descriptor, |
---|
265 | * returned to user space by the stat() system call. |
---|
266 | *****************************************************************************************/ |
---|
267 | |
---|
268 | typedef struct vfs_stat_s |
---|
269 | { |
---|
270 | uint32_t dev; /*! ID of device containing file */ |
---|
271 | uint32_t ino; /*! inode number */ |
---|
272 | uint32_t mode; /*! protection */ |
---|
273 | uint32_t nlink; /*! number of hard links */ |
---|
274 | uint32_t uid; /*! user ID of owner */ |
---|
275 | uint32_t gid; /*! group ID of owner */ |
---|
276 | uint32_t rdev; /*! device ID (if special file) */ |
---|
277 | uint64_t size; /*! total size, in bytes */ |
---|
278 | uint32_t blksize; /*! blocksize for file system I/O */ |
---|
279 | uint32_t blocks; /*! number of 512B blocks allocated */ |
---|
280 | uint64_t atime; /*! time of last access */ |
---|
281 | uint64_t mtime; /*! time of last modification */ |
---|
282 | uint64_t ctime; /*! time of last status change */ |
---|
283 | } |
---|
284 | vfs_stat_t; |
---|
285 | |
---|
286 | /********************************************************************************************* |
---|
287 | * This structure defines the information associated to a directory entry, |
---|
288 | * returned to user space by the readdir() system call. |
---|
289 | ********************************************************************************************/ |
---|
290 | |
---|
291 | typedef struct vfs_dirent_s |
---|
292 | { |
---|
293 | uint32_t inum; /*! inode identifier */ |
---|
294 | uint32_t type; /*! inode type */ |
---|
295 | char name[CONFIG_VFS_MAX_NAME_LENGTH]; /*! dentry name */ |
---|
296 | } |
---|
297 | vfs_dirent_t; |
---|
298 | |
---|
299 | |
---|
300 | |
---|
301 | /*****************************************************************************************/ |
---|
302 | /******************** VFS global functions ***********************************************/ |
---|
303 | /*****************************************************************************************/ |
---|
304 | |
---|
305 | |
---|
306 | /****************************************************************************************** |
---|
307 | * This function mount a given file system type for a given process TODO. |
---|
308 | *****************************************************************************************/ |
---|
309 | error_t vfs_mount_fs_root( struct device_s * device, |
---|
310 | uint32_t fs_type, |
---|
311 | struct process_s * process ); |
---|
312 | |
---|
313 | |
---|
314 | /*****************************************************************************************/ |
---|
315 | /******************* FS Context related functions ****************************************/ |
---|
316 | /*****************************************************************************************/ |
---|
317 | |
---|
318 | /****************************************************************************************** |
---|
319 | * This function allocates an inode identifier from the local cluster inum allocator. |
---|
320 | * The inum respects a fixed format: |
---|
321 | * - the 16 MSB bits contain the cluster identifier : cxy |
---|
322 | * - the 16 LSB bits contains the local inode identifier : lid |
---|
323 | ****************************************************************************************** |
---|
324 | * @ ctx : local pointer on file system context. |
---|
325 | * @ inum : [ou] buffer for allocated inode identifier. |
---|
326 | * @ return 0 if success / return non-zero if error. |
---|
327 | *****************************************************************************************/ |
---|
328 | error_t vfs_ctx_inum_alloc( vfs_ctx_t * ctx, |
---|
329 | uint32_t * inum ); |
---|
330 | |
---|
331 | /****************************************************************************************** |
---|
332 | * This function release an inode identifier. |
---|
333 | ****************************************************************************************** |
---|
334 | * @ ctx : local pointer on file system context. |
---|
335 | * @ inum : released inode identifier. |
---|
336 | *****************************************************************************************/ |
---|
337 | void vfs_ctx_inum_release( vfs_ctx_t * ctx, |
---|
338 | uint32_t inum ); |
---|
339 | |
---|
340 | |
---|
341 | |
---|
342 | |
---|
343 | /*****************************************************************************************/ |
---|
344 | /********************* Inode related functions *******************************************/ |
---|
345 | /*****************************************************************************************/ |
---|
346 | |
---|
347 | /****************************************************************************************** |
---|
348 | * This function allocates memory from local cluster for an inode descriptor and the |
---|
349 | * associated mapper. It initialise these descriptors from arguments values. |
---|
350 | * The parent dentry must have been previously created. |
---|
351 | * If the client thread is not running in the cluster containing this inode, |
---|
352 | * it must use the rpc_vfs_inode_create_client() function. |
---|
353 | ****************************************************************************************** |
---|
354 | * @ dentry_xp : extended pointer on associated dentry (in parent inode cluster). |
---|
355 | * @ fs_type : file system type. |
---|
356 | * @ inode_type : inode type. |
---|
357 | * @ attr : inode attributes. |
---|
358 | * @ rights : inode access rights. |
---|
359 | * @ uid : user owner ID. |
---|
360 | * @ gid : group owner ID. |
---|
361 | * @ inode_xp : [out] buffer for extended pointer on created inode. |
---|
362 | * # return 0 if success / return ENOMEM or EINVAL if error. |
---|
363 | *****************************************************************************************/ |
---|
364 | error_t vfs_inode_create( xptr_t dentry_xp, |
---|
365 | vfs_fs_type_t fs_type, |
---|
366 | vfs_inode_type_t inode_type, |
---|
367 | uint32_t attr, |
---|
368 | uint32_t rights, |
---|
369 | uid_t uid, |
---|
370 | gid_t gid, |
---|
371 | xptr_t * inode_xp ); |
---|
372 | |
---|
373 | /****************************************************************************************** |
---|
374 | * This function releases memory allocated to an inode descriptor. |
---|
375 | * It must be executed by a thread running in the cluster containing the inode, |
---|
376 | * and the inode refcount must be zero. |
---|
377 | * If the client thread is not running in the owner cluster, it must use the |
---|
378 | * rpc_vfs_inode_destroy_client() function. |
---|
379 | ****************************************************************************************** |
---|
380 | * @ inode : local pointer on inode descriptor. |
---|
381 | *****************************************************************************************/ |
---|
382 | void vfs_inode_destroy( vfs_inode_t * inode ); |
---|
383 | |
---|
384 | /****************************************************************************************** |
---|
385 | * This function atomically increment/decrement the inode refcount. |
---|
386 | * It can be called by any thread running in any cluster. |
---|
387 | *****************************************************************************************/ |
---|
388 | void vfs_inode_remote_up( xptr_t inode_xp ); |
---|
389 | void vfs_inode_remote_down( xptr_t inode_xp ); |
---|
390 | |
---|
391 | /****************************************************************************************** |
---|
392 | * This function returns the <size> of a file/dir from a remote inode, |
---|
393 | * taking the remote_rwlock protecting <size> in READ_MODE. |
---|
394 | ***************************************************************************************** |
---|
395 | * @ inode_xp : extended pointer on the remote inode. |
---|
396 | * @ return the current size. |
---|
397 | *****************************************************************************************/ |
---|
398 | uint32_t vfs_inode_get_size( xptr_t inode_xp ); |
---|
399 | |
---|
400 | /****************************************************************************************** |
---|
401 | * This function set the <size> of a file/dir to a remote inode, |
---|
402 | * taking the remote_rwlock protecting <size> in WRITE_MODE. |
---|
403 | ***************************************************************************************** |
---|
404 | * @ inode_xp : extended pointer on the remote inode. |
---|
405 | * @ size : value to be written. |
---|
406 | *****************************************************************************************/ |
---|
407 | void vfs_inode_set_size( xptr_t inode_xp, |
---|
408 | uint32_t size ); |
---|
409 | |
---|
410 | /****************************************************************************************** |
---|
411 | * This function takes the main lock of a remote inode. |
---|
412 | * This lock protect all inode fiels, including the children dentries. |
---|
413 | ***************************************************************************************** |
---|
414 | * @ inode_xp : extended pointer on the remote inode. |
---|
415 | *****************************************************************************************/ |
---|
416 | void vfs_inode_remote_lock( xptr_t inode_xp ); |
---|
417 | |
---|
418 | /****************************************************************************************** |
---|
419 | * This function releases the main lock of a remote inode. |
---|
420 | * This lock protect all inode fiels, including the children dentries. |
---|
421 | ***************************************************************************************** |
---|
422 | * @ inode_xp : extended pointer on the remote inode. |
---|
423 | *****************************************************************************************/ |
---|
424 | void vfs_inode_remote_unlock( xptr_t inode_xp ); |
---|
425 | |
---|
426 | |
---|
427 | |
---|
428 | |
---|
429 | /****************************************************************************************** |
---|
430 | * This function TODO |
---|
431 | *****************************************************************************************/ |
---|
432 | error_t vfs_inode_hold( vfs_inode_t * inode, |
---|
433 | uint32_t gc ); |
---|
434 | |
---|
435 | /****************************************************************************************** |
---|
436 | * This function TODO |
---|
437 | *****************************************************************************************/ |
---|
438 | error_t vfs_inode_trunc( vfs_inode_t * inode ); |
---|
439 | |
---|
440 | /****************************************************************************************** |
---|
441 | * This function TODO |
---|
442 | *****************************************************************************************/ |
---|
443 | error_t vfs_inode_link( vfs_inode_t * inode, |
---|
444 | uint32_t igc ); |
---|
445 | |
---|
446 | /****************************************************************************************** |
---|
447 | * This function TODO |
---|
448 | *****************************************************************************************/ |
---|
449 | error_t vfs_inode_unlink( vfs_inode_t * inode ); |
---|
450 | |
---|
451 | /****************************************************************************************** |
---|
452 | * This function TODO |
---|
453 | *****************************************************************************************/ |
---|
454 | error_t vfs_inode_stat( vfs_inode_t * inode, |
---|
455 | uint32_t inum ); |
---|
456 | |
---|
457 | /****************************************************************************************** |
---|
458 | * This function TODO |
---|
459 | *****************************************************************************************/ |
---|
460 | error_t vfs_icache_del( vfs_inode_t * inode ); |
---|
461 | |
---|
462 | |
---|
463 | /****************************************************************************************** |
---|
464 | * This function TODO Pourquoi 2 arguments ? |
---|
465 | *****************************************************************************************/ |
---|
466 | error_t vfs_stat_inode( vfs_inode_t * inode, |
---|
467 | uint32_t inum ); |
---|
468 | |
---|
469 | |
---|
470 | /*****************************************************************************************/ |
---|
471 | /***************** Dentry related functions **********************************************/ |
---|
472 | /*****************************************************************************************/ |
---|
473 | |
---|
474 | /****************************************************************************************** |
---|
475 | * This function allocates memory from local cluster for a dentry descriptor, |
---|
476 | * initialises it from arguments values, and returns the extended pointer on dentry. |
---|
477 | * The inode field is not initialized, because the inode does not exist yet. |
---|
478 | * If the client thread is not running in the target cluster for this inode, |
---|
479 | * it must use the rpc_dentry_create_client() function. |
---|
480 | ****************************************************************************************** |
---|
481 | * @ fs_type : file system type. |
---|
482 | * @ name : directory entry file/dir name. |
---|
483 | * @ parent : local pointer on parent inode. |
---|
484 | * @ dentry_xp : [out] buffer for extended pointer on created dentry. |
---|
485 | * @ return 0 if success / return ENOMEM or EINVAL if error. |
---|
486 | *****************************************************************************************/ |
---|
487 | error_t vfs_dentry_create( vfs_fs_type_t fs_type, |
---|
488 | char * name, |
---|
489 | vfs_inode_t * parent, |
---|
490 | xptr_t * dentry_xp ); |
---|
491 | |
---|
492 | /****************************************************************************************** |
---|
493 | * This function releases memory allocated to a dentry descriptor. |
---|
494 | * It must be executed by a thread running in the cluster containing the dentry, |
---|
495 | * and the dentry refcount must be zero. |
---|
496 | * If the client thread is not running in the owner cluster, it must use the |
---|
497 | * rpc_dentry_destroy_client() function. |
---|
498 | ****************************************************************************************** |
---|
499 | * @ dentry : local pointer on dentry descriptor. |
---|
500 | *****************************************************************************************/ |
---|
501 | void vfs_dentry_destroy( vfs_dentry_t * dentry ); |
---|
502 | |
---|
503 | /****************************************************************************************** |
---|
504 | * These functions atomically increment/decrement the dentry refcount. |
---|
505 | * It can be called by any thread running in any cluster. |
---|
506 | *****************************************************************************************/ |
---|
507 | void vfs_dentry_remote_up( xptr_t dentry_xp ); |
---|
508 | void vfs_dentry_remote_down( xptr_t dentry_xp ); |
---|
509 | |
---|
510 | |
---|
511 | /*****************************************************************************************/ |
---|
512 | /************************ File descriptor related functions ******************************/ |
---|
513 | /*****************************************************************************************/ |
---|
514 | |
---|
515 | /****************************************************************************************** |
---|
516 | * This function allocates memory and initializes a new local file descriptor. |
---|
517 | * It must be executed in the cluster containing the inode. |
---|
518 | * If the client thread is not running in the owner cluster, it must use the |
---|
519 | * rpc_vfs_file_create_client() function. |
---|
520 | ****************************************************************************************** |
---|
521 | * @ inode : local pointer on associated inode. |
---|
522 | * @ attr : file descriptor attributes. |
---|
523 | * @ file_xp : [out] buffer for extended pointer on created file descriptor. |
---|
524 | * @ return 0 if success / return ENOMEM if error. |
---|
525 | *****************************************************************************************/ |
---|
526 | error_t vfs_file_create( vfs_inode_t * inode, |
---|
527 | uint32_t attr, |
---|
528 | xptr_t * file_xp ); |
---|
529 | |
---|
530 | /****************************************************************************************** |
---|
531 | * This function releases memory allocated to a local file descriptor. |
---|
532 | * It must be executed by a thread running in the cluster containing the inode, |
---|
533 | * and the file refcount must be zero. |
---|
534 | * If the client thread is not running in the owner cluster, it must use the |
---|
535 | * rpc_vfs_file_destroy_client() function. |
---|
536 | ****************************************************************************************** |
---|
537 | * @ file : local pointer on file descriptor. |
---|
538 | *****************************************************************************************/ |
---|
539 | void vfs_file_destroy( vfs_file_t * file ); |
---|
540 | |
---|
541 | /****************************************************************************************** |
---|
542 | * These functions increment (resp. decrement) the count field in a remote file |
---|
543 | * descriptor, using a remote_atomic access. |
---|
544 | *****************************************************************************************/ |
---|
545 | void vfs_file_count_up ( xptr_t file_xp ); |
---|
546 | void vfs_file_count_down( xptr_t file_xp ); |
---|
547 | |
---|
548 | |
---|
549 | |
---|
550 | /*****************************************************************************************/ |
---|
551 | /******************* Inode-Tree related functions ****************************************/ |
---|
552 | /*****************************************************************************************/ |
---|
553 | |
---|
554 | /****************************************************************************************** |
---|
555 | * This function returns in a kernel buffer allocated by the caller function, |
---|
556 | * the pathname of a file/dir identified by an extended pointer on the inode. |
---|
557 | * It traverse the Inode Tree from the target node to the root. |
---|
558 | * It can be called by any thread running in any cluster. |
---|
559 | ****************************************************************************************** |
---|
560 | * @ inode_xp : pointer on inode descriptor. |
---|
561 | * @ buffer : kernel buffer for pathname (must be allocated by caller). |
---|
562 | * @ size : max number of characters in buffer. |
---|
563 | * @ return 0 if success / return EINVAL if buffer too small. |
---|
564 | *****************************************************************************************/ |
---|
565 | error_t vfs_get_path( xptr_t inode_xp, |
---|
566 | char * buffer, |
---|
567 | uint32_t max_size ); |
---|
568 | |
---|
569 | /****************************************************************************************** |
---|
570 | * This function takes a pathname (absolute or relative to cwd) and returns an extended |
---|
571 | * pointer on the associated inode. |
---|
572 | * - If a given name in the path is not found in the inode tree, it try to load the missing |
---|
573 | * dentry/inode couple, from informations found in the parent directory. |
---|
574 | * - If this directory entry does not exist on device, it returns an error. |
---|
575 | * - If the the file identified by the pathname does not exist on device but the |
---|
576 | * flag CREATE is set, the inode is created. |
---|
577 | * - If the the file identified by the pathname exist on device but both flags EXCL |
---|
578 | * and CREATE are set, an error is returned. |
---|
579 | ****************************************************************************************** |
---|
580 | * @ cwd_xp : extended pointer on current directory (for relative path). |
---|
581 | * @ pathname : path in kernel space (can be relative or absolute). |
---|
582 | * @ lookup_mode : flags defining the working mode (defined above in this file). |
---|
583 | * @ inode_xp : [out] buffer for extended pointer on inode. |
---|
584 | * @ return 0 if success / ENOENT if inode not found , EACCES if permissopn denied, |
---|
585 | * EAGAIN if a new complete lookup must be made |
---|
586 | *****************************************************************************************/ |
---|
587 | error_t vfs_lookup( xptr_t cwd_xp, |
---|
588 | char * pathname, |
---|
589 | uint32_t lookup_mode, |
---|
590 | xptr_t * inode_xp ); |
---|
591 | |
---|
592 | /****************************************************************************************** |
---|
593 | * This function creates a new couple dentry/inode, and insert it in the Inode-Tree. |
---|
594 | * It can be executed by any thread running in any cluster, as this function |
---|
595 | * uses the rpc_dentry_create_client() and rpc_inode_create client() if required. |
---|
596 | * - The dentry is created in the cluster containing the existing <parent_xp> inode. |
---|
597 | * - the child inode and its associated mapper are created in a randomly selected cluster. |
---|
598 | * - The new dentry name is defined by the <name> argument. |
---|
599 | * - The new inode and the parent inode can have different FS types. |
---|
600 | ****************************************************************************************** |
---|
601 | * @ inode_type : new inode type |
---|
602 | * @ fs_type : new inode FS type. |
---|
603 | * @ parent_xp : extended pointer on parent inode. |
---|
604 | * @ name : new directory entry name. |
---|
605 | * @ child_xp : [out] buffer for extended pointer on child inode. |
---|
606 | * @ return 0 if success / ENOENT if entry not found in parent directory |
---|
607 | *****************************************************************************************/ |
---|
608 | error_t vfs_add_child_in_parent( vfs_inode_type_t inode_type, |
---|
609 | vfs_fs_type_t fs_type, |
---|
610 | xptr_t parent_xp, |
---|
611 | char * name, |
---|
612 | xptr_t * child_xp ); |
---|
613 | |
---|
614 | /****************************************************************************************** |
---|
615 | * This function removes a couple dentry/inode from the Inode-Tree, and remove it from |
---|
616 | * the external device. |
---|
617 | * TODO |
---|
618 | ****************************************************************************************** |
---|
619 | * @ child_xp : extended pointer on removed inode. |
---|
620 | *****************************************************************************************/ |
---|
621 | error_t vfs_remove_child_from_parent( xptr_t child_xp ); |
---|
622 | |
---|
623 | |
---|
624 | |
---|
625 | |
---|
626 | |
---|
627 | |
---|
628 | /*****************************************************************************************/ |
---|
629 | /****************** File access API ******************************************************/ |
---|
630 | /*****************************************************************************************/ |
---|
631 | |
---|
632 | /****************************************************************************************** |
---|
633 | * This function allocates a vfs_file_t structure in the cluster containing the inode |
---|
634 | * associated to the file identified by <cwd_xp> & <path>. |
---|
635 | * It initializes it, register it in the reference process fd_array, and returns both |
---|
636 | * the extended pointer on the remote file descriptor, and the index in the fd_array. |
---|
637 | * The pathname can be relative to current directory or absolute. |
---|
638 | * If the inode does not exist in the inode cache, it try to find the file on the mounted |
---|
639 | * device, and creates an inode on a pseudo randomly selected cluster if found. |
---|
640 | * It the requested file does not exist on device, it creates a new inode if the |
---|
641 | * O_CREAT flag is set and return an error otherwise. |
---|
642 | ****************************************************************************************** |
---|
643 | * @ cwd_xp : extended pointer on current working directory file descriptor. |
---|
644 | * @ path : file pathname (absolute or relative to current directory). |
---|
645 | * @ flags : defined above |
---|
646 | * @ mode : access rights (as defined by chmod) |
---|
647 | * @ file_xp : [out] buffer for extended pointer on created remote file descriptor. |
---|
648 | * @ file_id : [out] buffer for created file descriptor index in reference fd_array. |
---|
649 | * @ return 0 if success / return non-zero if error. |
---|
650 | *****************************************************************************************/ |
---|
651 | error_t vfs_open( xptr_t cwd_xp, |
---|
652 | char * path, |
---|
653 | uint32_t flags, |
---|
654 | uint32_t mode, |
---|
655 | xptr_t * file_xp, |
---|
656 | uint32_t * file_id ); |
---|
657 | |
---|
658 | /****************************************************************************************** |
---|
659 | * This function moves <size> bytes between the file identified by the open file descriptor |
---|
660 | * <file_xp> and a local kernel <buffer> , taken into account the offset in <file_xp>. |
---|
661 | * The transfer direction is defined by the <to_buffer> argument. |
---|
662 | ****************************************************************************************** |
---|
663 | * @ to_buffer : mapper -> buffer if true / buffer->mapper if false. |
---|
664 | * @ file_xp : extended pointer on the remote file descriptor. |
---|
665 | * @ buffer : local pointer on local kernel buffer. |
---|
666 | * @ size : requested number of bytes from offset. |
---|
667 | * @ returns number of bytes actually transfered / -1 if error. |
---|
668 | *****************************************************************************************/ |
---|
669 | error_t vfs_move( bool_t to_buffer, |
---|
670 | xptr_t file_xp, |
---|
671 | void * buffer, |
---|
672 | uint32_t size ); |
---|
673 | |
---|
674 | /****************************************************************************************** |
---|
675 | * This function set a new value in the offset of the open file descriptor <file_xp>. |
---|
676 | * This value depends on the <whence> argument: |
---|
677 | * - if VFS_SEEK_SET, new value is <offset> |
---|
678 | * - if VFS_SEEK_CUR, new value is current_offset + <offset> |
---|
679 | * - if VFS_SEEK_END, new value is file_size + <offset> |
---|
680 | ****************************************************************************************** |
---|
681 | * @ file_xp : extended pointer on the remote open file descriptor. |
---|
682 | * @ offset : local pointer on source kernel buffer. |
---|
683 | * @ whence : VFS_SEEK_SET / VFS_SEEK_CUR / VFS_SEEK_END. |
---|
684 | * @ new_offset : [out] buffer for new offset value. |
---|
685 | * @ returns 0 if success / -1 if error. |
---|
686 | *****************************************************************************************/ |
---|
687 | error_t vfs_lseek( xptr_t file_xp, |
---|
688 | uint32_t offset, |
---|
689 | uint32_t whence, |
---|
690 | uint32_t * new_offset ); |
---|
691 | |
---|
692 | /****************************************************************************************** |
---|
693 | * This function close an open file descriptor: |
---|
694 | * 1) All entries in fd_array copies are directly cancelled by the calling thread, |
---|
695 | * using remote accesses. |
---|
696 | * 2) The memory allocated to file descriptor in cluster containing the inode is released. |
---|
697 | * It requires a RPC if cluster containing the file descriptor is remote. |
---|
698 | ****************************************************************************************** |
---|
699 | * @ file_xp : extended pointer on the file descriptor. |
---|
700 | * @ file_id : file descriptor index in fd_array. |
---|
701 | * @ returns 0 if success / -1 if error. |
---|
702 | *****************************************************************************************/ |
---|
703 | error_t vfs_close( xptr_t file_xp, |
---|
704 | uint32_t file_id ); |
---|
705 | |
---|
706 | /****************************************************************************************** |
---|
707 | * This function remove from the file system a directory entry identified by the |
---|
708 | * <cwd_xp> & <path> arguments. |
---|
709 | ****************************************************************************************** |
---|
710 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
711 | * @ path : pathname (absolute or relative to current directory). |
---|
712 | * @ returns 0 if success / -1 if error. |
---|
713 | *****************************************************************************************/ |
---|
714 | error_t vfs_unlink( xptr_t cwd_xp, |
---|
715 | char * path ); |
---|
716 | |
---|
717 | /****************************************************************************************** |
---|
718 | * This function returns, in the structure pointed by the <k_stat> kernel pointer, |
---|
719 | * various informations on the file descriptor identified by the <file_xp> argument. |
---|
720 | * TODO not implemented yet... |
---|
721 | ****************************************************************************************** |
---|
722 | * @ file_xp : extended pointer on the file descriptor of the searched directory . |
---|
723 | * @ k_dirent : local pointer on the dirent_t structure in kernel space. |
---|
724 | * @ returns 0 if success / -1 if error. |
---|
725 | *****************************************************************************************/ |
---|
726 | error_t vfs_stat( xptr_t file_xp, |
---|
727 | vfs_stat_t * k_stat ); |
---|
728 | |
---|
729 | /****************************************************************************************** |
---|
730 | * This function returns, in the structure pointed by the <k_dirent> kernel pointer, |
---|
731 | * various infos on the directory entry currently pointed by the <file_xp> file descriptor. |
---|
732 | * TODO not implemented yet... |
---|
733 | ****************************************************************************************** |
---|
734 | * @ file_xp : extended pointer on the file descriptor of the searched directory . |
---|
735 | * @ k_dirent : local pointer on the dirent_t structure in kernel space. |
---|
736 | * @ returns 0 if success / -1 if error. |
---|
737 | *****************************************************************************************/ |
---|
738 | error_t vfs_readdir( xptr_t file_xp, |
---|
739 | vfs_dirent_t * k_dirent ); |
---|
740 | |
---|
741 | /****************************************************************************************** |
---|
742 | * This function creates a new inode and associated dentry for the directory defined |
---|
743 | * by the <cwd_xp> & <path> arguments. |
---|
744 | * TODO not implemented yet... |
---|
745 | ****************************************************************************************** |
---|
746 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
747 | * @ path : pathname (absolute or relative to current directory). |
---|
748 | * @ mode : access rights (as defined by chmod) |
---|
749 | * @ returns 0 if success / -1 if error. |
---|
750 | *****************************************************************************************/ |
---|
751 | error_t vfs_mkdir( xptr_t cwd_xp, |
---|
752 | char * path, |
---|
753 | uint32_t mode ); |
---|
754 | |
---|
755 | /****************************************************************************************** |
---|
756 | * This function remove a directory identified by the <cwd_xp / path> arguments |
---|
757 | * from the file system. |
---|
758 | * TODO not implemented yet... |
---|
759 | ****************************************************************************************** |
---|
760 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
761 | * @ path : pathname (absolute or relative to current directory). |
---|
762 | * @ returns 0 if success / -1 if error. |
---|
763 | *****************************************************************************************/ |
---|
764 | error_t vfs_rmdir( xptr_t cwd_xp, |
---|
765 | char * path ); |
---|
766 | |
---|
767 | /****************************************************************************************** |
---|
768 | * This function makes the directory identified by <cwd_xp / path> arguments to become |
---|
769 | * the working directory for the calling process. |
---|
770 | ****************************************************************************************** |
---|
771 | * @ cwd_xp : extended pointer on current directory file descriptor (relative path). |
---|
772 | * @ path : file pathname (absolute or relative to current directory). |
---|
773 | * return 0 if success / -1 if error. |
---|
774 | *****************************************************************************************/ |
---|
775 | error_t vfs_chdir( xptr_t cwd_xp, |
---|
776 | char * path ); |
---|
777 | |
---|
778 | /****************************************************************************************** |
---|
779 | * This function change the access rigths for the file identified by the <cwd_xp / path> |
---|
780 | * arguments. The new access rights are defined by the <mode> argument value. |
---|
781 | ****************************************************************************************** |
---|
782 | * @ cwd_xp : extended pointer on current directory file descriptor (relative path). |
---|
783 | * @ path : file pathname (absolute or relative to current directory). |
---|
784 | * @ mode : access rights new value. |
---|
785 | * return 0 if success / -1 if error. |
---|
786 | *****************************************************************************************/ |
---|
787 | error_t vfs_chmod( xptr_t cwd_xp, |
---|
788 | char * path, |
---|
789 | uint32_t mode ); |
---|
790 | |
---|
791 | /****************************************************************************************** |
---|
792 | * This function creates a named FIFO file. |
---|
793 | * TODO not implemented yet |
---|
794 | ****************************************************************************************** |
---|
795 | * @ path : FIFO pathname (absolute or relative to current directory). |
---|
796 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
797 | * @ mode : access rights new value. |
---|
798 | *****************************************************************************************/ |
---|
799 | error_t vfs_mkfifo( xptr_t cwd_xp, |
---|
800 | char * path, |
---|
801 | uint32_t mode ); |
---|
802 | |
---|
803 | |
---|
804 | /*****************************************************************************************/ |
---|
805 | /****************** Mapper access API ****************************************************/ |
---|
806 | /*****************************************************************************************/ |
---|
807 | |
---|
808 | /****************************************************************************************** |
---|
809 | * This function makes an I/O operation to move one page from VFS to a given mapper, |
---|
810 | * in case of MISS on the mapper cache. |
---|
811 | * Depending on the file system type, it calls the proper, FS specific function. |
---|
812 | * It must be executed by a thread running in the cluster containing the mapper. |
---|
813 | * The mapper pointer is obtained from the page descriptor. |
---|
814 | * It takes the mapper lock before launching the IO operation. |
---|
815 | ****************************************************************************************** |
---|
816 | * @ page : local pointer on the page descriptor. |
---|
817 | * @ returns 0 if success / return EINVAL if it cannot access the external device. |
---|
818 | *****************************************************************************************/ |
---|
819 | error_t vfs_move_page_to_mapper( struct page_s * page ); |
---|
820 | |
---|
821 | /****************************************************************************************** |
---|
822 | * This function makes an I/0 operation to move one page from a given mapper to VFS, |
---|
823 | * when a dirty page in the mapper cache must be updated in the File System. |
---|
824 | * Depending on the file system type, it calls the proper, FS specific function. |
---|
825 | * It must be executed by a thread running in the cluster containing the mapper. |
---|
826 | * The mapper pointer is obtained from the page descriptor. |
---|
827 | * It takes the mapper lock before launching the IO operation. |
---|
828 | * It does nothing if the page is not dirty. If the page is dirty, it clear the page |
---|
829 | * dirty bit, and remove the page from the PPM dirty list. |
---|
830 | ****************************************************************************************** |
---|
831 | * @ page : local pointer on the page descriptor. |
---|
832 | * @ returns 0 if success / return EINVAL if it cannot access the external device. |
---|
833 | *****************************************************************************************/ |
---|
834 | error_t vfs_move_page_from_mapper( struct page_s * page ); |
---|
835 | |
---|
836 | |
---|
837 | |
---|
838 | |
---|
839 | |
---|
840 | |
---|
841 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
842 | // These typedef define the FS specific operations that must be implemented by any |
---|
843 | // specific file system to be supported by the ALMOS_MKH VFS. |
---|
844 | // These typedef are not actually used, and are only defined for documentation |
---|
845 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
846 | |
---|
847 | typedef error_t (fs_init_t) ( xptr_t vfs_root_xp ); |
---|
848 | |
---|
849 | typedef error_t (fs_inode_extend_t) ( struct vfs_inode_s * inode, |
---|
850 | void * extend ); |
---|
851 | |
---|
852 | typedef void (fs_inode_release_t) ( struct vfs_inode_s * inode ); |
---|
853 | |
---|
854 | typedef error_t (fs_write_page_t) ( struct page_s * page ); |
---|
855 | |
---|
856 | typedef error_t (fs_read_page_t) ( struct page_s * page ); |
---|
857 | |
---|
858 | |
---|
859 | |
---|
860 | |
---|
861 | |
---|
862 | |
---|
863 | |
---|
864 | |
---|
865 | /* deprecated [AG] |
---|
866 | |
---|
867 | typedef error_t (lookup_inode_t) ( vfs_inode_t * parent , |
---|
868 | vfs_dentry_t * dentry ); |
---|
869 | |
---|
870 | typedef error_t (write_inode_t) ( vfs_inode_t * inode ); |
---|
871 | |
---|
872 | typedef error_t (release_inode_t) ( vfs_inode_t * inode ); |
---|
873 | |
---|
874 | typedef error_t (unlink_inode_t) ( vfs_inode_t * parent, |
---|
875 | vfs_dentry_t * dentry, |
---|
876 | uint32_t flags ); |
---|
877 | |
---|
878 | typedef error_t (stat_inode_t) ( vfs_inode_t * inode ); |
---|
879 | |
---|
880 | typedef error_t (trunc_inode_t) ( vfs_inode_t * inode ); |
---|
881 | |
---|
882 | typedef error_t (delete_inode_t) ( vfs_inode_t * inode ); |
---|
883 | |
---|
884 | typedef struct vfs_inode_op_s |
---|
885 | { |
---|
886 | init_inode_t * init; |
---|
887 | create_inode_t * create; |
---|
888 | lookup_inode_t * lookup; |
---|
889 | write_inode_t * write; |
---|
890 | release_inode_t * release; |
---|
891 | unlink_inode_t * unlink; |
---|
892 | delete_inode_t * delete; |
---|
893 | stat_inode_t * stat; |
---|
894 | trunc_inode_t * trunc; // change the size of a file |
---|
895 | } |
---|
896 | vfs_inode_op_t; |
---|
897 | |
---|
898 | ****************************************************************************************** |
---|
899 | * These typedef define the set of FS specific operations on a VFS DENTRY descriptor. |
---|
900 | * They must be implemented by any specific file system to be supported by ALMOS_MKH. |
---|
901 | * This code is not actually used, and is only defined for documentation |
---|
902 | ****************************************************************************************** |
---|
903 | |
---|
904 | |
---|
905 | typedef error_t (vfs_compare_dentry_t) ( char * first , char * second ); |
---|
906 | |
---|
907 | typedef struct vfs_dentry_op_s |
---|
908 | { |
---|
909 | vfs_compare_dentry_t * compare; |
---|
910 | } |
---|
911 | vfs_dentry_op_t; |
---|
912 | |
---|
913 | |
---|
914 | ****************************************************************************************** |
---|
915 | * These typedef define the set of FS specific operations on FILE descriptors |
---|
916 | * They must be implemented by any specific file system to be supported by ALMOS_MKH. |
---|
917 | * This code is not actually used, and is only defined for documentation |
---|
918 | ****************************************************************************************** |
---|
919 | |
---|
920 | |
---|
921 | typedef error_t (open_file_t ) ( vfs_file_t * file, |
---|
922 | void * extend ); |
---|
923 | |
---|
924 | typedef error_t (read_file_t ) ( vfs_file_t * file, |
---|
925 | char * buffer, |
---|
926 | uint32_t count ); |
---|
927 | |
---|
928 | typedef error_t (write_file_t ) ( vfs_file_t * file, |
---|
929 | char * buffer, |
---|
930 | uint32_t count ); |
---|
931 | |
---|
932 | typedef error_t (lseek_file_t ) ( vfs_file_t * file ); |
---|
933 | |
---|
934 | typedef error_t (close_file_t ) ( vfs_file_t * file ); |
---|
935 | |
---|
936 | typedef error_t (release_file_t) ( vfs_file_t * file ); |
---|
937 | |
---|
938 | typedef error_t (read_dir_t ) ( vfs_file_t * file ); |
---|
939 | |
---|
940 | typedef error_t (mmap_file_t ) ( vfs_file_t * file , |
---|
941 | struct vseg_s * vseg ); |
---|
942 | |
---|
943 | typedef error_t (munmap_file_t ) ( vfs_file_t * file, |
---|
944 | struct vseg_s * vseg ); |
---|
945 | |
---|
946 | typedef struct vfs_file_op_s |
---|
947 | { |
---|
948 | open_file_t * open; |
---|
949 | read_file_t * read; |
---|
950 | write_file_t * write; |
---|
951 | lseek_file_t * lseek; |
---|
952 | read_dir_t * readdir; |
---|
953 | close_file_t * close; |
---|
954 | release_file_t * release; |
---|
955 | mmap_file_t * mmap; |
---|
956 | munmap_file_t * munmap; |
---|
957 | } |
---|
958 | vfs_file_op_t; |
---|
959 | |
---|
960 | */ |
---|
961 | |
---|
962 | #endif /* _VFS_H_ */ |
---|