Changeset 188 for trunk/kernel/vfs/vfs.h
- Timestamp:
- Jul 12, 2017, 8:12:41 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/vfs.h
r101 r188 132 132 vfs_fs_type_t type; /*! File System type */ 133 133 uint32_t attr; /*! global attributes for all files in FS */ 134 uint32_t count;/*! total number of clusters on device */135 uint32_t blksize; /*! device cluster size (bytes)*/136 xptr_t root_xp; /*! extended pointer on root inode*/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 137 spinlock_t lock; /*! lock protecting inum allocator */ 138 138 uint32_t bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)]; /* inum allocator */ … … 160 160 typedef enum 161 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 ET = 0x010, /*! POSIX socket*/167 INODE_TYPE_DEV = 0x020, /*! character peripheral channel*/168 INODE_TYPE_SYML = 0x080, /*! symbolic link*/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 169 } 170 170 vfs_inode_type_t; … … 182 182 typedef struct vfs_inode_s 183 183 { 184 struct vfs_ctx_s * ctx; /*! local pointer on FS context */ 185 uint32_t gc; /*! generation counter */ 186 uint32_t inum; /*! inode identifier (unique in file system) */ 187 uint32_t attr; /*! inode attributes (see above) */ 188 vfs_inode_type_t type; /*! inode type (see above) */ 189 uint32_t size; /*! number of bytes */ 190 uint32_t links; /*! number of alias dentry */ 191 uid_t uid; /*! user owner identifier */ 192 gid_t gid; /*! group owner identifier */ 193 uint32_t rights; /*! access rights */ 194 uint32_t refcount; /*! reference counter (all pointers) */ 195 xptr_t parent_xp; /*! extended pointer on parent dentry */ 196 xhtab_t children; /*! embedded xhtab of vfs_dentry_t */ 197 remote_rwlock_t data_lock; /*! protect read/write to data and to size */ 198 remote_spinlock_t main_lock; /*! protect inode tree traversal and modifs */ 199 list_entry_t list; /*! member of set of inodes in same cluster */ 200 xlist_entry_t wait_root; /*! root of threads waiting on this inode */ 201 struct vfs_inode_op_s * op; /*! TODO ??? */ 202 struct mapper_s * mapper; /*! associated file cache */ 203 void * extend; /*! FS specific inode extension */ 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 */ 204 203 } 205 204 vfs_inode_t; … … 214 213 typedef struct vfs_dentry_s 215 214 { 216 struct vfs_ctx_s * ctx; /*! local pointer on FS context */ 217 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 218 uint32_t length; /*! name length (bytes) */ 219 uint32_t refcount; /*! reference counter (all pointers) */ 220 struct vfs_inode_s * parent; /*! local pointer on parent inode */ 221 xptr_t child_xp; /*! extended pointer on child inode */ 222 xlist_entry_t xlist; /*! member of xlist of dentries with same key */ 223 struct vfs_dentry_op_s * op; /*! TODO */ 224 void * extend; /*! FS specific extension */ 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 */ 225 223 } 226 224 vfs_dentry_t; … … 231 229 * the inode, when a thread makes an open() or opendir() system call. 232 230 * It cannot exist a file structure without an inode structure. 233 * Aa the fd_array (containing extended pointers on the open file descriptors) 231 * Aa the fd_array (containing extended pointers on the open file descriptors)* is replicated in all process descriptors, we need a references counter. 234 232 * is replicated in all process descriptors, we need a references counter. 235 233 *****************************************************************************************/ … … 313 311 314 312 /*****************************************************************************************/ 315 /******************* FS Context related functions ****************************************/ 316 /*****************************************************************************************/ 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 ); 317 332 318 333 /****************************************************************************************** … … 355 370 * @ fs_type : file system type. 356 371 * @ inode_type : inode type. 372 * @ extend : local pointer on vs_type_specific extension. 357 373 * @ attr : inode attributes. 358 374 * @ rights : inode access rights. … … 365 381 vfs_fs_type_t fs_type, 366 382 vfs_inode_type_t inode_type, 383 void * extend, 367 384 uint32_t attr, 368 385 uint32_t rights, … … 550 567 /******************* Inode-Tree related functions ****************************************/ 551 568 /*****************************************************************************************/ 569 570 /****************************************************************************************** 571 * This function randomly selects a cluster for a new inode. 572 ****************************************************************************************** 573 * @ returns the selected cluster identifier. 574 *****************************************************************************************/ 575 cxy_t vfs_cluster_random_select(); 552 576 553 577 /****************************************************************************************** … … 594 618 * uses the rpc_dentry_create_client() and rpc_inode_create client() if required. 595 619 * - The dentry is created in the cluster containing the existing <parent_xp> inode. 596 * - the child inode and its associated mapper are created in a randomly selected cluster.620 * - the inode and its associated mapper are created in cluster identified by <child_cxy>. 597 621 * - The new dentry name is defined by the <name> argument. 598 622 * - The new inode and the parent inode can have different FS types. 599 623 ****************************************************************************************** 624 * @ child_cxy : target cluster for child inode. 600 625 * @ inode_type : new inode type 601 626 * @ fs_type : new inode FS type. 602 627 * @ parent_xp : extended pointer on parent inode. 603 628 * @ name : new directory entry name. 629 * @ extend : fs_type_specific inode extension. 604 630 * @ child_xp : [out] buffer for extended pointer on child inode. 605 631 * @ return 0 if success / ENOENT if entry not found in parent directory 606 632 *****************************************************************************************/ 607 error_t vfs_add_child_in_parent( vfs_inode_type_t inode_type, 633 error_t vfs_add_child_in_parent( cxy_t child_cxy, 634 vfs_inode_type_t inode_type, 608 635 vfs_fs_type_t fs_type, 609 636 xptr_t parent_xp, 610 637 char * name, 638 void * extend, 611 639 xptr_t * child_xp ); 612 640 … … 620 648 error_t vfs_remove_child_from_parent( xptr_t child_xp ); 621 649 650 /****************************************************************************************** 651 * This recursive function diplays a complete inode/dentry sub-tree. 652 * Any inode can be selected as the sub-tree root. 653 * TODO this function is not ptotected against a concurrent node removal... 654 ****************************************************************************************** 655 * @ inode_xp : extended pointer on sub-tree root inode. 656 *****************************************************************************************/ 657 void vfs_display( xptr_t inode_xp ); 622 658 623 659
Note: See TracChangeset
for help on using the changeset viewer.