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 total_clusters; /*! total number of clusters on device */ |
---|
135 | uint32_t cluster_size; /*! cluster size on device (bytes) */ |
---|
136 | xptr_t vfs_root_xp; /*! extended pointer on VFS 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_SOCK = 0x010, /*! POSIX socket */ |
---|
167 | INODE_TYPE_DEV = 0x020, /*! device 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 children dentries */ |
---|
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 mapper_s * mapper; /*! associated file cache */ |
---|
202 | void * extend; /*! fs_type_specific inode extension */ |
---|
203 | } |
---|
204 | vfs_inode_t; |
---|
205 | |
---|
206 | /****************************************************************************************** |
---|
207 | * This structure defines a directory entry. |
---|
208 | * A dentry contains the name of a remote file/dir, an extended pointer on the |
---|
209 | * inode representing this file/dir, and a local pointer on the inode representing |
---|
210 | * the parent directory. |
---|
211 | *****************************************************************************************/ |
---|
212 | |
---|
213 | typedef struct vfs_dentry_s |
---|
214 | { |
---|
215 | struct vfs_ctx_s * ctx; /*! local pointer on FS context */ |
---|
216 | char name[CONFIG_VFS_MAX_NAME_LENGTH]; |
---|
217 | uint32_t length; /*! name length (bytes) */ |
---|
218 | uint32_t refcount; /*! reference counter (all pointers) */ |
---|
219 | struct vfs_inode_s * parent; /*! local pointer on parent inode */ |
---|
220 | xptr_t child_xp; /*! extended pointer on child inode */ |
---|
221 | xlist_entry_t list; /*! member of list of dentries with same key */ |
---|
222 | void * extend; /*! FS specific extension */ |
---|
223 | } |
---|
224 | vfs_dentry_t; |
---|
225 | |
---|
226 | /****************************************************************************************** |
---|
227 | * This file structure describes an open file/directory for a given process. |
---|
228 | * It is not replicated, and is dynamically allocated in the cluster that contains |
---|
229 | * the inode, when a thread makes an open() or opendir() system call. |
---|
230 | * It cannot exist a file structure without an inode structure. |
---|
231 | * Aa the fd_array (containing extended pointers on the open file descriptors)* is replicated in all process descriptors, we need a references counter. |
---|
232 | * is replicated in all process descriptors, we need a references counter. |
---|
233 | *****************************************************************************************/ |
---|
234 | |
---|
235 | typedef enum |
---|
236 | { |
---|
237 | FD_ATTR_READ_ENABLE = 0x01, /*! read access possible */ |
---|
238 | FD_ATTR_WRITE_ENABLE = 0x02, /*! write access possible */ |
---|
239 | FD_ATTR_APPEND = 0x04, /*! append on each write */ |
---|
240 | FD_ATTR_CLOSE_EXEC = 0x08, /*! close file on exec */ |
---|
241 | FD_ATTR_SYNC = 0x10, /*! synchronise FS on each write */ |
---|
242 | FD_ATTR_IS_DIR = 0x20, /*! this is a directory */ |
---|
243 | } |
---|
244 | vfs_file_attr_t; |
---|
245 | |
---|
246 | typedef struct vfs_file_s |
---|
247 | { |
---|
248 | struct vfs_ctx_s * ctx; /*! local pointer on FS context. */ |
---|
249 | uint32_t gc; /*! generation counter */ |
---|
250 | vfs_file_attr_t attr; /*! file attributes bit vector (see above) */ |
---|
251 | vfs_inode_type_t type; /*! same type as inode */ |
---|
252 | uint32_t offset; /*! seek position in file */ |
---|
253 | uint32_t refcount; /*! all pointers on this file descriptor */ |
---|
254 | remote_rwlock_t lock; /*! protect offset modifications */ |
---|
255 | struct mapper_s * mapper; /*! associated file cache */ |
---|
256 | struct vfs_inode_s * inode; /*! local pointer on associated inode */ |
---|
257 | void * extend; /*! FS specific extension */ |
---|
258 | } |
---|
259 | vfs_file_t; |
---|
260 | |
---|
261 | /****************************************************************************************** |
---|
262 | * This structure define the informations associated to a file descriptor, |
---|
263 | * returned to user space by the stat() system call. |
---|
264 | *****************************************************************************************/ |
---|
265 | |
---|
266 | typedef struct vfs_stat_s |
---|
267 | { |
---|
268 | uint32_t dev; /*! ID of device containing file */ |
---|
269 | uint32_t ino; /*! inode number */ |
---|
270 | uint32_t mode; /*! protection */ |
---|
271 | uint32_t nlink; /*! number of hard links */ |
---|
272 | uint32_t uid; /*! user ID of owner */ |
---|
273 | uint32_t gid; /*! group ID of owner */ |
---|
274 | uint32_t rdev; /*! device ID (if special file) */ |
---|
275 | uint64_t size; /*! total size, in bytes */ |
---|
276 | uint32_t blksize; /*! blocksize for file system I/O */ |
---|
277 | uint32_t blocks; /*! number of 512B blocks allocated */ |
---|
278 | uint64_t atime; /*! time of last access */ |
---|
279 | uint64_t mtime; /*! time of last modification */ |
---|
280 | uint64_t ctime; /*! time of last status change */ |
---|
281 | } |
---|
282 | vfs_stat_t; |
---|
283 | |
---|
284 | /********************************************************************************************* |
---|
285 | * This structure defines the information associated to a directory entry, |
---|
286 | * returned to user space by the readdir() system call. |
---|
287 | ********************************************************************************************/ |
---|
288 | |
---|
289 | typedef struct vfs_dirent_s |
---|
290 | { |
---|
291 | uint32_t inum; /*! inode identifier */ |
---|
292 | uint32_t type; /*! inode type */ |
---|
293 | char name[CONFIG_VFS_MAX_NAME_LENGTH]; /*! dentry name */ |
---|
294 | } |
---|
295 | vfs_dirent_t; |
---|
296 | |
---|
297 | |
---|
298 | |
---|
299 | /*****************************************************************************************/ |
---|
300 | /******************** VFS global functions ***********************************************/ |
---|
301 | /*****************************************************************************************/ |
---|
302 | |
---|
303 | |
---|
304 | /****************************************************************************************** |
---|
305 | * This function mount a given file system type for a given process TODO. |
---|
306 | *****************************************************************************************/ |
---|
307 | error_t vfs_mount_fs_root( struct device_s * device, |
---|
308 | uint32_t fs_type, |
---|
309 | struct process_s * process ); |
---|
310 | |
---|
311 | |
---|
312 | /*****************************************************************************************/ |
---|
313 | /******************* VFS Context related functions ****************************************/ |
---|
314 | /*****************************************************************************************/ |
---|
315 | |
---|
316 | /****************************************************************************************** |
---|
317 | * This function initialise a (statically allocated) VFS context in local cluster. |
---|
318 | ****************************************************************************************** |
---|
319 | * @ fs_type : file system type. |
---|
320 | * @ attr : global attributes (for all files in FS. |
---|
321 | * @ total_clusters : total number of clusters on device. |
---|
322 | * @ cluster_size : cluster size on device (bytes). |
---|
323 | * @ vfs_root_xp : extended pointer on VFS root inode. |
---|
324 | * @ extend : fs_type_specific extension. |
---|
325 | *****************************************************************************************/ |
---|
326 | void vfs_ctx_init( vfs_fs_type_t type, |
---|
327 | uint32_t attr, |
---|
328 | uint32_t total_clusters, |
---|
329 | uint32_t cluster_size, |
---|
330 | xptr_t vfs_root_xp, |
---|
331 | void * extend ); |
---|
332 | |
---|
333 | /****************************************************************************************** |
---|
334 | * This function allocates an inode identifier from the local cluster inum allocator. |
---|
335 | * The inum respects a fixed format: |
---|
336 | * - the 16 MSB bits contain the cluster identifier : cxy |
---|
337 | * - the 16 LSB bits contains the local inode identifier : lid |
---|
338 | ****************************************************************************************** |
---|
339 | * @ ctx : local pointer on file system context. |
---|
340 | * @ inum : [ou] buffer for allocated inode identifier. |
---|
341 | * @ return 0 if success / return non-zero if error. |
---|
342 | *****************************************************************************************/ |
---|
343 | error_t vfs_ctx_inum_alloc( vfs_ctx_t * ctx, |
---|
344 | uint32_t * inum ); |
---|
345 | |
---|
346 | /****************************************************************************************** |
---|
347 | * This function release an inode identifier. |
---|
348 | ****************************************************************************************** |
---|
349 | * @ ctx : local pointer on file system context. |
---|
350 | * @ inum : released inode identifier. |
---|
351 | *****************************************************************************************/ |
---|
352 | void vfs_ctx_inum_release( vfs_ctx_t * ctx, |
---|
353 | uint32_t inum ); |
---|
354 | |
---|
355 | |
---|
356 | |
---|
357 | |
---|
358 | /*****************************************************************************************/ |
---|
359 | /********************* Inode related functions *******************************************/ |
---|
360 | /*****************************************************************************************/ |
---|
361 | |
---|
362 | /****************************************************************************************** |
---|
363 | * This function allocates memory from local cluster for an inode descriptor and the |
---|
364 | * associated mapper. It initialise these descriptors from arguments values. |
---|
365 | * The parent dentry must have been previously created. |
---|
366 | * If the client thread is not running in the cluster containing this inode, |
---|
367 | * it must use the rpc_vfs_inode_create_client() function. |
---|
368 | ****************************************************************************************** |
---|
369 | * @ dentry_xp : extended pointer on associated dentry (in parent inode cluster). |
---|
370 | * @ fs_type : file system type. |
---|
371 | * @ inode_type : inode type. |
---|
372 | * @ extend : local pointer on vs_type_specific extension. |
---|
373 | * @ attr : inode attributes. |
---|
374 | * @ rights : inode access rights. |
---|
375 | * @ uid : user owner ID. |
---|
376 | * @ gid : group owner ID. |
---|
377 | * @ inode_xp : [out] buffer for extended pointer on created inode. |
---|
378 | * # return 0 if success / return ENOMEM or EINVAL if error. |
---|
379 | *****************************************************************************************/ |
---|
380 | error_t vfs_inode_create( xptr_t dentry_xp, |
---|
381 | vfs_fs_type_t fs_type, |
---|
382 | vfs_inode_type_t inode_type, |
---|
383 | void * extend, |
---|
384 | uint32_t attr, |
---|
385 | uint32_t rights, |
---|
386 | uid_t uid, |
---|
387 | gid_t gid, |
---|
388 | xptr_t * inode_xp ); |
---|
389 | |
---|
390 | /****************************************************************************************** |
---|
391 | * This function releases memory allocated to an inode descriptor. |
---|
392 | * It must be executed by a thread running in the cluster containing the inode, |
---|
393 | * and the inode refcount must be zero. |
---|
394 | * If the client thread is not running in the owner cluster, it must use the |
---|
395 | * rpc_vfs_inode_destroy_client() function. |
---|
396 | ****************************************************************************************** |
---|
397 | * @ inode : local pointer on inode descriptor. |
---|
398 | *****************************************************************************************/ |
---|
399 | void vfs_inode_destroy( vfs_inode_t * inode ); |
---|
400 | |
---|
401 | /****************************************************************************************** |
---|
402 | * This function scan an existing parent inode directory, identified by the <parent> |
---|
403 | * argument to find a directory entry identified by the <name> argument, and update |
---|
404 | * the remote child inode, identified by the <child_xp> argument. |
---|
405 | * Depending on the file system type, it calls the relevant, FS specific function, |
---|
406 | * to scan the directory, and set the "type", "size", and "extend" fields. |
---|
407 | * It must be called by a thread running in the cluster containing the parent inode. |
---|
408 | ****************************************************************************************** |
---|
409 | * @ parent : local pointer on parent inode (directory). |
---|
410 | * @ name : child name. |
---|
411 | * @ child_xp : extended pointer on remote child inode (file or directory) |
---|
412 | * @ return 0 if success / return ENOENT if not found. |
---|
413 | *****************************************************************************************/ |
---|
414 | error_t vfs_inode_load( vfs_inode_t * parent, |
---|
415 | char * name, |
---|
416 | xptr_t child_xp ); |
---|
417 | |
---|
418 | /****************************************************************************************** |
---|
419 | * This function atomically increment/decrement the inode refcount. |
---|
420 | * It can be called by any thread running in any cluster. |
---|
421 | *****************************************************************************************/ |
---|
422 | void vfs_inode_remote_up( xptr_t inode_xp ); |
---|
423 | void vfs_inode_remote_down( xptr_t inode_xp ); |
---|
424 | |
---|
425 | /****************************************************************************************** |
---|
426 | * This function returns the <size> of a file/dir from a remote inode, |
---|
427 | * taking the remote_rwlock protecting <size> in READ_MODE. |
---|
428 | ***************************************************************************************** |
---|
429 | * @ inode_xp : extended pointer on the remote inode. |
---|
430 | * @ return the current size. |
---|
431 | *****************************************************************************************/ |
---|
432 | uint32_t vfs_inode_get_size( xptr_t inode_xp ); |
---|
433 | |
---|
434 | /****************************************************************************************** |
---|
435 | * This function set the <size> of a file/dir to a remote inode, |
---|
436 | * taking the remote_rwlock protecting <size> in WRITE_MODE. |
---|
437 | ***************************************************************************************** |
---|
438 | * @ inode_xp : extended pointer on the remote inode. |
---|
439 | * @ size : value to be written. |
---|
440 | *****************************************************************************************/ |
---|
441 | void vfs_inode_set_size( xptr_t inode_xp, |
---|
442 | uint32_t size ); |
---|
443 | |
---|
444 | /****************************************************************************************** |
---|
445 | * This function takes the main lock of a remote inode. |
---|
446 | * This lock protect all inode fiels, including the children dentries. |
---|
447 | ***************************************************************************************** |
---|
448 | * @ inode_xp : extended pointer on the remote inode. |
---|
449 | *****************************************************************************************/ |
---|
450 | void vfs_inode_lock( xptr_t inode_xp ); |
---|
451 | |
---|
452 | /****************************************************************************************** |
---|
453 | * This function releases the main lock of a remote inode. |
---|
454 | * This lock protect all inode fiels, including the children dentries. |
---|
455 | ***************************************************************************************** |
---|
456 | * @ inode_xp : extended pointer on the remote inode. |
---|
457 | *****************************************************************************************/ |
---|
458 | void vfs_inode_unlock( xptr_t inode_xp ); |
---|
459 | |
---|
460 | /****************************************************************************************** |
---|
461 | * This debug function returns the current owner of the inode main lock. |
---|
462 | ***************************************************************************************** |
---|
463 | * @ inode_xp : extended pointer on the remote inode. |
---|
464 | * @ return extended pointer on owner thread / return XPTR_NULL if lock not taken. |
---|
465 | *****************************************************************************************/ |
---|
466 | xptr_t vfs_inode_owner( xptr_t inode_xp ); |
---|
467 | |
---|
468 | /****************************************************************************************** |
---|
469 | * This debug function diplays the name of the inode identified by the <inode_xp> |
---|
470 | * argument, and all children names for a directory. |
---|
471 | ***************************************************************************************** |
---|
472 | * @ inode_xp : extended pointer on the remote inode. |
---|
473 | *****************************************************************************************/ |
---|
474 | void vfs_inode_display( xptr_t inode_xp ); |
---|
475 | |
---|
476 | |
---|
477 | |
---|
478 | |
---|
479 | |
---|
480 | |
---|
481 | /****************************************************************************************** |
---|
482 | * This function TODO |
---|
483 | *****************************************************************************************/ |
---|
484 | error_t vfs_inode_trunc( vfs_inode_t * inode ); |
---|
485 | |
---|
486 | /****************************************************************************************** |
---|
487 | * This function TODO |
---|
488 | *****************************************************************************************/ |
---|
489 | error_t vfs_inode_link( vfs_inode_t * inode, |
---|
490 | uint32_t igc ); |
---|
491 | |
---|
492 | /****************************************************************************************** |
---|
493 | * This function TODO |
---|
494 | *****************************************************************************************/ |
---|
495 | error_t vfs_inode_unlink( vfs_inode_t * inode ); |
---|
496 | |
---|
497 | /****************************************************************************************** |
---|
498 | * This function TODO |
---|
499 | *****************************************************************************************/ |
---|
500 | error_t vfs_inode_stat( vfs_inode_t * inode, |
---|
501 | uint32_t inum ); |
---|
502 | |
---|
503 | /****************************************************************************************** |
---|
504 | * This function TODO |
---|
505 | *****************************************************************************************/ |
---|
506 | error_t vfs_icache_del( vfs_inode_t * inode ); |
---|
507 | |
---|
508 | |
---|
509 | /****************************************************************************************** |
---|
510 | * This function TODO Pourquoi 2 arguments ? |
---|
511 | *****************************************************************************************/ |
---|
512 | error_t vfs_stat_inode( vfs_inode_t * inode, |
---|
513 | uint32_t inum ); |
---|
514 | |
---|
515 | |
---|
516 | /*****************************************************************************************/ |
---|
517 | /***************** Dentry related functions **********************************************/ |
---|
518 | /*****************************************************************************************/ |
---|
519 | |
---|
520 | /****************************************************************************************** |
---|
521 | * This function allocates memory from local cluster for a dentry descriptor, |
---|
522 | * initialises it from arguments values, and returns the extended pointer on dentry. |
---|
523 | * The inode field is not initialized, because the inode does not exist yet. |
---|
524 | * If the client thread is not running in the target cluster for this inode, |
---|
525 | * it must use the rpc_dentry_create_client() function. |
---|
526 | ****************************************************************************************** |
---|
527 | * @ fs_type : file system type. |
---|
528 | * @ name : directory entry file/dir name. |
---|
529 | * @ parent : local pointer on parent inode. |
---|
530 | * @ dentry_xp : [out] buffer for extended pointer on created dentry. |
---|
531 | * @ return 0 if success / return ENOMEM or EINVAL if error. |
---|
532 | *****************************************************************************************/ |
---|
533 | error_t vfs_dentry_create( vfs_fs_type_t fs_type, |
---|
534 | char * name, |
---|
535 | vfs_inode_t * parent, |
---|
536 | xptr_t * dentry_xp ); |
---|
537 | |
---|
538 | /****************************************************************************************** |
---|
539 | * This function releases memory allocated to a dentry descriptor. |
---|
540 | * It must be executed by a thread running in the cluster containing the dentry, |
---|
541 | * and the dentry refcount must be zero. |
---|
542 | * If the client thread is not running in the owner cluster, it must use the |
---|
543 | * rpc_dentry_destroy_client() function. |
---|
544 | ****************************************************************************************** |
---|
545 | * @ dentry : local pointer on dentry descriptor. |
---|
546 | *****************************************************************************************/ |
---|
547 | void vfs_dentry_destroy( vfs_dentry_t * dentry ); |
---|
548 | |
---|
549 | /****************************************************************************************** |
---|
550 | * These functions atomically increment/decrement the dentry refcount. |
---|
551 | * It can be called by any thread running in any cluster. |
---|
552 | *****************************************************************************************/ |
---|
553 | void vfs_dentry_remote_up( xptr_t dentry_xp ); |
---|
554 | void vfs_dentry_remote_down( xptr_t dentry_xp ); |
---|
555 | |
---|
556 | |
---|
557 | /*****************************************************************************************/ |
---|
558 | /************************ File descriptor related functions ******************************/ |
---|
559 | /*****************************************************************************************/ |
---|
560 | |
---|
561 | /****************************************************************************************** |
---|
562 | * This function allocates memory and initializes a new local file descriptor. |
---|
563 | * It must be executed in the cluster containing the inode. |
---|
564 | * If the client thread is not running in the owner cluster, it must use the |
---|
565 | * rpc_vfs_file_create_client() function. |
---|
566 | ****************************************************************************************** |
---|
567 | * @ inode : local pointer on associated inode. |
---|
568 | * @ attr : file descriptor attributes. |
---|
569 | * @ file_xp : [out] buffer for extended pointer on created file descriptor. |
---|
570 | * @ return 0 if success / return ENOMEM if error. |
---|
571 | *****************************************************************************************/ |
---|
572 | error_t vfs_file_create( vfs_inode_t * inode, |
---|
573 | uint32_t attr, |
---|
574 | xptr_t * file_xp ); |
---|
575 | |
---|
576 | /****************************************************************************************** |
---|
577 | * This function releases memory allocated to a local file descriptor. |
---|
578 | * It must be executed by a thread running in the cluster containing the inode, |
---|
579 | * and the file refcount must be zero. |
---|
580 | * If the client thread is not running in the owner cluster, it must use the |
---|
581 | * rpc_vfs_file_destroy_client() function. |
---|
582 | ****************************************************************************************** |
---|
583 | * @ file : local pointer on file descriptor. |
---|
584 | *****************************************************************************************/ |
---|
585 | void vfs_file_destroy( vfs_file_t * file ); |
---|
586 | |
---|
587 | /****************************************************************************************** |
---|
588 | * These functions increment (resp. decrement) the count field in a remote file |
---|
589 | * descriptor, using a remote_atomic access. |
---|
590 | *****************************************************************************************/ |
---|
591 | void vfs_file_count_up ( xptr_t file_xp ); |
---|
592 | void vfs_file_count_down( xptr_t file_xp ); |
---|
593 | |
---|
594 | |
---|
595 | |
---|
596 | /*****************************************************************************************/ |
---|
597 | /******************* Inode-Tree related functions ****************************************/ |
---|
598 | /*****************************************************************************************/ |
---|
599 | |
---|
600 | /****************************************************************************************** |
---|
601 | * This function randomly selects a cluster for a new inode. |
---|
602 | ****************************************************************************************** |
---|
603 | * @ returns the selected cluster identifier. |
---|
604 | *****************************************************************************************/ |
---|
605 | cxy_t vfs_cluster_random_select(); |
---|
606 | |
---|
607 | /****************************************************************************************** |
---|
608 | * This function returns in a kernel buffer allocated by the caller function, |
---|
609 | * the pathname of a file/dir identified by an extended pointer on the inode. |
---|
610 | * It traverse the Inode Tree from the target node to the root. |
---|
611 | * It can be called by any thread running in any cluster. |
---|
612 | ****************************************************************************************** |
---|
613 | * @ inode_xp : pointer on inode descriptor. |
---|
614 | * @ buffer : kernel buffer for pathname (must be allocated by caller). |
---|
615 | * @ size : max number of characters in buffer. |
---|
616 | * @ return 0 if success / return EINVAL if buffer too small. |
---|
617 | *****************************************************************************************/ |
---|
618 | error_t vfs_get_path( xptr_t inode_xp, |
---|
619 | char * buffer, |
---|
620 | uint32_t max_size ); |
---|
621 | |
---|
622 | /****************************************************************************************** |
---|
623 | * This function takes a pathname (absolute or relative to cwd) and returns an extended |
---|
624 | * pointer on the associated inode. |
---|
625 | * - If a given name in the path is not found in the inode tree, it try to load the missing |
---|
626 | * dentry/inode couple, from informations found in the parent directory. |
---|
627 | * - If this directory entry does not exist on device, it returns an error. |
---|
628 | * - If the the file identified by the pathname does not exist on device but the |
---|
629 | * flag CREATE is set, the inode is created. |
---|
630 | * - If the the file identified by the pathname exist on device but both flags EXCL |
---|
631 | * and CREATE are set, an error is returned. |
---|
632 | ****************************************************************************************** |
---|
633 | * @ cwd_xp : extended pointer on current directory (for relative path). |
---|
634 | * @ pathname : path in kernel space (can be relative or absolute). |
---|
635 | * @ lookup_mode : flags defining the working mode (defined above in this file). |
---|
636 | * @ inode_xp : [out] buffer for extended pointer on searched inode. |
---|
637 | * @ return 0 if success / ENOENT if inode not found , EACCES if permissopn denied, |
---|
638 | * EAGAIN if a new complete lookup must be made |
---|
639 | *****************************************************************************************/ |
---|
640 | error_t vfs_lookup( xptr_t cwd_xp, |
---|
641 | char * pathname, |
---|
642 | uint32_t lookup_mode, |
---|
643 | xptr_t * inode_xp ); |
---|
644 | |
---|
645 | /****************************************************************************************** |
---|
646 | * This function creates a new couple dentry/inode, and insert it in the Inode-Tree. |
---|
647 | * It can be executed by any thread running in any cluster, as this function |
---|
648 | * uses the rpc_dentry_create_client() and rpc_inode_create client() if required. |
---|
649 | * This is done in three steps: |
---|
650 | * 1) The dentry is created in the cluster containing the existing <parent_xp> inode. |
---|
651 | * The new dentry name is defined by the <name> argument. |
---|
652 | * 2) The inode and its associated mapper are created in cluster identified by <child_cxy>. |
---|
653 | * The new inode and the parent inode can have different FS types. |
---|
654 | * 3) The "child_xp" field in created dentry (pointing on the created inode) is updated. |
---|
655 | ****************************************************************************************** |
---|
656 | * @ child_cxy : target cluster for child inode. |
---|
657 | * @ inode_type : new inode type |
---|
658 | * @ fs_type : new inode FS type. |
---|
659 | * @ parent_xp : extended pointer on parent inode. |
---|
660 | * @ name : new directory entry name. |
---|
661 | * @ extend : fs_type_specific inode extension. |
---|
662 | * @ child_xp : [out] buffer for extended pointer on child inode. |
---|
663 | * @ return 0 if success / ENOMEM if dentry or inode cannot be created. |
---|
664 | *****************************************************************************************/ |
---|
665 | error_t vfs_add_child_in_parent( cxy_t child_cxy, |
---|
666 | vfs_inode_type_t inode_type, |
---|
667 | vfs_fs_type_t fs_type, |
---|
668 | xptr_t parent_xp, |
---|
669 | char * name, |
---|
670 | void * extend, |
---|
671 | xptr_t * child_xp ); |
---|
672 | |
---|
673 | /****************************************************************************************** |
---|
674 | * This function removes a couple dentry/inode from the Inode-Tree, and remove it from |
---|
675 | * the external device. |
---|
676 | * TODO |
---|
677 | ****************************************************************************************** |
---|
678 | * @ child_xp : extended pointer on removed inode. |
---|
679 | *****************************************************************************************/ |
---|
680 | error_t vfs_remove_child_from_parent( xptr_t child_xp ); |
---|
681 | |
---|
682 | /****************************************************************************************** |
---|
683 | * This recursive function diplays a complete inode/dentry sub-tree. |
---|
684 | * Any inode can be selected as the sub-tree root. |
---|
685 | * TODO this function is not protected against a concurrent inode/dentry removal... |
---|
686 | ****************************************************************************************** |
---|
687 | * @ inode_xp : extended pointer on sub-tree root inode. |
---|
688 | *****************************************************************************************/ |
---|
689 | void vfs_display( xptr_t inode_xp ); |
---|
690 | |
---|
691 | |
---|
692 | |
---|
693 | |
---|
694 | |
---|
695 | /*****************************************************************************************/ |
---|
696 | /****************** File access API ******************************************************/ |
---|
697 | /*****************************************************************************************/ |
---|
698 | |
---|
699 | /****************************************************************************************** |
---|
700 | * This function allocates a vfs_file_t structure in the cluster containing the inode |
---|
701 | * associated to the file identified by <cwd_xp> & <path>. |
---|
702 | * It initializes it, register it in the reference process fd_array, and returns both |
---|
703 | * the extended pointer on the remote file descriptor, and the index in the fd_array. |
---|
704 | * The pathname can be relative to current directory or absolute. |
---|
705 | * If the inode does not exist in the inode cache, it try to find the file on the mounted |
---|
706 | * device, and creates an inode on a pseudo randomly selected cluster if found. |
---|
707 | * It the requested file does not exist on device, it creates a new inode if the |
---|
708 | * O_CREAT flag is set and return an error otherwise. |
---|
709 | ****************************************************************************************** |
---|
710 | * @ cwd_xp : extended pointer on current working directory file descriptor. |
---|
711 | * @ path : file pathname (absolute or relative to current directory). |
---|
712 | * @ flags : defined above |
---|
713 | * @ mode : access rights (as defined by chmod) |
---|
714 | * @ file_xp : [out] buffer for extended pointer on created remote file descriptor. |
---|
715 | * @ file_id : [out] buffer for created file descriptor index in reference fd_array. |
---|
716 | * @ return 0 if success / return non-zero if error. |
---|
717 | *****************************************************************************************/ |
---|
718 | error_t vfs_open( xptr_t cwd_xp, |
---|
719 | char * path, |
---|
720 | uint32_t flags, |
---|
721 | uint32_t mode, |
---|
722 | xptr_t * file_xp, |
---|
723 | uint32_t * file_id ); |
---|
724 | |
---|
725 | /****************************************************************************************** |
---|
726 | * This function moves <size> bytes between the file identified by the open file descriptor |
---|
727 | * <file_xp> and a local kernel <buffer> , taken into account the offset in <file_xp>. |
---|
728 | * The transfer direction is defined by the <to_buffer> argument. |
---|
729 | ****************************************************************************************** |
---|
730 | * @ to_buffer : mapper -> buffer if true / buffer->mapper if false. |
---|
731 | * @ file_xp : extended pointer on the remote file descriptor. |
---|
732 | * @ buffer : local pointer on local kernel buffer. |
---|
733 | * @ size : requested number of bytes from offset. |
---|
734 | * @ returns number of bytes actually transfered / -1 if error. |
---|
735 | *****************************************************************************************/ |
---|
736 | error_t vfs_move( bool_t to_buffer, |
---|
737 | xptr_t file_xp, |
---|
738 | void * buffer, |
---|
739 | uint32_t size ); |
---|
740 | |
---|
741 | /****************************************************************************************** |
---|
742 | * This function set a new value in the offset of the open file descriptor <file_xp>. |
---|
743 | * This value depends on the <whence> argument: |
---|
744 | * - if VFS_SEEK_SET, new value is <offset> |
---|
745 | * - if VFS_SEEK_CUR, new value is current_offset + <offset> |
---|
746 | * - if VFS_SEEK_END, new value is file_size + <offset> |
---|
747 | ****************************************************************************************** |
---|
748 | * @ file_xp : extended pointer on the remote open file descriptor. |
---|
749 | * @ offset : local pointer on source kernel buffer. |
---|
750 | * @ whence : VFS_SEEK_SET / VFS_SEEK_CUR / VFS_SEEK_END. |
---|
751 | * @ new_offset : [out] buffer for new offset value. |
---|
752 | * @ returns 0 if success / -1 if error. |
---|
753 | *****************************************************************************************/ |
---|
754 | error_t vfs_lseek( xptr_t file_xp, |
---|
755 | uint32_t offset, |
---|
756 | uint32_t whence, |
---|
757 | uint32_t * new_offset ); |
---|
758 | |
---|
759 | /****************************************************************************************** |
---|
760 | * This function close an open file descriptor: |
---|
761 | * 1) All entries in fd_array copies are directly cancelled by the calling thread, |
---|
762 | * using remote accesses. |
---|
763 | * 2) The memory allocated to file descriptor in cluster containing the inode is released. |
---|
764 | * It requires a RPC if cluster containing the file descriptor is remote. |
---|
765 | ****************************************************************************************** |
---|
766 | * @ file_xp : extended pointer on the file descriptor. |
---|
767 | * @ file_id : file descriptor index in fd_array. |
---|
768 | * @ returns 0 if success / -1 if error. |
---|
769 | *****************************************************************************************/ |
---|
770 | error_t vfs_close( xptr_t file_xp, |
---|
771 | uint32_t file_id ); |
---|
772 | |
---|
773 | /****************************************************************************************** |
---|
774 | * This function remove from the file system a directory entry identified by the |
---|
775 | * <cwd_xp> & <path> arguments. |
---|
776 | ****************************************************************************************** |
---|
777 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
778 | * @ path : pathname (absolute or relative to current directory). |
---|
779 | * @ returns 0 if success / -1 if error. |
---|
780 | *****************************************************************************************/ |
---|
781 | error_t vfs_unlink( xptr_t cwd_xp, |
---|
782 | char * path ); |
---|
783 | |
---|
784 | /****************************************************************************************** |
---|
785 | * This function returns, in the structure pointed by the <k_stat> kernel pointer, |
---|
786 | * various informations on the file descriptor identified by the <file_xp> argument. |
---|
787 | * TODO not implemented yet... |
---|
788 | ****************************************************************************************** |
---|
789 | * @ file_xp : extended pointer on the file descriptor of the searched directory . |
---|
790 | * @ k_dirent : local pointer on the dirent_t structure in kernel space. |
---|
791 | * @ returns 0 if success / -1 if error. |
---|
792 | *****************************************************************************************/ |
---|
793 | error_t vfs_stat( xptr_t file_xp, |
---|
794 | vfs_stat_t * k_stat ); |
---|
795 | |
---|
796 | /****************************************************************************************** |
---|
797 | * This function returns, in the structure pointed by the <k_dirent> kernel pointer, |
---|
798 | * various infos on the directory entry currently pointed by the <file_xp> file descriptor. |
---|
799 | * TODO not implemented yet... |
---|
800 | ****************************************************************************************** |
---|
801 | * @ file_xp : extended pointer on the file descriptor of the searched directory . |
---|
802 | * @ k_dirent : local pointer on the dirent_t structure in kernel space. |
---|
803 | * @ returns 0 if success / -1 if error. |
---|
804 | *****************************************************************************************/ |
---|
805 | error_t vfs_readdir( xptr_t file_xp, |
---|
806 | vfs_dirent_t * k_dirent ); |
---|
807 | |
---|
808 | /****************************************************************************************** |
---|
809 | * This function creates a new inode and associated dentry for the directory defined |
---|
810 | * by the <cwd_xp> & <path> arguments. |
---|
811 | * TODO not implemented yet... |
---|
812 | ****************************************************************************************** |
---|
813 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
814 | * @ path : pathname (absolute or relative to current directory). |
---|
815 | * @ mode : access rights (as defined by chmod) |
---|
816 | * @ returns 0 if success / -1 if error. |
---|
817 | *****************************************************************************************/ |
---|
818 | error_t vfs_mkdir( xptr_t cwd_xp, |
---|
819 | char * path, |
---|
820 | uint32_t mode ); |
---|
821 | |
---|
822 | /****************************************************************************************** |
---|
823 | * This function remove a directory identified by the <cwd_xp / path> arguments |
---|
824 | * from the file system. |
---|
825 | * TODO not implemented yet... |
---|
826 | ****************************************************************************************** |
---|
827 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
828 | * @ path : pathname (absolute or relative to current directory). |
---|
829 | * @ returns 0 if success / -1 if error. |
---|
830 | *****************************************************************************************/ |
---|
831 | error_t vfs_rmdir( xptr_t cwd_xp, |
---|
832 | char * path ); |
---|
833 | |
---|
834 | /****************************************************************************************** |
---|
835 | * This function makes the directory identified by <cwd_xp / path> arguments to become |
---|
836 | * the working directory for the calling process. |
---|
837 | ****************************************************************************************** |
---|
838 | * @ cwd_xp : extended pointer on current directory file descriptor (relative path). |
---|
839 | * @ path : file pathname (absolute or relative to current directory). |
---|
840 | * return 0 if success / -1 if error. |
---|
841 | *****************************************************************************************/ |
---|
842 | error_t vfs_chdir( xptr_t cwd_xp, |
---|
843 | char * path ); |
---|
844 | |
---|
845 | /****************************************************************************************** |
---|
846 | * This function change the access rigths for the file identified by the <cwd_xp / path> |
---|
847 | * arguments. The new access rights are defined by the <mode> argument value. |
---|
848 | ****************************************************************************************** |
---|
849 | * @ cwd_xp : extended pointer on current directory file descriptor (relative path). |
---|
850 | * @ path : file pathname (absolute or relative to current directory). |
---|
851 | * @ mode : access rights new value. |
---|
852 | * return 0 if success / -1 if error. |
---|
853 | *****************************************************************************************/ |
---|
854 | error_t vfs_chmod( xptr_t cwd_xp, |
---|
855 | char * path, |
---|
856 | uint32_t mode ); |
---|
857 | |
---|
858 | /****************************************************************************************** |
---|
859 | * This function creates a named FIFO file. |
---|
860 | * TODO not implemented yet |
---|
861 | ****************************************************************************************** |
---|
862 | * @ path : FIFO pathname (absolute or relative to current directory). |
---|
863 | * @ cwd_xp : extended pointer on the current working directory file descriptor. |
---|
864 | * @ mode : access rights new value. |
---|
865 | *****************************************************************************************/ |
---|
866 | error_t vfs_mkfifo( xptr_t cwd_xp, |
---|
867 | char * path, |
---|
868 | uint32_t mode ); |
---|
869 | |
---|
870 | |
---|
871 | /*****************************************************************************************/ |
---|
872 | /****************** Mapper access API ****************************************************/ |
---|
873 | /*****************************************************************************************/ |
---|
874 | |
---|
875 | /****************************************************************************************** |
---|
876 | * This function makes an I/O operation to move one page to/from device from/to the mapper. |
---|
877 | * It is used in case of MISS on the mapper, or when a dirty page in the mapper must |
---|
878 | * be updated in the File System. |
---|
879 | * Depending on the file system type, it calls the proper, FS specific function. |
---|
880 | * It must be executed by a thread running in the cluster containing the mapper. |
---|
881 | * The mapper pointer is obtained from the page descriptor. |
---|
882 | * It takes the mapper lock before launching the IO operation. |
---|
883 | ****************************************************************************************** |
---|
884 | * @ page : local pointer on the page descriptor. |
---|
885 | * @ to_mapper : transfer direction. |
---|
886 | * @ returns 0 if success / return EINVAL if it cannot access the external device. |
---|
887 | *****************************************************************************************/ |
---|
888 | error_t vfs_mapper_move_page( struct page_s * page, |
---|
889 | bool_t to_mapper ); |
---|
890 | |
---|
891 | /****************************************************************************************** |
---|
892 | * This function makes an I/O operation to move, from device to mapper, all pages covering |
---|
893 | * a given inode, identified by the <inode> argument. It can be a directory or a file, |
---|
894 | * but is mainly used to load (prefetch) a complete directory in the inode mapper. |
---|
895 | * Depending on the file system type, it calls the proper, FS specific function. |
---|
896 | * It must be executed by a thread running in the cluster containing the mapper. |
---|
897 | * The mapper pointer is obtained from the inode descriptor. |
---|
898 | * It takes the mapper lock before launching the IO operation. |
---|
899 | ****************************************************************************************** |
---|
900 | * @ inode : local pointer on inode. |
---|
901 | * @ return 0 if success / return EIO if device access failure. |
---|
902 | *****************************************************************************************/ |
---|
903 | error_t vfs_mapper_load_all( vfs_inode_t * inode ); |
---|
904 | |
---|
905 | |
---|
906 | |
---|
907 | /* deprecated [AG] |
---|
908 | |
---|
909 | typedef error_t (lookup_inode_t) ( vfs_inode_t * parent , |
---|
910 | vfs_dentry_t * dentry ); |
---|
911 | |
---|
912 | typedef error_t (write_inode_t) ( vfs_inode_t * inode ); |
---|
913 | |
---|
914 | typedef error_t (release_inode_t) ( vfs_inode_t * inode ); |
---|
915 | |
---|
916 | typedef error_t (unlink_inode_t) ( vfs_inode_t * parent, |
---|
917 | vfs_dentry_t * dentry, |
---|
918 | uint32_t flags ); |
---|
919 | |
---|
920 | typedef error_t (stat_inode_t) ( vfs_inode_t * inode ); |
---|
921 | |
---|
922 | typedef error_t (trunc_inode_t) ( vfs_inode_t * inode ); |
---|
923 | |
---|
924 | typedef error_t (delete_inode_t) ( vfs_inode_t * inode ); |
---|
925 | |
---|
926 | typedef struct vfs_inode_op_s |
---|
927 | { |
---|
928 | init_inode_t * init; |
---|
929 | create_inode_t * create; |
---|
930 | lookup_inode_t * lookup; |
---|
931 | write_inode_t * write; |
---|
932 | release_inode_t * release; |
---|
933 | unlink_inode_t * unlink; |
---|
934 | delete_inode_t * delete; |
---|
935 | stat_inode_t * stat; |
---|
936 | trunc_inode_t * trunc; // change the size of a file |
---|
937 | } |
---|
938 | vfs_inode_op_t; |
---|
939 | |
---|
940 | ****************************************************************************************** |
---|
941 | * These typedef define the set of FS specific operations on a VFS DENTRY descriptor. |
---|
942 | * They must be implemented by any specific file system to be supported by ALMOS_MKH. |
---|
943 | * This code is not actually used, and is only defined for documentation |
---|
944 | ****************************************************************************************** |
---|
945 | |
---|
946 | |
---|
947 | typedef error_t (vfs_compare_dentry_t) ( char * first , char * second ); |
---|
948 | |
---|
949 | typedef struct vfs_dentry_op_s |
---|
950 | { |
---|
951 | vfs_compare_dentry_t * compare; |
---|
952 | } |
---|
953 | vfs_dentry_op_t; |
---|
954 | |
---|
955 | |
---|
956 | ****************************************************************************************** |
---|
957 | * These typedef define the set of FS specific operations on FILE descriptors |
---|
958 | * They must be implemented by any specific file system to be supported by ALMOS_MKH. |
---|
959 | * This code is not actually used, and is only defined for documentation |
---|
960 | ****************************************************************************************** |
---|
961 | |
---|
962 | |
---|
963 | typedef error_t (open_file_t ) ( vfs_file_t * file, |
---|
964 | void * extend ); |
---|
965 | |
---|
966 | typedef error_t (read_file_t ) ( vfs_file_t * file, |
---|
967 | char * buffer, |
---|
968 | uint32_t count ); |
---|
969 | |
---|
970 | typedef error_t (write_file_t ) ( vfs_file_t * file, |
---|
971 | char * buffer, |
---|
972 | uint32_t count ); |
---|
973 | |
---|
974 | typedef error_t (lseek_file_t ) ( vfs_file_t * file ); |
---|
975 | |
---|
976 | typedef error_t (close_file_t ) ( vfs_file_t * file ); |
---|
977 | |
---|
978 | typedef error_t (release_file_t) ( vfs_file_t * file ); |
---|
979 | |
---|
980 | typedef error_t (read_dir_t ) ( vfs_file_t * file ); |
---|
981 | |
---|
982 | typedef error_t (mmap_file_t ) ( vfs_file_t * file , |
---|
983 | struct vseg_s * vseg ); |
---|
984 | |
---|
985 | typedef error_t (munmap_file_t ) ( vfs_file_t * file, |
---|
986 | struct vseg_s * vseg ); |
---|
987 | |
---|
988 | typedef struct vfs_file_op_s |
---|
989 | { |
---|
990 | open_file_t * open; |
---|
991 | read_file_t * read; |
---|
992 | write_file_t * write; |
---|
993 | lseek_file_t * lseek; |
---|
994 | read_dir_t * readdir; |
---|
995 | close_file_t * close; |
---|
996 | release_file_t * release; |
---|
997 | mmap_file_t * mmap; |
---|
998 | munmap_file_t * munmap; |
---|
999 | } |
---|
1000 | vfs_file_op_t; |
---|
1001 | |
---|
1002 | */ |
---|
1003 | |
---|
1004 | #endif /* _VFS_H_ */ |
---|