Changeset 673 for trunk/kernel/fs/vfs.h


Ignore:
Timestamp:
Nov 19, 2020, 11:54:16 PM (3 years ago)
Author:
alain
Message:

Introduce the DEBUG_VFS_ERROR in kernel_config to make
error messges display conditional.

File:
1 edited

Legend:

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

    r657 r673  
    33 *
    44 * Author  Mohamed Lamine Karaoui (2014,2015)
    5  *         Alain Greiner (2016,2017,2018,2019,2020)
     5 *         Alain Greiner          (2016,2017,2018,2019,2020)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    4949struct vfs_ctx_s;
    5050struct vfs_file_s;
    51 
     51struct remote_buf_s;
    5252struct mapper_s;
    5353struct process_s;
     
    6666#define VFS_LOOKUP_CREATE   0x10     /* file must be created if missing                  */
    6767#define VFS_LOOKUP_EXCL     0x20     /* file cannot previously exist                     */
     68
     69
     70
    6871
    6972/******************************************************************************************
     
    105108}
    106109vfs_ctx_t;
     110
     111/******************************************************************************************
     112 *        These functions access / modify  a VFS context.
     113 *****************************************************************************************/
     114
     115/******************************************************************************************
     116 * This function initialises a (statically allocated) VFS context in cluster identified
     117 * by the <cxy> argument.
     118 * It is called by the kernel_init() function.
     119 ******************************************************************************************
     120 * @ cxy            : target cluster identifier.
     121 * @ fs_type        : file system type.
     122 * @ total_clusters : total number of clusters on device.
     123 * @ cluster_size   : cluster size on device (bytes).
     124 * @ vfs_root_xp    : extended pointer on VFS root inode.
     125 * @ extend         : fs_type_specific extension.
     126 *****************************************************************************************/
     127void vfs_ctx_init( cxy_t           cxy,
     128                   vfs_fs_type_t   type,
     129                       uint32_t        total_clusters,
     130                       uint32_t        cluster_size,
     131                       xptr_t          vfs_root_xp,
     132                   void          * extend );
     133
     134/******************************************************************************************
     135 * This function allocates an inode identifier from the local cluster inum allocator.
     136 * The inum respects a fixed format:
     137 * - the 16 MSB bits contain the cluster identifier : cxy
     138 * - the 16 LSB bits contains the local inode identifier  : lid
     139 ******************************************************************************************
     140 * @ ctx_xp   : [in]  extended pointer on file system context.
     141 * @ inum     : [out] buffer for allocated inode identifier.
     142 * @ return 0 if success / return non-zero if error.
     143 *****************************************************************************************/
     144error_t vfs_ctx_inum_alloc( xptr_t     ctx_xp,
     145                            uint32_t * inum );
     146
     147/******************************************************************************************
     148 * This function release an inode identifier.                                 
     149 ******************************************************************************************
     150 * @ ctx_xp   : [in] extended pointer on file system context.
     151 * @ inum     : [in] released inode identifier.
     152 *****************************************************************************************/
     153void vfs_ctx_inum_release( xptr_t      ctx_xp,
     154                           uint32_t    inum );
     155
     156
     157
     158
     159
     160
     161/******************************************************************************************
     162 * This file structure describes an open file/directory for a given process.
     163 * It is not replicated, and is dynamically allocated in the cluster that contains
     164 * the associated inode / socket / pipe , when a thread makes an open(), opendir(),
     165 * socket(), or pipe() system call. It cannot exist a <file> structure without a
     166 * a <mapper>, <socket>, or <pipe> structure (depending on type) in same cluster.
     167 * It can exist a <file> structure without an <inode> (for PIPE and SOCK types).
     168 *****************************************************************************************/
     169
     170/* this enum define the VFS inode types values                                           */
     171/* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file       */
     172/*           and with types in <shared_dirent.h> file.                                   */
     173
     174typedef enum   
     175{
     176    FILE_TYPE_REG   =     0,           /*! regular file                                 */
     177    FILE_TYPE_DIR   =     1,           /*! directory                                    */
     178    FILE_TYPE_FIFO  =     2,           /*! POSIX named fifo                             */
     179    FILE_TYPE_PIPE  =     3,           /*! POSIX anonymous pipe                         */
     180    FILE_TYPE_SOCK  =     4,           /*! POSIX anonymous socket                       */
     181    FILE_TYPE_DEV   =     5,           /*! character device                             */
     182    FILE_TYPE_BLK   =     6,           /*! block device                                 */
     183    FILE_TYPE_SYML  =     7,           /*! symbolic link                                */
     184}
     185vfs_file_type_t;
     186
     187typedef enum
     188{
     189    FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                          */
     190    FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                         */
     191    FD_ATTR_APPEND         = 0x04,     /*! append on each write                          */
     192    FD_ATTR_CLOSE_EXEC     = 0x08,     /*! close file on exec                            */
     193    FD_ATTR_SYNC           = 0x10,     /*! synchronise FS on each write                  */
     194    FD_ATTR_IS_DIR         = 0x20,     /*! this is a directory                           */
     195}
     196vfs_file_attr_t;
     197
     198typedef struct vfs_file_s
     199{
     200        struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
     201        vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
     202        vfs_file_type_t        type;       /*! same type as inode                           */
     203        uint32_t                offset;     /*! seek position in file                        */
     204        remote_rwlock_t         lock;       /*! protect offset modifications                 */
     205        struct vfs_inode_s    * inode;      /*! local pointer on associated inode            */
     206        struct mapper_s       * mapper;     /*! associated mapper (REG or DIR types only)    */
     207    struct socket_s       * socket;     /*! associated socket (SOCK type only)           */
     208    struct pipe_s         * pipe;       /*! associated pipe (FIFO or PIPE types only)    */
     209        void                  * extend;     /*! FS specific extension                        */
     210}
     211vfs_file_t;
     212
     213/******************************************************************************************
     214 *        These low-level functions access / modify a VFS file descriptor
     215 *****************************************************************************************/
     216
     217/******************************************************************************************
     218 * This function allocates memory and initializes a new file descriptor in the
     219 * cluster defined by the <inode_xp> argument.
     220 * It can be called by any thread running in any cluster.
     221 ******************************************************************************************
     222 * @ inode_xp  : [in]  extended pointer on associated inode.
     223 * @ attr      : [in]  file descriptor attributes.
     224 * @ file_xp   : [out] buffer for extended pointer on created file descriptor.
     225 * @ return 0 if success / return ENOMEM if error.
     226 *****************************************************************************************/
     227error_t vfs_file_create( xptr_t        inode_xp,
     228                         uint32_t      attr,
     229                         xptr_t      * file_xp ); 
     230
     231/******************************************************************************************
     232 * This function releases memory allocated to file descriptor identified
     233 * by the <file_xp> argument.
     234 * It can be called by any thread running in any cluster.
     235 ******************************************************************************************
     236 * @ file_xp  : [in] extended pointer on file descriptor.
     237 *****************************************************************************************/
     238void vfs_file_destroy( xptr_t  file_xp ); 
     239
     240/******************************************************************************************
     241 * This debug function copies the name of a the file identified by <file_xp>
     242 * argument to a local buffer identified by the <name> argument.
     243 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
     244 *****************************************************************************************
     245 * @ ionde_xp  : [in] extended pointer on the remote inode.
     246 * @ name      : [out] local string.
     247 ***************************************************************************************/
     248void vfs_file_get_name( xptr_t inode_xp,
     249                        char * name );
     250
     251
     252
    107253
    108254/******************************************************************************************
     
    124270 *****************************************************************************************/
    125271
    126 /* this enum define the VFS inode types values                                           */
    127 /* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file       */
    128 /*           and with types in <shared_dirent.h> file.                                   */
    129 
    130 typedef enum   
    131 {
    132     INODE_TYPE_FILE  =     0,           /*! regular file                                 */
    133     INODE_TYPE_DIR   =     1,           /*! directory                                    */
    134     INODE_TYPE_FIFO  =     2,           /*! POSIX named pipe                             */
    135     INODE_TYPE_PIPE  =     3,           /*! POSIX anonymous pipe                         */
    136     INODE_TYPE_SOCK  =     4,           /*! POSIX socket                                 */
    137     INODE_TYPE_DEV   =     5,           /*! character device                             */
    138     INODE_TYPE_BLK   =     6,           /*! block device                                 */
    139     INODE_TYPE_SYML  =     7,           /*! symbolic link                                */
    140 }
    141 vfs_inode_type_t;
    142 
    143272/* this enum define the VFS inode attributes values */
    144273
     
    153282typedef struct vfs_inode_s
    154283{
    155     struct vfs_ctx_s * ctx;              /*! local pointer on FS context                 */
    156     uint32_t           inum;             /*! inode identifier (unique in file system)    */
    157     uint32_t           attr;             /*! inode attributes (see above)                */
    158     vfs_inode_type_t   type;             /*! inode type (see above)                      */
    159     uint32_t           size;             /*! number of bytes                             */
    160     uint32_t           uid;              /*! user owner identifier                       */
    161     uint32_t           gid;              /*! group owner identifier                      */
    162     uint32_t           rights;           /*! access rights                               */
    163     xlist_entry_t      parents;          /*! root of list of parents dentries            */
    164     uint32_t           links;            /*! number of parent dentries (hard links)      */
    165     xhtab_t            children;         /*! embedded xhtab of children dentries         */
    166     remote_rwlock_t    size_lock;        /*! protect read/write to size                  */
    167     remote_rwlock_t    main_lock;        /*! protect inode tree traversal and modifs     */
    168     struct mapper_s  * mapper;           /*! associated file cache                       */
    169     void             * extend;           /*! fs_type_specific inode extension            */
     284    struct vfs_ctx_s    * ctx;           /*! local pointer on FS context                 */
     285    uint32_t              inum;          /*! inode identifier (unique in file system)    */
     286    uint32_t              attr;          /*! inode attributes (see above)                */
     287    vfs_file_type_t      type;          /*! inode type (see above)                      */
     288    uint32_t              size;          /*! number of bytes                             */
     289    uint32_t              uid;           /*! user owner identifier                       */
     290    uint32_t              gid;           /*! group owner identifier                      */
     291    uint32_t              rights;        /*! access rights                               */
     292    xlist_entry_t         parents;       /*! root of list of parents dentries            */
     293    uint32_t              links;         /*! number of parent dentries (hard links)      */
     294    xhtab_t               children;      /*! embedded xhtab of children dentries         */
     295    remote_rwlock_t       size_lock;     /*! protect read/write to size                  */
     296    remote_rwlock_t       main_lock;     /*! protect inode tree traversal and modifs     */
     297    struct mapper_s     * mapper;        /*! associated file (REG or DIR types only)     */
     298    struct remote_buf_s * pipe;          /*! associated pipe (FIFO type only)            */
     299    void                * extend;        /*! fs_type_specific inode extension            */
    170300}
    171301vfs_inode_t;
     
    191321#define VFS_IWOTH      0x0000002
    192322#define VFS_IXOTH      0x0000001
     323
     324/******************************************************************************************
     325 *        These low-level functions access / modify a VFS inode descriptor
     326 *****************************************************************************************/
     327
     328/******************************************************************************************
     329 * This function returns a printable string for the inode type.
     330 *****************************************************************************************/
     331const char * vfs_inode_type_str( vfs_file_type_t type );
     332
     333/******************************************************************************************
     334 * This function allocates memory in cluster identified by the <cxy> argument
     335 * for an inode descriptor and for the associated mapper, and partially initialise
     336 * this inode from arguments values.
     337 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().
     338 * It can be called by any thread running in any cluster.
     339 ******************************************************************************************
     340 * @ cxy        : [in]  target cluster identifier
     341 * @ fs_type    : [in]  file system type.
     342 * @ attr       : [in]  inode attributes.
     343 * @ rights     : [in]  inode access rights.
     344 * @ uid        : [in]  user owner ID.
     345 * @ gid        : [in]  group owner ID.
     346 * @ inode_xp   : [out] buffer for extended pointer on created inode.
     347 * @ return 0 if success / return -1 if error.
     348 *****************************************************************************************/
     349error_t vfs_inode_create( cxy_t             cxy,
     350                          vfs_fs_type_t     fs_type,
     351                          uint32_t          attr,
     352                          uint32_t          rights,
     353                          uid_t             uid,
     354                          gid_t             gid,
     355                          xptr_t          * inode_xp );
     356
     357/******************************************************************************************
     358 * This function releases memory allocated to an inode descriptor, including
     359 * all memory allocated to the mapper (both mapper descriptor and radix tree).
     360 * The mapper should not contain any dirty page (should be synchronized before deletion).
     361 * It can be called by any thread running in any cluster.
     362 ******************************************************************************************
     363 * @ inode_xp  : extended pointer on inode descriptor.
     364 *****************************************************************************************/
     365void vfs_inode_destroy( xptr_t  inode_xp ); 
     366
     367/******************************************************************************************
     368 * This function returns the <size> of a file/dir from a remote inode,
     369 * taking the remote_rwlock protecting <size> in READ_MODE.
     370 * It can be called by any thread running in any cluster.
     371 *****************************************************************************************
     372 * @ inode_xp  : extended pointer on the remote inode.
     373 * @ return the current size.
     374 *****************************************************************************************/
     375uint32_t vfs_inode_get_size( xptr_t inode_xp );
     376
     377/******************************************************************************************
     378 * This function updates the "size" field of a remote inode identified by <inode_xp>.
     379 * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field
     380 * when the current size is smaller than the requested <size> argument.
     381 * It can be called by any thread running in any cluster.
     382 *****************************************************************************************
     383 * @ inode_xp  : extended pointer on the remote inode.
     384 * @ size      : requested size value.
     385 *****************************************************************************************/
     386void vfs_inode_update_size( xptr_t   inode_xp,
     387                            uint32_t size );
     388
     389/******************************************************************************************
     390 * This function takes the main lock of a remote inode identified by the <inode_xp>.
     391 * This lock protect all inode fields, including the children dentries.
     392 * It can be called by any thread running in any cluster.
     393 *****************************************************************************************
     394 * @ inode_xp  : extended pointer on the remote inode.
     395 *****************************************************************************************/
     396void vfs_inode_lock( xptr_t inode_xp );
     397
     398/******************************************************************************************
     399 * This function releases the main lock of a remote inode identified by <inode_xp>.
     400 * This lock protect all inode fiels, including the children dentries.
     401 * It can be called by any thread running in any cluster.
     402 *****************************************************************************************
     403 * @ inode_xp  : extended pointer on the remote inode.
     404 *****************************************************************************************/
     405void vfs_inode_unlock( xptr_t inode_xp );
     406
     407/******************************************************************************************
     408 * This debug function copies the name of a remote inode identified by the <inode_xp>
     409 * argument to a local buffer identified by the <name> argument.
     410 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
     411 * It can be called by any thread running in any cluster.
     412 ******************************************************************************************
     413 * @ inode_xp  : extended pointer on the remote inode.
     414 * @ name      : local buffer pointer.
     415 *****************************************************************************************/
     416void vfs_inode_get_name( xptr_t inode_xp,
     417                         char * name );
     418
     419/******************************************************************************************
     420 * This function accesses successively all pages of a file identified by the <inode_xp>,
     421 * argument, to force misses, and load all pages into mapper.
     422 * The target inode can be a directory or a file, but this function is mainly used
     423 * to prefetch a complete directory to the mapper.
     424 * This function does NOT take any lock.
     425 * It can be called by any thread running in any cluster.
     426 ******************************************************************************************
     427 * @ inode_xp  : extended pointer on inode.
     428 * @ return 0 if success / return -1 if device access failure.
     429 *****************************************************************************************/
     430error_t vfs_inode_load_all_pages( xptr_t inode_xp );
     431
     432/******************************************************************************************
     433 * This debug function display the curren state of an inode descriptor.
     434 * It can be called by any thread running in any cluster.
     435 *****************************************************************************************/
     436void vfs_inode_display( xptr_t inode_xp );
     437
     438
     439
     440
     441
    193442
    194443/******************************************************************************************
     
    215464
    216465/******************************************************************************************
    217  * This file structure describes an open file/directory for a given process.
    218  * It is not replicated, and is dynamically allocated in the cluster that contains
    219  * the inode, when a thread makes an open() or opendir() system call.
    220  * It cannot exist a file structure without an inode structure in same cluster.
    221  * As the fd_array (containing extended pointers on the open file descriptors)
    222  * is replicated in all process descriptors, we need a references counter.
    223  *****************************************************************************************/
    224 
    225 typedef enum
    226 {
    227     FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                          */
    228     FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                         */
    229     FD_ATTR_APPEND         = 0x04,     /*! append on each write                          */
    230     FD_ATTR_CLOSE_EXEC     = 0x08,     /*! close file on exec                            */
    231     FD_ATTR_SYNC           = 0x10,     /*! synchronise FS on each write                  */
    232     FD_ATTR_IS_DIR         = 0x20,     /*! this is a directory                           */
    233 }
    234 vfs_file_attr_t;
    235 
    236 typedef struct vfs_file_s
    237 {
    238         struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
    239         vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
    240         vfs_inode_type_t        type;       /*! same type as inode                           */
    241         uint32_t                offset;     /*! seek position in file                        */
    242         uint32_t                refcount;   /*! all pointers on this file descriptor         */
    243         remote_rwlock_t         lock;       /*! protect offset modifications                 */
    244         struct mapper_s       * mapper;     /*! associated file cache                        */
    245         struct vfs_inode_s    * inode;      /*! local pointer on associated inode            */
    246     struct socket_s       * socket;     /*! local pointer on associated socket           */
    247         void                  * extend;     /*! FS specific extension                        */
    248 }
    249 vfs_file_t;
    250 
    251 
    252 /******************************************************************************************
    253  *        These functions access / modify  a VFS context.
    254  *****************************************************************************************/
    255 
    256 /******************************************************************************************
    257  * This function initialises a (statically allocated) VFS context in cluster identified
    258  * by the <cxy> argument.
    259  * It is called by the kernel_init() function.
    260  ******************************************************************************************
    261  * @ cxy            : target cluster identifier.
    262  * @ fs_type        : file system type.
    263  * @ total_clusters : total number of clusters on device.
    264  * @ cluster_size   : cluster size on device (bytes).
    265  * @ vfs_root_xp    : extended pointer on VFS root inode.
    266  * @ extend         : fs_type_specific extension.
    267  *****************************************************************************************/
    268 void vfs_ctx_init( cxy_t           cxy,
    269                    vfs_fs_type_t   type,
    270                        uint32_t        total_clusters,
    271                        uint32_t        cluster_size,
    272                        xptr_t          vfs_root_xp,
    273                    void          * extend );
    274 
    275 /******************************************************************************************
    276  * This function allocates an inode identifier from the local cluster inum allocator.
    277  * The inum respects a fixed format:
    278  * - the 16 MSB bits contain the cluster identifier : cxy
    279  * - the 16 LSB bits contains the local inode identifier  : lid
    280  ******************************************************************************************
    281  * @ ctx_xp   : [in]  extended pointer on file system context.
    282  * @ inum     : [out] buffer for allocated inode identifier.
    283  * @ return 0 if success / return non-zero if error.
    284  *****************************************************************************************/
    285 error_t vfs_ctx_inum_alloc( xptr_t     ctx_xp,
    286                             uint32_t * inum );
    287 
    288 /******************************************************************************************
    289  * This function release an inode identifier.                                 
    290  ******************************************************************************************
    291  * @ ctx_xp   : [in] extended pointer on file system context.
    292  * @ inum     : [in] released inode identifier.
    293  *****************************************************************************************/
    294 void vfs_ctx_inum_release( xptr_t      ctx_xp,
    295                            uint32_t    inum );
    296 
    297 
    298 
    299 /******************************************************************************************
    300  *        These low-level functions access / modify a VFS inode descriptor
    301  *****************************************************************************************/
    302 
    303 /******************************************************************************************
    304  * This function returns a printable string for the inode type.
    305  *****************************************************************************************/
    306 const char * vfs_inode_type_str( vfs_inode_type_t type );
    307 
    308 /******************************************************************************************
    309  * This function allocates memory in cluster identified by the <cxy> argument
    310  * for an inode descriptor and for the associated mapper, and partially initialise
    311  * this inode from arguments values.
    312  * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().
    313  * It can be called by any thread running in any cluster.
    314  ******************************************************************************************
    315  * @ cxy        : [in]  target cluster identifier
    316  * @ fs_type    : [in]  file system type.
    317  * @ attr       : [in]  inode attributes.
    318  * @ rights     : [in]  inode access rights.
    319  * @ uid        : [in]  user owner ID.
    320  * @ gid        : [in]  group owner ID.
    321  * @ inode_xp   : [out] buffer for extended pointer on created inode.
    322  * @ return 0 if success / return -1 if error.
    323  *****************************************************************************************/
    324 error_t vfs_inode_create( cxy_t             cxy,
    325                           vfs_fs_type_t     fs_type,
    326                           uint32_t          attr,
    327                           uint32_t          rights,
    328                           uid_t             uid,
    329                           gid_t             gid,
    330                           xptr_t          * inode_xp );
    331 
    332 /******************************************************************************************
    333  * This function releases memory allocated to an inode descriptor, including
    334  * all memory allocated to the mapper (both mapper descriptor and radix tree).
    335  * The mapper should not contain any dirty page (should be synchronized before deletion).
    336  * It can be called by any thread running in any cluster.
    337  ******************************************************************************************
    338  * @ inode_xp  : extended pointer on inode descriptor.
    339  *****************************************************************************************/
    340 void vfs_inode_destroy( xptr_t  inode_xp ); 
    341 
    342 /******************************************************************************************
    343  * This function returns the <size> of a file/dir from a remote inode,
    344  * taking the remote_rwlock protecting <size> in READ_MODE.
    345  * It can be called by any thread running in any cluster.
    346  *****************************************************************************************
    347  * @ inode_xp  : extended pointer on the remote inode.
    348  * @ return the current size.
    349  *****************************************************************************************/
    350 uint32_t vfs_inode_get_size( xptr_t inode_xp );
    351 
    352 /******************************************************************************************
    353  * This function updates the "size" field of a remote inode identified by <inode_xp>.
    354  * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field
    355  * when the current size is smaller than the requested <size> argument.
    356  * It can be called by any thread running in any cluster.
    357  *****************************************************************************************
    358  * @ inode_xp  : extended pointer on the remote inode.
    359  * @ size      : requested size value.
    360  *****************************************************************************************/
    361 void vfs_inode_update_size( xptr_t   inode_xp,
    362                             uint32_t size );
    363 
    364 /******************************************************************************************
    365  * This function takes the main lock of a remote inode identified by the <inode_xp>.
    366  * This lock protect all inode fields, including the children dentries.
    367  * It can be called by any thread running in any cluster.
    368  *****************************************************************************************
    369  * @ inode_xp  : extended pointer on the remote inode.
    370  *****************************************************************************************/
    371 void vfs_inode_lock( xptr_t inode_xp );
    372 
    373 /******************************************************************************************
    374  * This function releases the main lock of a remote inode identified by <inode_xp>.
    375  * This lock protect all inode fiels, including the children dentries.
    376  * It can be called by any thread running in any cluster.
    377  *****************************************************************************************
    378  * @ inode_xp  : extended pointer on the remote inode.
    379  *****************************************************************************************/
    380 void vfs_inode_unlock( xptr_t inode_xp );
    381 
    382 /******************************************************************************************
    383  * This debug function copies the name of a remote inode identified by the <inode_xp>
    384  * argument to a local buffer identified by the <name> argument.
    385  * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
    386  * It can be called by any thread running in any cluster.
    387  ******************************************************************************************
    388  * @ inode_xp  : extended pointer on the remote inode.
    389  * @ name      : local buffer pointer.
    390  *****************************************************************************************/
    391 void vfs_inode_get_name( xptr_t inode_xp,
    392                          char * name );
    393 
    394 /******************************************************************************************
    395  * This function accesses successively all pages of a file identified by the <inode_xp>,
    396  * argument, to force misses, and load all pages into mapper.
    397  * The target inode can be a directory or a file, but this function is mainly used
    398  * to prefetch a complete directory to the mapper.
    399  * This function does NOT take any lock.
    400  * It can be called by any thread running in any cluster.
    401  ******************************************************************************************
    402  * @ inode_xp  : extended pointer on inode.
    403  * @ return 0 if success / return -1 if device access failure.
    404  *****************************************************************************************/
    405 error_t vfs_inode_load_all_pages( xptr_t inode_xp );
    406 
    407 /******************************************************************************************
    408  * This debug function display the curren state of an inode descriptor.
    409  * It can be called by any thread running in any cluster.
    410  *****************************************************************************************/
    411 void vfs_inode_display( xptr_t inode_xp );
    412 
    413 /******************************************************************************************
    414466 *        These low-level functions access / modify a VFS dentry descriptor
    415467 *****************************************************************************************/
     
    442494
    443495
    444 /******************************************************************************************
    445  *        These low-level functions access / modify a VFS file descriptor
    446  *****************************************************************************************/
    447 
    448 /******************************************************************************************
    449  * This function allocates memory and initializes a new file descriptor in the
    450  * cluster defined by the <inode_xp> argument.
    451  * It can be called by any thread running in any cluster.
    452  ******************************************************************************************
    453  * @ inode_xp  : [in]  extended pointer on associated inode.
    454  * @ attr      : [in]  file descriptor attributes.
    455  * @ file_xp   : [out] buffer for extended pointer on created file descriptor.
    456  * @ return 0 if success / return ENOMEM if error.
    457  *****************************************************************************************/
    458 error_t vfs_file_create( xptr_t        inode_xp,
    459                          uint32_t      attr,
    460                          xptr_t      * file_xp ); 
    461 
    462 /******************************************************************************************
    463  * This function releases memory allocated to file descriptor identified
    464  * by the <file_xp> argument.
    465  * It can be called by any thread running in any cluster.
    466  ******************************************************************************************
    467  * @ file_xp  : [in] extended pointer on file descriptor.
    468  *****************************************************************************************/
    469 void vfs_file_destroy( xptr_t  file_xp ); 
    470 
    471 /******************************************************************************************
    472  * These functions increment (resp. decrement) the count field in a remote file
    473  * descriptor, using a remote_atomic access.
    474  *****************************************************************************************
    475  * @ file_xp  : extended pointer on file descriptor.
    476  *****************************************************************************************/
    477 void vfs_file_count_up  ( xptr_t   file_xp );
    478 void vfs_file_count_down( xptr_t   file_xp );
    479 
    480 /******************************************************************************************
    481  * This debug function copies the name of a the file identified by <file_xp>
    482  * argument to a local buffer identified by the <name> argument.
    483  * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
    484  *****************************************************************************************
    485  * @ ionde_xp  : [in] extended pointer on the remote inode.
    486  * @ name      : [out] local string.
    487  ***************************************************************************************/
    488 void vfs_file_get_name( xptr_t inode_xp,
    489                         char * name );
     496
     497
    490498
    491499
     
    532540 *   the missing dentry/inode couple, from informations found in the parent directory.
    533541 * - If this directory entry does not exist on IOC, it returns an error.
    534  * - If the the file identified by the pathname does not exist on IOC but the
     542 * - If the file identified by the pathname does not exist on IOC but the
    535543 *   flag CREATE is set, the inode is created. It returns an error otherwise.
    536544 * - If the the file identified by the pathname exist on device, but both flags EXCL
     
    539547 *   inode, and copies in <last_name> buffer a string containing the last name in path.
    540548 *
    541  * WARNING : The remote_rwlock protecting the Inode Tree must be taken by the caller.
     549 * WARNING : The lock protecting the Inode Tree must be taken in read mode by the caller.
    542550 *
    543551 * TODO the access rights are not checked yet.
     
    558566/******************************************************************************************
    559567 * This function creates a new couple dentry/inode, and insert it in the Inode-Tree.
    560  * Only the distributed Inode Tree is modified: it does NOT modify the parent mapper,
     568 * Only the distributed Inode-Tree is modified: it does NOT modify the parent mapper,
    561569 * and does NOT update the FS on IOC device.
    562  * It set the inode type to the default INODE_TYPE_FILE value
     570 * It set the inode type to the default FILE_TYPE_REG value.
    563571 * It can be executed by any thread running in any cluster (can be different from both
    564572 * the child cluster and the parent cluster).
    565573 * The new child inode and the parent inode can have different FS types.
    566  * [Implementation note]
     574 *
     575 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller.
     576 ******************************************************************************************
     577 * Implementation note
    567578 * As there are cross-references between inode and dentry, this function implements
    568579 * a five steps scenario :
     
    591602
    592603/******************************************************************************************
    593  * This function removes a remote dentry from the Inode-Tree.
     604 * This function removes a remote dentry and the associated inode from the Inode-Tree.
    594605 * - It removes the dentry from the parent inode xhtab ("children" field), and from the
    595606 *   child inode xlist ("parents" field).
     
    601612 * It can be executed by any thread running in any cluster (can be different from both
    602613 * the inode cluster and the dentry cluster).
     614 *
     615 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller.
    603616 ******************************************************************************************
    604617 * @ dentry_xp   : extended pointer on removed dentry.
     
    613626 * This function is called by all functions creating a brand new directory : vfs_mkdir(),
    614627 * devfs_global_init(), and devfs_local_init().
     628 *
     629 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller.
    615630 ******************************************************************************************
    616631 * @ child_xp    : extended pointer on new directory inode.
     
    624639 * This recursive function diplays a complete inode/dentry sub-tree.
    625640 * Any inode can be selected as the sub-tree root.
    626  * WARNING : this function is not protected against a concurrent inode/dentry removal...
     641 *
     642 * TODO : this function should be protected against a concurrent Inode-Tree change.
    627643 ******************************************************************************************
    628644 * @ inode_xp   : extended pointer on sub-tree root inode.
     
    632648/******************************************************************************************
    633649 * This function mount a given file system type for a given process
    634  * TODO non implemented yet [AG].     
     650 * TODO non implemented [AG].     
    635651 *****************************************************************************************/
    636652error_t vfs_mount_fs_root( struct device_s  * device,
     
    829845
    830846/******************************************************************************************
    831  * This function  creates a new directory as defined by the <root_xp> & <path> arguments.
    832  * TODO not implemented yet...
     847 * This function  creates a new inode/dentry couple for a new directory, and registers it
     848 * in the Inode Tree, as defined by the <root_xp>,  <path>, and <mode> arguments.
    833849 ******************************************************************************************
    834850 * @ root_xp  : extended pointer on the path root directory.
     
    855871 * This function change the access rigths for the file/directory identified by the
    856872 * <root_xp> and <path> arguments as defined by the <mode> argument value.
     873 * TODO not implemented yet
    857874 ******************************************************************************************
    858875 * @ root_xp  : extended pointer on the path root directory.
     
    866883
    867884/******************************************************************************************
    868  * This function creates a named FIFO file.
    869  * TODO not implemented yet                                                         
     885 * This function creates a new inode/dentry couple of FIFO type, and registers it
     886 * in the Inode Tree as specified by the <root_xp>, <path>, and <mode> arguments.
    870887 ******************************************************************************************
    871  * @ root_xp  : extended pointer on the path root directory.
    872  * @ path     : pathname (absolute or relative to CWD).
    873  * @ mode     : access rights new value.
     888 * @ root_xp  : [in] extended pointer on the root directory in path.
     889 * @ path     : [in] pathname (absolute or relative to CWD).
     890 * @ mode     : [in] access rights new value.
    874891 *****************************************************************************************/
    875892error_t vfs_mkfifo( xptr_t       root_xp,
Note: See TracChangeset for help on using the changeset viewer.