[1] | 1 | /* |
---|
| 2 | * vfs.h - Virtual File System definition. |
---|
| 3 | * |
---|
| 4 | * Author Mohamed Lamine Karaoui (2015) |
---|
| 5 | * Alain Greiner (2016) |
---|
| 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 <almos_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 | |
---|
| 45 | /**** Forward declarations ***/ |
---|
| 46 | |
---|
| 47 | struct vfs_inode_s; |
---|
| 48 | struct vfs_dentry_t; |
---|
| 49 | struct vfs_ctx_t; |
---|
| 50 | struct vfs_file_ref_s; |
---|
| 51 | struct vfs_file_s; |
---|
| 52 | |
---|
| 53 | struct vfs_inode_op_s; |
---|
| 54 | struct vfs_dentry_op_s; |
---|
| 55 | struct vfs_file_op_s; |
---|
| 56 | struct vfs_ctx_op_s; |
---|
| 57 | |
---|
| 58 | struct vfs_lookup_cmd_s; |
---|
| 59 | struct vfs_lookup_rsp_s; |
---|
| 60 | |
---|
| 61 | struct mapper_s; |
---|
| 62 | struct process_s; |
---|
| 63 | struct device_s; |
---|
| 64 | struct vseg_s; |
---|
| 65 | |
---|
| 66 | /********************************************************************************************* |
---|
| 67 | * This defines the various Flags arguments for an open() or opendir() system call. |
---|
| 68 | ********************************************************************************************/ |
---|
| 69 | |
---|
| 70 | #define VFS_O_APPEND 0x00080000 |
---|
| 71 | #define VFS_O_RDONLY 0x00100000 |
---|
| 72 | #define VFS_O_WRONLY 0x00200000 |
---|
| 73 | #define VFS_O_RDWR 0x00300000 |
---|
| 74 | #define VFS_O_CREATE 0x00400000 |
---|
| 75 | #define VFS_O_EXCL 0x00800000 |
---|
| 76 | #define VFS_O_TRUNC 0x01000000 |
---|
| 77 | #define VFS_O_SYNC 0x08000000 |
---|
| 78 | |
---|
| 79 | /********************************************************************************************* |
---|
| 80 | * This defines the various types of command for an lseek() system call. |
---|
| 81 | ********************************************************************************************/ |
---|
| 82 | |
---|
| 83 | #define VFS_SEEK_SET 0 |
---|
| 84 | #define VFS_SEEK_CUR 1 |
---|
| 85 | #define VFS_SEEK_END 2 |
---|
| 86 | |
---|
| 87 | /********************************************************************************************* |
---|
| 88 | * TODO : the following flags were defined in the vfs-params.h file... |
---|
| 89 | * ... and must be documented. [AG] |
---|
| 90 | ********************************************************************************************/ |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | ////////////////////////////////////// |
---|
| 94 | /// keep these flags compact /// |
---|
| 95 | ////////////////////////////////////// |
---|
| 96 | #define VFS_REGFILE 0x0000000 |
---|
| 97 | #define VFS_DIR 0x0000001 |
---|
| 98 | #define VFS_FIFO 0x0000002 |
---|
| 99 | #define VFS_DEV_CHR 0x0000004 |
---|
| 100 | #define VFS_DEV_BLK 0x0000008 |
---|
| 101 | #define VFS_DEV 0x000000C |
---|
| 102 | #define VFS_SOCK 0x0000010 |
---|
| 103 | #define VFS_SYMLNK 0x0000020 |
---|
| 104 | ////////////////////////////////////// |
---|
| 105 | |
---|
| 106 | #define VFS_RD_ONLY 0x0000040 |
---|
| 107 | #define VFS_SYS 0x0000080 |
---|
| 108 | #define VFS_ARCHIVE 0x0000100 |
---|
| 109 | #define VFS_PIPE 0x0000200 |
---|
| 110 | |
---|
| 111 | #define VFS_IFMT 0x0170000 |
---|
| 112 | #define VFS_IFSOCK 0x0140000 |
---|
| 113 | #define VFS_IFLNK 0x0120000 |
---|
| 114 | #define VFS_IFREG 0x0100000 |
---|
| 115 | #define VFS_IFBLK 0x0060000 |
---|
| 116 | #define VFS_IFDIR 0x0040000 |
---|
| 117 | #define VFS_IFCHR 0x0020000 |
---|
| 118 | #define VFS_IFIFO 0x0010000 |
---|
| 119 | |
---|
| 120 | #define VFS_ISUID 0x0004000 |
---|
| 121 | #define VFS_ISGID 0x0002000 |
---|
| 122 | #define VFS_ISVTX 0x0001000 |
---|
| 123 | |
---|
| 124 | #define VFS_IRWXU 0x0000700 |
---|
| 125 | #define VFS_IRUSR 0x0000400 |
---|
| 126 | #define VFS_IWUSR 0x0000200 |
---|
| 127 | #define VFS_IXUSR 0x0000100 |
---|
| 128 | #define VFS_IRWXG 0x0000070 |
---|
| 129 | #define VFS_IRGRP 0x0000040 |
---|
| 130 | #define VFS_IWGRP 0x0000020 |
---|
| 131 | #define VFS_IXGRP 0x0000010 |
---|
| 132 | #define VFS_IRWXO 0x0000007 |
---|
| 133 | #define VFS_IROTH 0x0000004 |
---|
| 134 | #define VFS_IWOTH 0x0000002 |
---|
| 135 | #define VFS_IXOTH 0x0000001 |
---|
| 136 | |
---|
| 137 | #define VFS_IREAD VFS_IRUSR |
---|
| 138 | #define VFS_IWRITE VFS_IWUSR |
---|
| 139 | #define VFS_IEXEC VFS_IXUSR |
---|
| 140 | |
---|
| 141 | #define VFS_SET(state,flag) (state) |= (flag) |
---|
| 142 | #define VFS_IS(state,flag) (state) & (flag) |
---|
| 143 | #define VFS_CLEAR(state,flag) (state) &= ~(flag) |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | /* Lookup flags */ |
---|
| 147 | #define VFS_LOOKUP_FILE 0x1 |
---|
| 148 | #define VFS_LOOKUP_LAST 0x2 |
---|
| 149 | #define VFS_LOOKUP_OPEN 0x4 |
---|
| 150 | #define VFS_LOOKUP_RESTART 0x8 |
---|
| 151 | #define VFS_LOOKUP_RETRY 0x10 |
---|
| 152 | #define VFS_LOOKUP_PARENT 0x20 |
---|
| 153 | #define VFS_LOOKUP_HELD 0x40 |
---|
| 154 | |
---|
| 155 | /* Context flags*/ |
---|
| 156 | #define VFS_FS_LOCAL 0x1 |
---|
| 157 | #define VFS_FS_USE_MAPPER 0x2 |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | /****************************************************************************************** |
---|
| 163 | * This structure define a VFS inode. |
---|
| 164 | * It contains an extended pointer on the parent dentry, and (for directory only) |
---|
| 165 | * an hash table xhtab refering all children dentries. |
---|
| 166 | * The <parent> inode is unique for a directory (not hard links for directories). |
---|
| 167 | * For a file, the parent field points to the first dentry who created this inode. |
---|
| 168 | * TODO pourquoi deux types de locks ??? |
---|
| 169 | *****************************************************************************************/ |
---|
| 170 | |
---|
| 171 | typedef enum |
---|
| 172 | { |
---|
| 173 | INODE_ATTR_DIRTY = 0x01, |
---|
| 174 | INODE_ATTR_DIR = 0x02, |
---|
| 175 | INODE_ATTR_INLOAD = 0x04, |
---|
| 176 | INODE_ATTR_NEW = 0x08, |
---|
| 177 | } |
---|
| 178 | inode_attr_t; |
---|
| 179 | |
---|
| 180 | typedef struct vfs_inode_s |
---|
| 181 | { |
---|
| 182 | struct vfs_ctx_s * ctx; /*! Rlocal pointer on FS context */ |
---|
| 183 | uint32_t gc; /*! generation counter */ |
---|
| 184 | uint32_t inum; /*! inode identifier (unique in file system) */ |
---|
| 185 | uint32_t attr; /*! inode attributes (see above) */ |
---|
| 186 | uint32_t size; /*! number of bytes */ |
---|
| 187 | uint32_t links; /*! number of alias dentry */ |
---|
| 188 | uid_t uid; /*! user owner identifier */ |
---|
| 189 | gid_t gid; /*! group owner identifier */ |
---|
| 190 | uint32_t mode; /*! access mode */ |
---|
| 191 | uint32_t refcount; /*! reference counter (all pointers) */ |
---|
| 192 | xptr_t parent_xp; /*! extended pointer on parent dentry */ |
---|
| 193 | xhtab_t children; /*! embedded htab of dir entries (for dir type) */ |
---|
| 194 | remote_rwlock_t size_lock; /*! protect size field modifications */ |
---|
| 195 | remote_spinlock_t main_lock; /*! protect other fields (including children) */ |
---|
| 196 | xlist_entry_t xlist; /*! member of set of inodes in same cluster */ |
---|
| 197 | xlist_entry_t wait_root; /*! root of threads waiting on this inode */ |
---|
| 198 | struct vfs_inode_op_s * op; /*! TODO ??? */ |
---|
| 199 | struct mapper_s * mapper; /*! associated file cache */ |
---|
| 200 | void * extend; /*! FS specific inode extension */ |
---|
| 201 | } |
---|
| 202 | vfs_inode_t; |
---|
| 203 | |
---|
| 204 | /****************************************************************************************** |
---|
| 205 | * This structure defines a directory entry. |
---|
| 206 | * A dentry contains the name of a remote file/dir, an extended pointer on the |
---|
| 207 | * inode representing this file/dir, and a local pointer on the inode representing |
---|
| 208 | * the parent directory. |
---|
| 209 | *****************************************************************************************/ |
---|
| 210 | |
---|
| 211 | typedef struct vfs_dentry_s |
---|
| 212 | { |
---|
| 213 | struct vfs_ctx_s * ctx; /*! local pointer on FS context */ |
---|
| 214 | char name[CONFIG_VFS_MAX_NAME_LENGTH]; |
---|
| 215 | uint32_t length; /*! name length (bytes) */ |
---|
| 216 | uint32_t refcount; /*! reference counter (all pointers) */ |
---|
| 217 | struct vfs_inode_s * parent; /*! local pointer on parent inode */ |
---|
| 218 | xptr_t child_xp; /*! extended pointer on child inode */ |
---|
| 219 | xlist_entry_t xlist; /*! member of xlist of dentries with same key */ |
---|
| 220 | struct vfs_dentry_op_s * op; /*! TODO */ |
---|
| 221 | void * extend; /*! FS specific extension */ |
---|
| 222 | } |
---|
| 223 | vfs_dentry_t; |
---|
| 224 | |
---|
| 225 | /****************************************************************************************** |
---|
| 226 | * This structure describes an open file/directory for a given process. |
---|
| 227 | * It is not replicated, and is dynamically allocated in the cluster that contains |
---|
| 228 | * the inode, when a thread makes an open() or opendir() system call. |
---|
| 229 | *****************************************************************************************/ |
---|
| 230 | |
---|
| 231 | typedef enum |
---|
| 232 | { |
---|
| 233 | VFS_FD_NORMAL, /*! file or directory */ |
---|
| 234 | VFS_FD_PIPE, /*! POSIX pipe */ |
---|
| 235 | VFS_FD_SOCKET, /*! POSIX socket */ |
---|
| 236 | VFS_FD_DEV, /*! peripheral channel */ |
---|
| 237 | } |
---|
| 238 | vfs_fd_type_t; |
---|
| 239 | |
---|
| 240 | typedef enum |
---|
| 241 | { |
---|
| 242 | VFS_ATTR_READ_ENABLE = 0x01, /*! read access possible */ |
---|
| 243 | VFS_ATTR_WRITE_ENABLE = 0x02, /*! write access possible */ |
---|
| 244 | VFS_ATTR_APPEND = 0x04, /*! append on each write */ |
---|
| 245 | VFS_ATTR_CLOSE_EXEC = 0x08, /*! close file on exec */ |
---|
| 246 | VFS_ATTR_SYNC = 0x10, /*! synchronise FS on each write */ |
---|
| 247 | VFS_ATTR_IS_DIR = 0x20, /*! this is a directory */ |
---|
| 248 | } |
---|
| 249 | vfs_fd_attr_t; |
---|
| 250 | |
---|
| 251 | typedef struct vfs_file_s |
---|
| 252 | { |
---|
| 253 | uint32_t gc; /*! generation counter */ |
---|
| 254 | uint32_t type; /*! see above */ |
---|
| 255 | uint32_t attr; /*! see above */ |
---|
| 256 | uint32_t offset; /*! seek position in file */ |
---|
| 257 | uint32_t refcount; /*! all pointers on this file */ |
---|
| 258 | remote_rwlock_t lock; /*! protect offset modifications */ |
---|
| 259 | struct mapper_s * mapper; /*! associated file cache */ |
---|
| 260 | struct vfs_inode_s * inode; /*! local pointer on associated inode */ |
---|
| 261 | struct vfs_ctx_s * ctx; /*! file system features */ |
---|
| 262 | struct vfs_file_op_s * op; /*! local set of function pointers */ |
---|
| 263 | } |
---|
| 264 | vfs_file_t; |
---|
| 265 | |
---|
| 266 | /****************************************************************************************** |
---|
| 267 | * This structure defines informations common to all inodes and dentries |
---|
| 268 | * of a given file system. As it is declared a global variable in the kdata segment, |
---|
| 269 | * it is replicated in all clusters and handled as private by each OS intance. |
---|
| 270 | *****************************************************************************************/ |
---|
| 271 | |
---|
| 272 | typedef enum |
---|
| 273 | { |
---|
| 274 | FS_TYPE_SYSFS = 0, |
---|
| 275 | FS_TYPE_DEVFS = 1, |
---|
| 276 | FS_TYPE_FATFS = 2, |
---|
| 277 | FS_TYPE_RAMFS = 3, |
---|
| 278 | |
---|
| 279 | FS_TYPES_NR = 4, |
---|
| 280 | } |
---|
| 281 | vfs_types_t; |
---|
| 282 | |
---|
| 283 | typedef struct vfs_ctx_s |
---|
| 284 | { |
---|
| 285 | uint32_t type; /*! File System type */ |
---|
| 286 | uint32_t flags; /*! TODO ??? */ |
---|
| 287 | uint32_t count; /*! number of clusters */ |
---|
| 288 | uint32_t blksize; /*! cluster size */ |
---|
| 289 | xptr_t ioc_xp; /*! extended pointer on IOC device */ |
---|
| 290 | xptr_t root_xp; /*! extended pointer on root inode */ |
---|
| 291 | |
---|
| 292 | spinlock_t lock; /*! lock protecting inum allocator */ |
---|
| 293 | BITMAP( inum , CONFIG_VFS_MAX_INODES ); /*! inum allocator */ |
---|
| 294 | |
---|
| 295 | void * extend; /*! FS specific context extension */ |
---|
| 296 | } |
---|
| 297 | vfs_ctx_t; |
---|
| 298 | |
---|
| 299 | /****************************************************************************************** |
---|
| 300 | * This structure define the informations associated to a given file descriptor, |
---|
| 301 | * that are returned by the vfs_stat() function. |
---|
| 302 | *****************************************************************************************/ |
---|
| 303 | |
---|
| 304 | typedef struct vfs_stat_s |
---|
| 305 | { |
---|
| 306 | uint32_t dev; /*! ID of device containing file */ |
---|
| 307 | uint32_t ino; /*! inode number */ |
---|
| 308 | uint32_t mode; /*! protection */ |
---|
| 309 | uint32_t nlink; /*! number of hard links */ |
---|
| 310 | uint32_t uid; /*! user ID of owner */ |
---|
| 311 | uint32_t gid; /*! group ID of owner */ |
---|
| 312 | uint32_t rdev; /*! device ID (if special file) */ |
---|
| 313 | uint64_t size; /*! total size, in bytes */ |
---|
| 314 | uint32_t blksize; /*! blocksize for file system I/O */ |
---|
| 315 | uint32_t blocks; /*! number of 512B blocks allocated */ |
---|
| 316 | uint64_t atime; /*! time of last access */ |
---|
| 317 | uint64_t mtime; /*! time of last modification */ |
---|
| 318 | uint64_t ctime; /*! time of last status change */ |
---|
| 319 | } |
---|
| 320 | vfs_stat_t; |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | |
---|
| 324 | |
---|
| 325 | |
---|
| 326 | |
---|
| 327 | /****************************************************************************************** |
---|
| 328 | * This structure defines the set of operations that can be done on a VFS context. |
---|
| 329 | * TODO A quoi cela sert-il ? [AG] |
---|
| 330 | *****************************************************************************************/ |
---|
| 331 | |
---|
| 332 | typedef error_t (vfs_create_context_t) ( vfs_ctx_t * context ); |
---|
| 333 | typedef error_t (vfs_destroy_context_t) ( vfs_ctx_t * context ); |
---|
| 334 | typedef error_t (vfs_read_root_t) ( vfs_ctx_t * context , vfs_inode_t * root ); |
---|
| 335 | typedef error_t (vfs_reply_root_t) ( vfs_ctx_t * context , vfs_inode_t * root ); |
---|
| 336 | typedef error_t (vfs_write_root_t) ( vfs_ctx_t * context , vfs_inode_t * root ); |
---|
| 337 | |
---|
| 338 | struct vfs_ctx_op_s |
---|
| 339 | { |
---|
| 340 | vfs_create_context_t * create; /*! allocate memory and initialize a context */ |
---|
| 341 | vfs_destroy_context_t * destroy; /*! release memory allocated to a context */ |
---|
| 342 | vfs_read_root_t * read_root; /*! TODO */ |
---|
| 343 | vfs_reply_root_t * repli_root; /*! TODO */ |
---|
| 344 | vfs_write_root_t * write_root; /*! TODO */ |
---|
| 345 | } |
---|
| 346 | vfs_ctx_op_t; |
---|
| 347 | |
---|
| 348 | /****************************************************************************************** |
---|
| 349 | * This structure defines the set of operations that can be done on a VFS inode. |
---|
| 350 | * TODO A quoi cela sert-il ? [AG] |
---|
| 351 | *****************************************************************************************/ |
---|
| 352 | |
---|
| 353 | typedef error_t (vfs_init_inode_t) ( vfs_inode_t * inode ); |
---|
| 354 | typedef error_t (vfs_create_inode_t) ( vfs_inode_t * parent , vfs_dentry_t * dentry ); |
---|
| 355 | typedef error_t (vfs_lookup_inode_t) ( vfs_inode_t * parent , vfs_dentry_t * dentry ); |
---|
| 356 | typedef error_t (vfs_write_inode_t) ( vfs_inode_t * inode ); |
---|
| 357 | typedef error_t (vfs_release_inode_t) ( vfs_inode_t * inode ); |
---|
| 358 | typedef error_t (vfs_unlink_inode_t) ( vfs_inode_t * parent , vfs_dentry_t * dentry , uint32_t flags ); |
---|
| 359 | typedef error_t (vfs_stat_inode_t) ( vfs_inode_t * inode ); |
---|
| 360 | typedef error_t (vfs_trunc_inode_t) ( vfs_inode_t * inode ); |
---|
| 361 | typedef error_t (vfs_delete_inode_t) ( vfs_inode_t * inode ); |
---|
| 362 | |
---|
| 363 | typedef struct vfs_inode_op_s |
---|
| 364 | { |
---|
| 365 | vfs_init_inode_t * init; /*! initialise inode from scratch */ |
---|
| 366 | vfs_create_inode_t * create; /*! allocate memory for one inode */ |
---|
| 367 | vfs_lookup_inode_t * lookup; /*! get one directory entry by name */ |
---|
| 368 | vfs_write_inode_t * write; /*! update the device from the inode */ |
---|
| 369 | vfs_release_inode_t * release; /*! reset one inode and release associated objects */ |
---|
| 370 | vfs_unlink_inode_t * unlink; /*! unlink a directory entry from parent inode */ |
---|
| 371 | vfs_delete_inode_t * delete; /*! release memory allocated to inode when count = 0 */ |
---|
| 372 | vfs_stat_inode_t * stat; /*! TODO */ |
---|
| 373 | vfs_trunc_inode_t * trunc; /*! change the size of a file */ |
---|
| 374 | } |
---|
| 375 | vfs_inode_op_t; |
---|
| 376 | |
---|
| 377 | /****************************************************************************************** |
---|
| 378 | * This structure defines the set of operations that can be done on a VFS dentry. |
---|
| 379 | * TODO A quoi cela sert-il ? [AG] |
---|
| 380 | *****************************************************************************************/ |
---|
| 381 | |
---|
| 382 | typedef error_t (vfs_compare_dentry_t) ( char * first , char * second ); |
---|
| 383 | |
---|
| 384 | typedef struct vfs_dentry_op_s |
---|
| 385 | { |
---|
| 386 | vfs_compare_dentry_t * compare; |
---|
| 387 | } |
---|
| 388 | vfs_dentry_op_t; |
---|
| 389 | |
---|
| 390 | /****************************************************************************************** |
---|
| 391 | * This structure defines the set of operations that can be done on a VFS file. |
---|
| 392 | * TODO A quoi cela sert-il ? [AG] |
---|
| 393 | *****************************************************************************************/ |
---|
| 394 | |
---|
| 395 | typedef error_t (vfs_open_file_t) ( vfs_file_t * file , void * priv ); |
---|
| 396 | typedef error_t (vfs_read_file_t) ( vfs_file_t * file , char * buffer ); |
---|
| 397 | typedef error_t (vfs_write_file_t) ( vfs_file_t * file , char * buffer ); |
---|
| 398 | typedef error_t (vfs_lseek_file_t) ( vfs_file_t * file ); |
---|
| 399 | typedef error_t (vfs_close_file_t) ( vfs_file_t * file ); |
---|
| 400 | typedef error_t (vfs_release_file_t) ( vfs_file_t * file ); |
---|
| 401 | typedef error_t (vfs_read_dir_t) ( vfs_file_t * file ); |
---|
| 402 | typedef error_t (vfs_mmap_file_t) ( vfs_file_t * file , struct vseg_s * vseg ); |
---|
| 403 | typedef error_t (vfs_munmap_file_t) ( vfs_file_t * file , struct vseg_s * vseg ); |
---|
| 404 | |
---|
| 405 | typedef struct vfs_file_op_s |
---|
| 406 | { |
---|
| 407 | vfs_open_file_t * open; |
---|
| 408 | vfs_read_file_t * read; |
---|
| 409 | vfs_write_file_t * write; |
---|
| 410 | vfs_lseek_file_t * lseek; |
---|
| 411 | vfs_read_dir_t * readdir; |
---|
| 412 | vfs_close_file_t * close; |
---|
| 413 | vfs_release_file_t * release; |
---|
| 414 | vfs_mmap_file_t * mmap; |
---|
| 415 | vfs_munmap_file_t * munmap; |
---|
| 416 | } |
---|
| 417 | vfs_file_op_t; |
---|
| 418 | |
---|
| 419 | |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | |
---|
| 423 | |
---|
| 424 | /*****************************************************************************************/ |
---|
| 425 | /******************** VFS global functions ***********************************************/ |
---|
| 426 | /*****************************************************************************************/ |
---|
| 427 | |
---|
| 428 | /****************************************************************************************** |
---|
| 429 | * This function initializes the Virtual File System. |
---|
| 430 | *****************************************************************************************/ |
---|
| 431 | void vfs_init(); |
---|
| 432 | |
---|
| 433 | /****************************************************************************************** |
---|
| 434 | * This function mount a given file system type for a given process. |
---|
| 435 | *****************************************************************************************/ |
---|
| 436 | error_t vfs_mount_fs_root( struct device_s * device, |
---|
| 437 | uint32_t fs_type, |
---|
| 438 | struct process_s * process ); |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | /*****************************************************************************************/ |
---|
| 442 | /******************* FS Context related functions ****************************************/ |
---|
| 443 | /*****************************************************************************************/ |
---|
| 444 | |
---|
| 445 | /****************************************************************************************** |
---|
| 446 | * This function allocates an inode identifier from the local cluster inum allocator. |
---|
| 447 | * The inum respects a fixed format: |
---|
| 448 | * - the 16 MSB bits contain the cluster identifier : cxy |
---|
| 449 | * - the 16 LSB bits contains the local inode identifier : lid |
---|
| 450 | ****************************************************************************************** |
---|
| 451 | * @ ctx : local pointer on file system context. |
---|
| 452 | * @ inum : [ou] buffer for allocated inode identifier. |
---|
| 453 | * @ return 0 if success / return non-zero if error. |
---|
| 454 | *****************************************************************************************/ |
---|
| 455 | error_t vfs_ctx_inum_alloc( vfs_ctx_t * ctx, |
---|
| 456 | uint32_t * inum ); |
---|
| 457 | |
---|
| 458 | /****************************************************************************************** |
---|
| 459 | * This function release an inode identifier. |
---|
| 460 | ****************************************************************************************** |
---|
| 461 | * @ ctx : local pointer on file system context. |
---|
| 462 | * @ inum : released inode identifier. |
---|
| 463 | *****************************************************************************************/ |
---|
| 464 | void vfs_ctx_inum_release( vfs_ctx_t * ctx, |
---|
| 465 | uint32_t inum ); |
---|
| 466 | |
---|
| 467 | |
---|
| 468 | |
---|
| 469 | /*****************************************************************************************/ |
---|
| 470 | /************************ File Descriptor related functions ******************************/ |
---|
| 471 | /*****************************************************************************************/ |
---|
| 472 | |
---|
| 473 | /****************************************************************************************** |
---|
| 474 | * This function allocates memory and initializes a new local file descriptor. |
---|
| 475 | * It must be executed in the owner cluster containing the inode. |
---|
| 476 | * If the client thread is not running in the owner cluster, it must use the |
---|
| 477 | * rpc_vfs_file_create_client() function. |
---|
| 478 | ****************************************************************************************** |
---|
| 479 | * @ inode_xp : extended pointer on associated inode. |
---|
| 480 | * @ type : file descriptor type. |
---|
| 481 | * @ attr : file descriptor attributes. |
---|
| 482 | * @ file_xp : [out] buffer for extended pointer on created file descriptor. |
---|
| 483 | * @ return 0 if success / return ENOMEM if error. |
---|
| 484 | *****************************************************************************************/ |
---|
| 485 | error_t vfs_file_create( xptr_t inode_xp, |
---|
| 486 | uint32_t type, |
---|
| 487 | uint32_t attr, |
---|
| 488 | xptr_t * file_xp ); |
---|
| 489 | |
---|
| 490 | /****************************************************************************************** |
---|
| 491 | * This function releases memory allocated to a local file descriptor. |
---|
| 492 | * It must be executed by a thread running in the cluster containing the inode, |
---|
| 493 | * and the file refcount must be zero. |
---|
| 494 | * If the client thread is not running in the owner cluster, it must use the |
---|
| 495 | * rpc_vfs_file_destroy_client() function. |
---|
| 496 | ****************************************************************************************** |
---|
| 497 | * @ file_xp : extended pointer on file descriptor. |
---|
| 498 | *****************************************************************************************/ |
---|
| 499 | void vfs_file_destroy( xptr_t file_xp ); |
---|
| 500 | |
---|
| 501 | |
---|
| 502 | /****************************************************************************************** |
---|
| 503 | * These functions increment (resp. decrement) the count field in a remote file |
---|
| 504 | * descriptor, using a remote_atomic access. |
---|
| 505 | *****************************************************************************************/ |
---|
| 506 | void vfs_file_count_up ( xptr_t file_xp ); |
---|
| 507 | void vfs_file_count_down( xptr_t file_xp ); |
---|
| 508 | |
---|
| 509 | |
---|
| 510 | |
---|
| 511 | /*****************************************************************************************/ |
---|
| 512 | /********************* Inode related functions *******************************************/ |
---|
| 513 | /*****************************************************************************************/ |
---|
| 514 | |
---|
| 515 | /****************************************************************************************** |
---|
| 516 | * This function allocates memory from local cluster for an inode descriptor and the |
---|
| 517 | * associated mapper. It initialise these descriptors from arguments values. |
---|
| 518 | * The parent dentry must have been previously created. |
---|
| 519 | * If the client thread is not running in the cluster containing this inode, |
---|
| 520 | * it must use the rpc_vfs_inode_create_client() function. |
---|
| 521 | ****************************************************************************************** |
---|
| 522 | * @ dentry_xp : extended pointer on associated dentry (in parent inode cluster). |
---|
| 523 | * @ type : file system type. |
---|
| 524 | * @ attr : inode attributes. |
---|
| 525 | * @ mode : inode access mode. |
---|
| 526 | * @ uid : user owner ID. |
---|
| 527 | * @ gid : group owner ID. |
---|
| 528 | * @ inode_xp : [out] buffer for extended pointer on created inode. |
---|
| 529 | * # return 0 if success / return ENOMEM or EINVAL if error. |
---|
| 530 | *****************************************************************************************/ |
---|
| 531 | error_t vfs_inode_create( xptr_t dentry_xp, |
---|
| 532 | uint32_t type, |
---|
| 533 | uint32_t attr, |
---|
| 534 | uint32_t mode, |
---|
| 535 | uid_t uid, |
---|
| 536 | gid_t gid, |
---|
| 537 | xptr_t * inode_xp ); |
---|
| 538 | |
---|
| 539 | /****************************************************************************************** |
---|
| 540 | * This function releases memory allocated to an inode descriptor. |
---|
| 541 | * It must be executed by a thread running in the cluster containing the inode, |
---|
| 542 | * and the inode refcount must be zero. |
---|
| 543 | * If the client thread is not running in the owner cluster, it must use the |
---|
| 544 | * rpc_vfs_inode_destroy_client() function. |
---|
| 545 | ****************************************************************************************** |
---|
| 546 | * @ inode : local pointer on inode descriptor. |
---|
| 547 | *****************************************************************************************/ |
---|
| 548 | void vfs_inode_destroy( vfs_inode_t * inode ); |
---|
| 549 | |
---|
| 550 | /****************************************************************************************** |
---|
| 551 | * This function atomically increment the inode refcount. |
---|
| 552 | * It can be called by any thread running in any cluster. |
---|
| 553 | *****************************************************************************************/ |
---|
| 554 | void vfs_inode_remote_up( xptr_t inode_xp ); |
---|
| 555 | |
---|
| 556 | /****************************************************************************************** |
---|
| 557 | * This function atomically decrement the inode refcount. |
---|
| 558 | * It can be called by any thread running in any cluster. |
---|
| 559 | *****************************************************************************************/ |
---|
| 560 | void vfs_inode_remote_down( xptr_t inode_xp ); |
---|
| 561 | |
---|
| 562 | /****************************************************************************************** |
---|
| 563 | * This function returns the <size> of a file/dir from a remote inode, |
---|
| 564 | * taking the remote_rwlock protecting <size> in READ_MODE. |
---|
| 565 | ***************************************************************************************** |
---|
| 566 | * @ inode_xp : extended pointer on the remote inode. |
---|
| 567 | * @ return the current size. |
---|
| 568 | *****************************************************************************************/ |
---|
| 569 | uint32_t vfs_inode_get_size( xptr_t inode_xp ); |
---|
| 570 | |
---|
| 571 | /****************************************************************************************** |
---|
| 572 | * This function set the <size> of a file/dir to a remote inode, |
---|
| 573 | * taking the remote_rwlock protecting <size> in WRITE_MODE. |
---|
| 574 | ***************************************************************************************** |
---|
| 575 | * @ inode_xp : extended pointer on the remote inode. |
---|
| 576 | * @ size : value to be written. |
---|
| 577 | *****************************************************************************************/ |
---|
| 578 | void vfs_inode_set_size( xptr_t inode_xp, |
---|
| 579 | uint32_t size ); |
---|
| 580 | |
---|
| 581 | /****************************************************************************************** |
---|
| 582 | * This function takes the main lock of a remote inode. |
---|
| 583 | * This lock protect all inode fiels, including the children dentries. |
---|
| 584 | ***************************************************************************************** |
---|
| 585 | * @ inode_xp : extended pointer on the remote inode. |
---|
| 586 | *****************************************************************************************/ |
---|
| 587 | void vfs_inode_remote_lock( xptr_t inode_xp ); |
---|
| 588 | |
---|
| 589 | /****************************************************************************************** |
---|
| 590 | * This function releases the main lock of a remote inode. |
---|
| 591 | * This lock protect all inode fiels, including the children dentries. |
---|
| 592 | ***************************************************************************************** |
---|
| 593 | * @ inode_xp : extended pointer on the remote inode. |
---|
| 594 | *****************************************************************************************/ |
---|
| 595 | void vfs_inode_remote_unlock( xptr_t inode_xp ); |
---|
| 596 | |
---|
| 597 | |
---|
| 598 | |
---|
| 599 | |
---|
| 600 | /****************************************************************************************** |
---|
| 601 | * This function TODO |
---|
| 602 | *****************************************************************************************/ |
---|
| 603 | error_t vfs_inode_hold( vfs_inode_t * inode, |
---|
| 604 | uint32_t gc ); |
---|
| 605 | |
---|
| 606 | /****************************************************************************************** |
---|
| 607 | * This function TODO |
---|
| 608 | *****************************************************************************************/ |
---|
| 609 | error_t vfs_inode_trunc( vfs_inode_t * inode ); |
---|
| 610 | |
---|
| 611 | /****************************************************************************************** |
---|
| 612 | * This function TODO |
---|
| 613 | *****************************************************************************************/ |
---|
| 614 | error_t vfs_inode_link( vfs_inode_t * inode, |
---|
| 615 | uint32_t igc ); |
---|
| 616 | |
---|
| 617 | /****************************************************************************************** |
---|
| 618 | * This function TODO |
---|
| 619 | *****************************************************************************************/ |
---|
| 620 | error_t vfs_inode_unlink( vfs_inode_t * inode ); |
---|
| 621 | |
---|
| 622 | /****************************************************************************************** |
---|
| 623 | * This function TODO |
---|
| 624 | *****************************************************************************************/ |
---|
| 625 | error_t vfs_inode_stat( vfs_inode_t * inode, |
---|
| 626 | uint32_t inum ); |
---|
| 627 | |
---|
| 628 | /****************************************************************************************** |
---|
| 629 | * This function TODO |
---|
| 630 | *****************************************************************************************/ |
---|
| 631 | error_t vfs_icache_del( vfs_inode_t * inode ); |
---|
| 632 | |
---|
| 633 | |
---|
| 634 | /****************************************************************************************** |
---|
| 635 | * This function TODO Pourquoi 2 arguments ? |
---|
| 636 | *****************************************************************************************/ |
---|
| 637 | error_t vfs_stat_inode( vfs_inode_t * inode, |
---|
| 638 | uint32_t inum ); |
---|
| 639 | |
---|
| 640 | |
---|
| 641 | /*****************************************************************************************/ |
---|
| 642 | /***************** Dentry related functions **********************************************/ |
---|
| 643 | /*****************************************************************************************/ |
---|
| 644 | |
---|
| 645 | /****************************************************************************************** |
---|
| 646 | * This function allocates memory from local cluster for a dentry descriptor, |
---|
| 647 | * initialises it from arguments values, and returns the extended pointer on dentry. |
---|
| 648 | * The inode field is not initialized, because the inode does not exist yet. |
---|
| 649 | * If the client thread is not running in the target cluster for this inode, |
---|
| 650 | * it must use the rpc_dentry_create_client() function. |
---|
| 651 | ****************************************************************************************** |
---|
| 652 | * @ type : file system type. |
---|
| 653 | * @ name : directory entry file/dir name. |
---|
| 654 | * @ parent : local pointer on parent inode. |
---|
| 655 | * @ dentry_xp : [out] buffer for extended pointer on created inode. |
---|
| 656 | * @ return 0 if success / return ENOMEM or EINVAL if error. |
---|
| 657 | *****************************************************************************************/ |
---|
| 658 | error_t vfs_dentry_create( uint32_t type, |
---|
| 659 | char * name, |
---|
| 660 | vfs_inode_t * parent, |
---|
| 661 | xptr_t * dentry_xp ); |
---|
| 662 | |
---|
| 663 | /****************************************************************************************** |
---|
| 664 | * This function releases memory allocated to a dentry descriptor. |
---|
| 665 | * It must be executed by a thread running in the cluster containing the dentry, |
---|
| 666 | * and the dentry refcount must be zero. |
---|
| 667 | * If the client thread is not running in the owner cluster, it must use the |
---|
| 668 | * rpc_dentry_destroy_client() function. |
---|
| 669 | ****************************************************************************************** |
---|
| 670 | * @ dentry : local pointer on dentry descriptor. |
---|
| 671 | *****************************************************************************************/ |
---|
| 672 | void vfs_dentry_destroy( vfs_dentry_t * dentry ); |
---|
| 673 | |
---|
| 674 | /****************************************************************************************** |
---|
| 675 | * This function atomically increment the dentry refcount. |
---|
| 676 | * It can be called by any thread running in any cluster. |
---|
| 677 | *****************************************************************************************/ |
---|
| 678 | void vfs_dentry_remote_up( xptr_t dentry_xp ); |
---|
| 679 | |
---|
| 680 | /****************************************************************************************** |
---|
| 681 | * This function atomically decrement the dentry refcount. |
---|
| 682 | * It can be called by any thread running in any cluster. |
---|
| 683 | *****************************************************************************************/ |
---|
| 684 | void vfs_dentry_remote_down( xptr_t dentry_xp ); |
---|
| 685 | |
---|
| 686 | |
---|
| 687 | /*****************************************************************************************/ |
---|
| 688 | /* Inode-Tree related functions */ |
---|
| 689 | /*****************************************************************************************/ |
---|
| 690 | |
---|
| 691 | /****************************************************************************************** |
---|
| 692 | * This function returns in a kernel buffer allocated by the caller function, |
---|
| 693 | * the pathname of a file/dir identified by an extended pointer on the inode. |
---|
| 694 | * It traverse the Inode Tree from the target node to the root. |
---|
| 695 | * It can be called by any thread running in any cluster. |
---|
| 696 | ****************************************************************************************** |
---|
| 697 | * @ inode_xp : pointer on inode descriptor. |
---|
| 698 | * @ buffer : kernel buffer for pathname (must be allocated by caller). |
---|
| 699 | * @ size : max number of characters in buffer. |
---|
| 700 | * @ return 0 if success / return EINVAL if buffer too small. |
---|
| 701 | *****************************************************************************************/ |
---|
| 702 | error_t vfs_get_path( xptr_t inode_xp, |
---|
| 703 | char * buffer, |
---|
| 704 | uint32_t max_size ); |
---|
| 705 | |
---|
| 706 | /****************************************************************************************** |
---|
| 707 | * This function takes a pathname (absolute or relative to cwd) and returns an extended |
---|
| 708 | * pointer on the associated inode, and an extended pointer on the inode context. |
---|
| 709 | * If a given name in the path is not found in the inode tree, it try to load the missing |
---|
| 710 | * dentry/inode couple, from informations found in the parent directory. |
---|
| 711 | * If this directory entry does not exist on device, it returns an error. |
---|
| 712 | ****************************************************************************************** |
---|
| 713 | * @ cwd_xp : extended pointer on current directory (for relative path). |
---|
| 714 | * @ pathname : path in kernel space (can be relative or absolute). |
---|
| 715 | * @ client_uid : client thread user ID (for checking). |
---|
| 716 | * @ client_gid : client thread group ID (for checking). |
---|
| 717 | * @ inode_xp : [out] buffer for extended pointer on inode. |
---|
| 718 | * @ ctx_xp : [out] buffer for extended pointer on inode context. |
---|
| 719 | * @ return 0 if success / ENOENT if inode not found / EACCES if permissopn denied |
---|
| 720 | *****************************************************************************************/ |
---|
| 721 | error_t vfs_lookup( xptr_t cwd_xp, |
---|
| 722 | char * pathname, |
---|
| 723 | uint32_t client_uid, |
---|
| 724 | uint32_t client_gid, |
---|
| 725 | xptr_t * inode_xp, |
---|
| 726 | xptr_t * ctx_xp ); |
---|
| 727 | |
---|
| 728 | /****************************************************************************************** |
---|
| 729 | * This function creates a new couple dentry/inode, and insert it in the Inode-Tree. |
---|
| 730 | * It can be executed by any thread running in any cluster, as this function |
---|
| 731 | * uses the rpc_dentry_create_client() and rpc_inode_create client() if required. |
---|
| 732 | * - The dentry is created in the cluster containing the existing <parent_xp> inode. |
---|
| 733 | * - the child inode and its associated mapper are created in a randomly selected cluster. |
---|
| 734 | * - The dentry name is defined by the <name> argument. |
---|
| 735 | ****************************************************************************************** |
---|
| 736 | * @ type : new inode type |
---|
| 737 | * @ parent_xp : extended pointer on parent inode. |
---|
| 738 | * @ name : new directory entry name. |
---|
| 739 | * @ child_xp : [out] buffer for extended pointer on child inode. |
---|
| 740 | * @ return 0 if success / ENOENT if entry not found in parent directory |
---|
| 741 | *****************************************************************************************/ |
---|
| 742 | error_t vfs_add_child_in_parent( uint32_t type, |
---|
| 743 | xptr_t parent_xp, |
---|
| 744 | char * name, |
---|
| 745 | xptr_t * child_xp ); |
---|
| 746 | |
---|
| 747 | /****************************************************************************************** |
---|
| 748 | * TODO |
---|
| 749 | ****************************************************************************************** |
---|
| 750 | * @ child_xp : extended pointer on removed inode. |
---|
| 751 | *****************************************************************************************/ |
---|
| 752 | error_t vfs_remove_child_from_parent( xptr_t child_xp ); |
---|
| 753 | |
---|
| 754 | /*****************************************************************************************/ |
---|
| 755 | /************************ File related functions *****************************************/ |
---|
| 756 | /*****************************************************************************************/ |
---|
| 757 | |
---|
| 758 | /****************************************************************************************** |
---|
| 759 | * This function allocates a vfs_file_t structure in the cluster containing the inode |
---|
| 760 | * associated to the requested file, initializes it, and returns an extended pointer |
---|
| 761 | * on this remote open file descriptor. |
---|
| 762 | * The pathname can be relative to current directory or absolute. |
---|
| 763 | * If the inode does not exist in the inode cache, it try to find file on the mounted |
---|
| 764 | * device, and creates an inode on a pseudo randomly selected cluster if found. |
---|
| 765 | * It the requested file does not exist on device, it creates a new inode if the |
---|
| 766 | * O_CREAT flag is set and return an error otherwise. |
---|
| 767 | ****************************************************************************************** |
---|
| 768 | * @ cwd_xp : extended pointer on current directory file descriptor (for relative path). |
---|
| 769 | * @ path : file pathname (absolute or relative to current directory). |
---|
| 770 | * @ flags : O_RDONLY, O_WRONLY, O_CREATE etc... |
---|
| 771 | * @ file_xp : [out] buffer for extended pointer on created remote file descriptor. |
---|
| 772 | * @ return 0 if success / return non-zero if error. |
---|
| 773 | *****************************************************************************************/ |
---|
| 774 | error_t vfs_open( xptr_t cwd_xp, |
---|
| 775 | char * path, |
---|
| 776 | uint32_t flags, |
---|
| 777 | xptr_t * file_xp ); |
---|
| 778 | |
---|
| 779 | /****************************************************************************************** |
---|
| 780 | * This function moves <size> bytes from the file identified by the open file descriptor |
---|
| 781 | * <file_xp> to the local kernel <buffer> , taken into account the offset in <file_xp>. |
---|
| 782 | ****************************************************************************************** |
---|
| 783 | * @ file_xp : extended pointer on the remote open file descriptor. |
---|
| 784 | * @ buffer : local pointer on destination kernel buffer. |
---|
| 785 | * @ size : requested number of bytes from offset. |
---|
| 786 | * @ returns number of bytes actually transfered / 0 if EOF / -1 if error. |
---|
| 787 | *****************************************************************************************/ |
---|
| 788 | uint32_t vfs_read( xptr_t file_xp, |
---|
| 789 | void * buffer, |
---|
| 790 | uint32_t size ); |
---|
| 791 | |
---|
| 792 | /****************************************************************************************** |
---|
| 793 | * This function moves <size> bytes from the local kernel <buffer> to the open file |
---|
| 794 | * descriptor <file_xp>, taken into account the offset defined in <file_xp>. |
---|
| 795 | ****************************************************************************************** |
---|
| 796 | * @ file_xp : extended pointer on the remote open file descriptor. |
---|
| 797 | * @ buffer : local pointer on source kernel buffer. |
---|
| 798 | * @ size : requested number of bytes to be written from offset. |
---|
| 799 | * @ returns number of bytes actually transfered / -1 if error. |
---|
| 800 | *****************************************************************************************/ |
---|
| 801 | uint32_t vfs_write( xptr_t file_xp, |
---|
| 802 | void * buffer, |
---|
| 803 | uint32_t size ); |
---|
| 804 | |
---|
| 805 | /****************************************************************************************** |
---|
| 806 | * This function set a new value in the offset of the open file descriptor <file_xp>. |
---|
| 807 | * This value depends on the <whence> argument: |
---|
| 808 | * - if VFS_SEEK_SET, new value is <offset> |
---|
| 809 | * - if VFS_SEEK_CUR, new value is current_offset + <offset> |
---|
| 810 | * - if VFS_SEEK_END, new value is file_size + <offset> |
---|
| 811 | ****************************************************************************************** |
---|
| 812 | * @ file_xp : extended pointer on the remote open file descriptor. |
---|
| 813 | * @ offset : local pointer on source kernel buffer. |
---|
| 814 | * @ whence : VFS_SEEK_SET / VFS_SEEK_CUR / VFS_SEEK_END. |
---|
| 815 | * @ new_offset : [out] buffer for new offset value. |
---|
| 816 | * @ returns 0 if success / -1 if error. |
---|
| 817 | *****************************************************************************************/ |
---|
| 818 | error_t vfs_lseek( xptr_t file_xp, |
---|
| 819 | uint32_t offset, |
---|
| 820 | uint32_t whence, |
---|
| 821 | uint32_t * new_offset ); |
---|
| 822 | |
---|
| 823 | /****************************************************************************************** |
---|
| 824 | * This function close an open file descriptor. |
---|
| 825 | ****************************************************************************************** |
---|
| 826 | * @ file_xp : extended pointer on the file descriptor. |
---|
| 827 | * @ refcount : number of references after close. |
---|
| 828 | * @ return 0 if success / return -1 if error |
---|
| 829 | *****************************************************************************************/ |
---|
| 830 | error_t vfs_close( xptr_t file_xp, |
---|
| 831 | uint32_t * refcount ); |
---|
| 832 | |
---|
| 833 | /****************************************************************************************** |
---|
| 834 | * This function remove from the file system a directory entry identified by its pathname. |
---|
| 835 | * The pathname can be relative to current directory or absolute. |
---|
| 836 | ****************************************************************************************** |
---|
| 837 | * @ cwd_xp : extended pointer on the current directory file descriptor. |
---|
| 838 | * @ path : pathname (absolute or relative to current directory). |
---|
| 839 | *****************************************************************************************/ |
---|
| 840 | error_t vfs_unlink( xptr_t cwd_xp, |
---|
| 841 | char * path ); |
---|
| 842 | |
---|
| 843 | /****************************************************************************************** |
---|
| 844 | * This function returns in the <ustat> structure various informations on the file TODO |
---|
| 845 | *****************************************************************************************/ |
---|
| 846 | error_t vfs_stat( xptr_t file_xp, |
---|
| 847 | vfs_stat_t * ustat ); |
---|
| 848 | |
---|
| 849 | |
---|
| 850 | |
---|
| 851 | |
---|
| 852 | /*****************************************************************************************/ |
---|
| 853 | /************************ Directory related functions ************************************/ |
---|
| 854 | /*****************************************************************************************/ |
---|
| 855 | |
---|
| 856 | /****************************************************************************************** |
---|
| 857 | * This function TODO |
---|
| 858 | *****************************************************************************************/ |
---|
| 859 | error_t vfs_opendir( xptr_t cwd_xp, |
---|
| 860 | char * path, |
---|
| 861 | uint32_t flags, |
---|
| 862 | xptr_t file_xp ); |
---|
| 863 | |
---|
| 864 | /****************************************************************************************** |
---|
| 865 | * This function TODO |
---|
| 866 | * fat32_readdir need cleaning |
---|
| 867 | *****************************************************************************************/ |
---|
| 868 | error_t vfs_readdir( xptr_t file_xp, |
---|
| 869 | char * path ); |
---|
| 870 | |
---|
| 871 | /****************************************************************************************** |
---|
| 872 | * This function TODO |
---|
| 873 | *****************************************************************************************/ |
---|
| 874 | error_t vfs_mkdir( xptr_t file_xp, |
---|
| 875 | char * path, |
---|
| 876 | uint32_t mode ); |
---|
| 877 | |
---|
| 878 | /****************************************************************************************** |
---|
| 879 | * This function remove a directory from the file system. |
---|
| 880 | *****************************************************************************************/ |
---|
| 881 | error_t vfs_rmdir( xptr_t file_xp, |
---|
| 882 | char * path ); |
---|
| 883 | |
---|
| 884 | /****************************************************************************************** |
---|
| 885 | * This function TODO |
---|
| 886 | *****************************************************************************************/ |
---|
| 887 | error_t vfs_chdir( char * pathname, |
---|
| 888 | xptr_t cwd_xp ); |
---|
| 889 | |
---|
| 890 | /****************************************************************************************** |
---|
| 891 | * This function TODO |
---|
| 892 | *****************************************************************************************/ |
---|
| 893 | error_t vfs_chmod( char * pathname, |
---|
| 894 | vfs_file_t * cwd, |
---|
| 895 | uint32_t mode ); |
---|
| 896 | |
---|
| 897 | /****************************************************************************************** |
---|
| 898 | * This function TODO |
---|
| 899 | *****************************************************************************************/ |
---|
| 900 | error_t vfs_closedir( xptr_t file_xp, |
---|
| 901 | uint32_t * refcount ); |
---|
| 902 | |
---|
| 903 | |
---|
| 904 | |
---|
| 905 | |
---|
| 906 | /*****************************************************************************************/ |
---|
| 907 | /******************* Pipe related functions *********************************************/ |
---|
| 908 | /*****************************************************************************************/ |
---|
| 909 | |
---|
| 910 | /****************************************************************************************** |
---|
| 911 | * This function TODO ??? |
---|
| 912 | *****************************************************************************************/ |
---|
| 913 | error_t vfs_pipe( xptr_t pipefd[2] ); |
---|
| 914 | |
---|
| 915 | /****************************************************************************************** |
---|
| 916 | * This function TODO |
---|
| 917 | *****************************************************************************************/ |
---|
| 918 | error_t vfs_mkfifo( xptr_t cwd_xp, |
---|
| 919 | char * path, |
---|
| 920 | uint32_t mode ); |
---|
| 921 | |
---|
| 922 | |
---|
| 923 | |
---|
| 924 | |
---|
| 925 | #endif /* _VFS_H_ */ |
---|