Changeset 10


Ignore:
Timestamp:
Apr 26, 2017, 2:24:47 PM (7 years ago)
Author:
alain
Message:

Merge all FS related files in one single directory.

Location:
trunk/kernel/vfs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/vfs/fatfs.c

    r1 r10  
    252252
    253253    // compute FATFS_cluster index for the accessed page
    254     uint32_t cluster;
     254    uint32_t cluster = 0;
    255255    error_t  error = fatfs_cluster_from_index( fatfs_ctx,
    256256                                               first_cluster,
  • trunk/kernel/vfs/ramfs.c

    r1 r10  
    7171void ramfs_inode_destroy( struct vfs_inode_s * inode )
    7272{
    73     printk("\n[PANIC] %s not fully implemented yet\n", __FUNCTION__ );
    74     hal_core_sleep();
    75 
    76     return 0;
     73    assert( false , __FUNCTION__ , "not fully implemented yet" );
    7774}
    7875
  • trunk/kernel/vfs/vfs.c

    r1 r10  
    177177
    178178    // initialize inode locks
    179     remote_rwlock_init( XPTR( local_cxy , &inode->size_lock ) );
     179    remote_rwlock_init( XPTR( local_cxy , &inode->data_lock ) );
    180180    remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) );
    181181
     
    238238
    239239    // get size
    240     remote_rwlock_rd_lock( XPTR( cxy , &ptr->size_lock ) );
     240    remote_rwlock_rd_lock( XPTR( cxy , &ptr->data_lock ) );
    241241    uint32_t size = hal_remote_lw( XPTR( cxy , &ptr->size ) );
    242     remote_rwlock_rd_unlock( XPTR( cxy , &ptr->size_lock ) );
     242    remote_rwlock_rd_unlock( XPTR( cxy , &ptr->data_lock ) );
    243243    return size;
    244244}
     
    253253
    254254    // set size
    255     remote_rwlock_wr_unlock( XPTR( cxy , &ptr->size_lock ) );
     255    remote_rwlock_wr_unlock( XPTR( cxy , &ptr->data_lock ) );
    256256    hal_remote_sw( XPTR( cxy , &ptr->size ) , size );
    257     remote_rwlock_wr_unlock( XPTR( cxy , &ptr->size_lock ) );
     257    remote_rwlock_wr_unlock( XPTR( cxy , &ptr->data_lock ) );
    258258}
    259259
  • trunk/kernel/vfs/vfs.h

    r1 r10  
    166166 * The <parent> inode is unique for a directory (not hard links for directories).
    167167 * For a file, the parent field points to the first dentry who created this inode.
    168  * TODO pourquoi deux types de locks ???
    169  *****************************************************************************************/
     168 * Syncronisation:
     169 * - the main_lock (spinlock) is used during the inode tree traversal or for inode
     170 *   modification (add/remove children).
     171 * - the data_lock (rwlock) is used during read/write accesses to the data stored
     172 *   in the mapper.
     173 * - the mapper lock (rwlock) is only used during the radix tree traversal to return
     174 *   to return the relevant page for red/write.
     175 *****************************************************************************************/
     176
     177typedef enum   
     178{
     179    INODE_TYPE_NORMAL,                 /*! file or directory                            */
     180    INODE_TYPE_PIPE,                   /*! POSIX pipe                                   */
     181    INODE_TYPE_SOCKET,                 /*! POSIX socket                                 */
     182    INODE_TYPE_DEV,                    /*! peripheral channel                           */
     183}
     184vfs_inode_type_t;
    170185
    171186typedef enum
     
    176191    INODE_ATTR_NEW    = 0x08,
    177192}
    178 inode_attr_t;
     193vfs_inode_attr_t;
    179194
    180195typedef struct vfs_inode_s
     
    184199        uint32_t                inum;        /*! inode identifier (unique in file system)    */
    185200        uint32_t                attr;        /*! inode attributes (see above)                */
     201        uint32_t                type;        /*! inode type (see above)                      */
    186202        uint32_t                size;        /*! number of bytes                             */
    187203        uint32_t                links;       /*! number of alias dentry                      */
     
    192208        xptr_t                  parent_xp;   /*! extended pointer on parent dentry           */
    193209        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)   */
     210        remote_rwlock_t         data_lock;   /*! protect read/write to data and to size      */
     211        remote_spinlock_t       main_lock;   /*! protect inode tree traversal and modifs     */
    196212        xlist_entry_t           xlist;       /*! member of set of inodes in same cluster     */
    197213        xlist_entry_t           wait_root;   /*! root of threads waiting on this inode       */
     
    229245 *****************************************************************************************/
    230246
    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;
    239247
    240248typedef enum
    241249{
    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                          */
     250    FD_ATTR_READ_ENABLE  = 0x01,       /*! read access possible                         */
     251    FD_ATTR_WRITE_ENABLE = 0x02,       /*! write access possible                        */
     252    FD_ATTR_APPEND       = 0x04,       /*! append on each write                         */
     253    FD_ATTR_CLOSE_EXEC   = 0x08,       /*! close file on exec                           */
     254    FD_ATTR_SYNC         = 0x10,       /*! synchronise FS on each write                 */
     255    FD_ATTR_IS_DIR       = 0x20,       /*! this is a directory                          */
    248256}
    249257vfs_fd_attr_t;
     
    281289vfs_types_t;
    282290
     291typedef enum
     292{
     293    CTX_ATTR_READ_ONLY    = 0x01,       /*! read access possible                         */
     294    CTX_ATTR_SYNC         = 0x10,       /*! synchronise FS on each write                 */
     295}
     296vfs_ctx_attr_t;
     297
    283298typedef struct vfs_ctx_s
    284299{
    285300        uint32_t                      type;          /*! File System type                        */
    286         uint32_t                      flags;         /*! TODO ???                                */
     301        uint32_t                      attr;          /*! global attributes for all files in FS   */
    287302        uint32_t                  count;         /*! number of clusters                      */
    288303        uint32_t                  blksize;       /*! cluster size                            */
Note: See TracChangeset for help on using the changeset viewer.