Changeset 188 for trunk/kernel/vfs/vfs.h


Ignore:
Timestamp:
Jul 12, 2017, 8:12:41 PM (7 years ago)
Author:
alain
Message:

Redefine the PIC device API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/vfs/vfs.h

    r101 r188  
    132132        vfs_fs_type_t  type;                     /*! File System type                        */
    133133        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      */
    137137    spinlock_t     lock;                     /*! lock protecting inum allocator          */
    138138    uint32_t       bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)];  /* inum allocator        */
     
    160160typedef enum   
    161161{
    162     INODE_TYPE_FILE    =     0x001,      /*! file                                        */
    163     INODE_TYPE_DIR     =     0x002,      /*! directory                                   */
    164     INODE_TYPE_FIFO    =     0x004,      /*! POSIX named pipe                            */
    165     INODE_TYPE_PIPE    =     0x008,      /*! POSIX anonymous pipe                        */
    166     INODE_TYPE_SOCKET  =     0x010,      /*! POSIX socket                                */
    167     INODE_TYPE_DEV     =     0x020,      /*! character peripheral channel                */
    168     INODE_TYPE_SYML    =     0x080,      /*! symbolic link                               */
     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                                 */
    169169}
    170170vfs_inode_type_t;
     
    182182typedef struct vfs_inode_s
    183183{
    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            */
    204203}
    205204vfs_inode_t;
     
    214213typedef struct vfs_dentry_s
    215214{
    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                       */
    225223}
    226224vfs_dentry_t;
     
    231229 * the inode, when a thread makes an open() or opendir() system call.
    232230 * 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.
    234232 * is replicated in all process descriptors, we need a references counter.
    235233 *****************************************************************************************/
     
    313311
    314312/*****************************************************************************************/
    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 *****************************************************************************************/
     326void 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 );
    317332
    318333/******************************************************************************************
     
    355370 * @ fs_type    : file system type.
    356371 * @ inode_type : inode type.
     372 * @ extend     : local pointer on vs_type_specific extension.
    357373 * @ attr       : inode attributes.
    358374 * @ rights     : inode access rights.
     
    365381                          vfs_fs_type_t     fs_type,
    366382                          vfs_inode_type_t  inode_type,
     383                          void            * extend,
    367384                          uint32_t          attr,
    368385                          uint32_t          rights,
     
    550567/******************* Inode-Tree related functions ****************************************/
    551568/*****************************************************************************************/
     569
     570/******************************************************************************************
     571 * This function randomly selects a cluster for a new inode.
     572 ******************************************************************************************
     573 * @ returns the selected cluster identifier.
     574 *****************************************************************************************/
     575cxy_t vfs_cluster_random_select();
    552576
    553577/******************************************************************************************
     
    594618 * uses the rpc_dentry_create_client() and rpc_inode_create client() if required.
    595619 * - 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>.
    597621 * - The new dentry name is defined by the <name> argument.
    598622 * - The new inode and the parent inode can have different FS types.
    599623 ******************************************************************************************
     624 * @ child_cxy  : target cluster for child inode.
    600625 * @ inode_type : new inode type
    601626 * @ fs_type    : new inode FS type.
    602627 * @ parent_xp  : extended pointer on parent inode.
    603628 * @ name       : new directory entry name.
     629 * @ extend     : fs_type_specific inode extension.
    604630 * @ child_xp   : [out] buffer for extended pointer on child inode.
    605631 * @ return 0 if success / ENOENT if entry not found in parent directory
    606632 *****************************************************************************************/
    607 error_t vfs_add_child_in_parent( vfs_inode_type_t   inode_type,
     633error_t vfs_add_child_in_parent( cxy_t              child_cxy,
     634                                 vfs_inode_type_t   inode_type,
    608635                                 vfs_fs_type_t      fs_type,
    609636                                 xptr_t             parent_xp,
    610637                                 char             * name,   
     638                                 void             * extend,
    611639                                 xptr_t           * child_xp );
    612640
     
    620648error_t vfs_remove_child_from_parent( xptr_t child_xp );
    621649
     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 *****************************************************************************************/
     657void vfs_display( xptr_t   inode_xp );
    622658
    623659
Note: See TracChangeset for help on using the changeset viewer.