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


Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (5 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

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

    r14 r23  
    22 * vfs.h - Virtual File System definition.
    33 *
    4  * Author  Mohamed Lamine Karaoui (2015)
    5  *         Alain Greiner (2016)
     4 * Author  Mohamed Lamine Karaoui (2014,2015)
     5 *         Alain Greiner (2016,2017)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    4242#include <fatfs.h>
    4343#include <ramfs.h>
     44#include <devfs.h>
    4445
    4546/****  Forward declarations  ***/
     
    6364struct device_s;
    6465struct 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
     66struct page_s;
     67
     68
     69/******************************************************************************************
     70 * These flags are used to define the working mode of the vfs_lookup() function. 
     71 *****************************************************************************************/
     72
     73#define VFS_LOOKUP_DIR      0x01     /* the searched inode is a directory                */
     74#define VFS_LOOKUP_OPEN         0x02     /* the search is for an open/opendir                */
     75#define VFS_LOOKUP_PARENT       0x04     /* return the parent inode (not the inode itself)   */
     76#define VFS_LOOKUP_CREATE   0x10     /* file must be created if missing                  */
     77#define VFS_LOOKUP_EXCL     0x20     /* file cannot previously exist                     */   
     78
     79/******************************************************************************************
     80 * This define the masks for the POSIX access rights to inodes
     81 *****************************************************************************************/
     82
     83#define VFS_ISUID                0x0004000
     84#define VFS_ISGID                0x0002000
     85#define VFS_ISVTX                0x0001000
    12386
    12487#define VFS_IRWXU            0x0000700
     
    12689#define VFS_IWUSR            0x0000200
    12790#define VFS_IXUSR            0x0000100
     91
    12892#define VFS_IRWXG            0x0000070
    12993#define VFS_IRGRP            0x0000040
    13094#define VFS_IWGRP            0x0000020
    13195#define VFS_IXGRP            0x0000010
     96
    13297#define VFS_IRWXO            0x0000007
    13398#define VFS_IROTH            0x0000004
     
    139104#define VFS_IEXEC            VFS_IXUSR
    140105
    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 
     106
     107/******************************************************************************************
     108 * This structure defines informations common to all inodes and dentries
     109 * of a given file system. As it is declared a global variable in the kdata segment,
     110 * it is replicated in all clusters and handled as private by each OS intance.
     111 *****************************************************************************************/
     112
     113typedef enum
     114{
     115        FS_TYPE_DEVFS = 0,
     116        FS_TYPE_FATFS = 1,
     117        FS_TYPE_RAMFS = 2,
     118 
     119        FS_TYPES_NR   = 3,
     120}
     121vfs_fs_type_t;
     122
     123typedef enum
     124{
     125    CTX_ATTR_READ_ONLY    = 0x01,            /*! write access prohibited                 */
     126    CTX_ATTR_SYNC         = 0x10,            /*! synchronise FS on each write            */
     127}
     128vfs_ctx_attr_t;
     129
     130typedef struct vfs_ctx_s
     131{
     132        vfs_fs_type_t  type;                     /*! File System type                        */
     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          */
     137    spinlock_t     lock;                     /*! lock protecting inum allocator          */
     138    uint32_t       bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)];  /* inum allocator        */
     139    void         * extend;                   /*! FS specific context extension           */
     140}
     141vfs_ctx_t;
    161142
    162143/******************************************************************************************
     
    166147 * The <parent> inode is unique for a directory (not hard links for directories).
    167148 * For a file, the parent field points to the first dentry who created this inode.
    168  * Syncronisation:
     149 * Syncrhonisation:
    169150 * - the main_lock (spinlock) is used during the inode tree traversal or for inode
    170151 *   modification (add/remove children).
     
    172153 *   in the mapper.
    173154 * - the mapper lock (rwlock) is only used during the radix tree traversal to return
    174  *   to return the relevant page for red/write.
    175  *****************************************************************************************/
     155 *   the relevant page for read/write.
     156 *****************************************************************************************/
     157
     158/* this enum define the VFS inode types values */
    176159
    177160typedef enum   
    178161{
    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                           */
     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                               */
    183169}
    184170vfs_inode_type_t;
    185171
     172/* this enum define the VFS inode attributes values */
     173
    186174typedef enum
    187175{
    188     INODE_ATTR_DIRTY  = 0x01,
    189     INODE_ATTR_DIR    = 0x02,
    190     INODE_ATTR_INLOAD = 0x04,
    191     INODE_ATTR_NEW    = 0x08,
     176    INODE_ATTR_DIRTY   =     0x01,       /* modified versus the value on device          */
     177    INODE_ATTR_INLOAD  =     0x04,       /* loading from device in progress              */
     178    INODE_ATTR_NEW     =     0x08,       /* not saved on device yet                      */
    192179}
    193180vfs_inode_attr_t;
     
    195182typedef struct vfs_inode_s
    196183{
    197         struct vfs_ctx_s      * ctx;         /*! Rlocal pointer on FS context                */
     184        struct vfs_ctx_s      * ctx;         /*! local pointer on FS context                 */
    198185    uint32_t                gc;          /*! generation counter                          */
    199186        uint32_t                inum;        /*! inode identifier (unique in file system)    */
    200187        uint32_t                attr;        /*! inode attributes (see above)                */
    201         uint32_t                type;        /*! inode type (see above)                      */
     188        vfs_inode_type_t        type;        /*! inode type (see above)                      */
    202189        uint32_t                size;        /*! number of bytes                             */
    203190        uint32_t                links;       /*! number of alias dentry                      */
    204191        uid_t                   uid;         /*! user owner identifier                       */
    205192        gid_t                   gid;         /*! group owner identifier                      */
    206     uint32_t                mode;        /*! access mode                                 */
     193    uint32_t                rights;      /*! access rights                               */
    207194        uint32_t                    refcount;    /*! reference counter (all pointers)            */
    208195        xptr_t                  parent_xp;   /*! extended pointer on parent dentry           */
    209         xhtab_t                 children;    /*! embedded htab of dir entries (for dir type) */
     196        xhtab_t                 children;    /*! embedded xhtab of vfs_dentry_t              */
    210197        remote_rwlock_t         data_lock;   /*! protect read/write to data and to size      */
    211198        remote_spinlock_t       main_lock;   /*! protect inode tree traversal and modifs     */
    212         xlist_entry_t           xlist;       /*! member of set of inodes in same cluster     */
     199        list_entry_t            list;        /*! member of set of inodes in same cluster     */
    213200        xlist_entry_t           wait_root;   /*! root of threads waiting on this inode       */
    214201        struct vfs_inode_op_s * op;          /*! TODO ???                                    */
     
    240227
    241228/******************************************************************************************
    242  * This structure describes an open file/directory for a given process.
     229 * This file structure describes an open file/directory for a given process.
    243230 * It is not replicated, and is dynamically allocated in the cluster that contains
    244231 * the inode, when a thread makes an open() or opendir() system call.
    245  *****************************************************************************************/
    246 
     232 * It cannot exist a file structure without an inode structure.
     233 * Aa the fd_array (containing extended pointers on the open file descriptors)
     234 * is replicated in all process descriptors, we need a references counter.
     235 *****************************************************************************************/
    247236
    248237typedef enum
    249238{
    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                          */
    256 }
    257 vfs_fd_attr_t;
     239    FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                         */
     240    FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                        */
     241    FD_ATTR_APPEND         = 0x04,     /*! append on each write                         */
     242    FD_ATTR_CLOSE_EXEC     = 0x08,     /*! close file on exec                           */
     243    FD_ATTR_SYNC           = 0x10,     /*! synchronise FS on each write                 */
     244    FD_ATTR_IS_DIR         = 0x20,     /*! this is a directory                          */
     245}
     246vfs_file_attr_t;
    258247
    259248typedef struct vfs_file_s
    260249{
     250        struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
    261251        uint32_t                gc;         /*! generation counter                           */
    262         uint32_t                type;       /*! see above                                    */
    263         uint32_t                attr;       /*! see above                                    */
     252        vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
     253        vfs_inode_type_t        type;       /*! same type as inode                           */
    264254        uint32_t                offset;     /*! seek position in file                        */
    265         uint32_t                refcount;   /*! all pointers on this file                    */
    266         remote_rwlock_t       lock;       /*! protect offset modifications                 */
     255        uint32_t                refcount;   /*! all pointers on this file descriptor         */
     256        remote_rwlock_t         lock;       /*! protect offset modifications                 */
    267257        struct mapper_s       * mapper;     /*! associated file cache                        */
    268258        struct vfs_inode_s    * inode;      /*! local pointer on associated inode            */
    269         struct vfs_ctx_s      * ctx;        /*! file system features                         */
    270         struct vfs_file_op_s  * op;         /*! local set of function pointers               */
     259        void                  * extend;     /*! FS specific extension                        */
    271260}
    272261vfs_file_t;
    273262
    274263/******************************************************************************************
    275  * This structure defines informations common to all inodes and dentries
    276  * of a given file system. As it is declared a global variable in the kdata segment,
    277  * it is replicated in all clusters and handled as private by each OS intance.
    278  *****************************************************************************************/
    279 
    280 typedef enum
    281 {
    282         FS_TYPE_SYSFS = 0,
    283         FS_TYPE_DEVFS = 1,
    284         FS_TYPE_FATFS = 2,
    285         FS_TYPE_RAMFS = 3,
    286  
    287         FS_TYPES_NR   = 4,
    288 }
    289 vfs_types_t;
    290 
    291 typedef enum
    292 {
    293     CTX_ATTR_READ_ONLY    = 0x01,       /*! read access possible                         */
    294     CTX_ATTR_SYNC         = 0x10,       /*! synchronise FS on each write                 */
    295 }
    296 vfs_ctx_attr_t;
    297 
    298 typedef struct vfs_ctx_s
    299 {
    300         uint32_t                      type;          /*! File System type                        */
    301         uint32_t                      attr;          /*! global attributes for all files in FS   */
    302         uint32_t                  count;         /*! number of clusters                      */
    303         uint32_t                  blksize;       /*! cluster size                            */
    304     xptr_t                    ioc_xp;        /*! extended pointer on IOC device          */
    305         xptr_t                    root_xp;       /*! extended pointer on root inode          */
    306 
    307     spinlock_t                lock;          /*! lock protecting inum allocator          */
    308         BITMAP( inum , CONFIG_VFS_MAX_INODES );  /*! inum allocator                          */
    309 
    310     void                    * extend;        /*! FS specific context extension           */
    311 }
    312 vfs_ctx_t;
    313 
    314 /******************************************************************************************
    315  * This structure define the informations associated to a given file descriptor,
    316  * that are returned by the vfs_stat() function.
     264 * This structure define the informations associated to a file descriptor,
     265 * returned to user space by the stat() system call.
    317266 *****************************************************************************************/
    318267
     
    335284vfs_stat_t;
    336285
    337 
    338 
    339 
    340 
    341 
    342 /******************************************************************************************
    343  * This structure defines the set of operations that can be done on a VFS context.
    344  * TODO A quoi cela sert-il ? [AG]
    345  *****************************************************************************************/
    346 
    347 typedef error_t (vfs_create_context_t)  ( vfs_ctx_t * context );
    348 typedef error_t (vfs_destroy_context_t) ( vfs_ctx_t * context );
    349 typedef error_t (vfs_read_root_t)       ( vfs_ctx_t * context , vfs_inode_t * root );
    350 typedef error_t (vfs_reply_root_t)      ( vfs_ctx_t * context , vfs_inode_t * root );
    351 typedef error_t (vfs_write_root_t)      ( vfs_ctx_t * context , vfs_inode_t * root );
    352 
    353 struct vfs_ctx_op_s
    354 {
    355         vfs_create_context_t  * create;      /*! allocate memory and initialize a context   */
    356         vfs_destroy_context_t * destroy;     /*! release memory allocated to a context      */
    357         vfs_read_root_t       * read_root;   /*! TODO                                       */
    358         vfs_reply_root_t      * repli_root;  /*! TODO                                       */
    359         vfs_write_root_t      * write_root;  /*! TODO                                       */
    360 }
    361 vfs_ctx_op_t;
    362 
    363 /******************************************************************************************
    364  * This structure defines the set of operations that can be done on a VFS inode.
    365  * TODO A quoi cela sert-il ? [AG]
    366  *****************************************************************************************/
    367 
    368 typedef error_t (vfs_init_inode_t)    ( vfs_inode_t * inode );
    369 typedef error_t (vfs_create_inode_t)  ( vfs_inode_t * parent , vfs_dentry_t  * dentry );
    370 typedef error_t (vfs_lookup_inode_t)  ( vfs_inode_t * parent , vfs_dentry_t  * dentry );
    371 typedef error_t (vfs_write_inode_t)   ( vfs_inode_t * inode );
    372 typedef error_t (vfs_release_inode_t) ( vfs_inode_t * inode );
    373 typedef error_t (vfs_unlink_inode_t)  ( vfs_inode_t * parent , vfs_dentry_t  * dentry , uint32_t flags );
    374 typedef error_t (vfs_stat_inode_t)    ( vfs_inode_t * inode );
    375 typedef error_t (vfs_trunc_inode_t)   ( vfs_inode_t * inode );
    376 typedef error_t (vfs_delete_inode_t)  ( vfs_inode_t * inode );
    377 
    378 typedef struct vfs_inode_op_s
    379 {
    380         vfs_init_inode_t    * init;     /*! initialise inode from scratch                    */
    381         vfs_create_inode_t  * create;   /*! allocate memory for one inode                    */
    382         vfs_lookup_inode_t  * lookup;   /*! get one directory entry by name                  */
    383         vfs_write_inode_t   * write;    /*! update the device from the inode                 */
    384         vfs_release_inode_t * release;  /*! reset one inode and release associated objects   */
    385         vfs_unlink_inode_t  * unlink;   /*! unlink a directory entry from parent inode       */
    386         vfs_delete_inode_t  * delete;   /*! release memory allocated to inode when count = 0 */
    387         vfs_stat_inode_t    * stat;     /*! TODO                                             */
    388         vfs_trunc_inode_t   * trunc;    /*! change the size of a file                        */
    389 }
    390 vfs_inode_op_t;
    391 
    392 /******************************************************************************************
    393  * This structure defines the set of operations that can be done on a VFS dentry.
    394  * TODO A quoi cela sert-il ? [AG]
    395  *****************************************************************************************/
    396 
    397 typedef error_t (vfs_compare_dentry_t) ( char * first , char * second );
    398 
    399 typedef struct vfs_dentry_op_s
    400 {
    401         vfs_compare_dentry_t * compare;
    402 }
    403 vfs_dentry_op_t;
    404 
    405 /******************************************************************************************
    406  * This structure defines the set of operations that can be done on a VFS file. 
    407  * TODO A quoi cela sert-il ? [AG]
    408  *****************************************************************************************/
    409 
    410 typedef error_t (vfs_open_file_t)    ( vfs_file_t * file , void * priv );
    411 typedef error_t (vfs_read_file_t)    ( vfs_file_t * file , char * buffer );
    412 typedef error_t (vfs_write_file_t)   ( vfs_file_t * file , char * buffer );
    413 typedef error_t (vfs_lseek_file_t)   ( vfs_file_t * file );
    414 typedef error_t (vfs_close_file_t)   ( vfs_file_t * file );
    415 typedef error_t (vfs_release_file_t) ( vfs_file_t * file );
    416 typedef error_t (vfs_read_dir_t)     ( vfs_file_t * file );
    417 typedef error_t (vfs_mmap_file_t)    ( vfs_file_t * file , struct vseg_s * vseg );
    418 typedef error_t (vfs_munmap_file_t)  ( vfs_file_t * file , struct vseg_s * vseg );
    419 
    420 typedef struct vfs_file_op_s
    421 {
    422         vfs_open_file_t    * open;
    423         vfs_read_file_t    * read;
    424         vfs_write_file_t   * write;
    425         vfs_lseek_file_t   * lseek;
    426         vfs_read_dir_t     * readdir;
    427         vfs_close_file_t   * close;
    428         vfs_release_file_t * release;
    429         vfs_mmap_file_t    * mmap;
    430         vfs_munmap_file_t  * munmap;
    431 }
    432 vfs_file_op_t;
    433 
    434 
    435 
     286/*********************************************************************************************
     287 * This structure defines the information associated to a directory entry,
     288 * returned to user space by the readdir() system call.
     289 ********************************************************************************************/
     290
     291typedef struct vfs_dirent_s
     292{
     293    uint32_t    inum;                               /*! inode identifier                    */
     294    uint32_t    type;                               /*! inode type                          */
     295    char        name[CONFIG_VFS_MAX_NAME_LENGTH];   /*! dentry name                         */
     296}
     297vfs_dirent_t;
    436298
    437299
     
    441303/*****************************************************************************************/
    442304
    443 /******************************************************************************************
    444  * This function initializes the Virtual File System.     
    445  *****************************************************************************************/
    446 void vfs_init();
    447 
    448 /******************************************************************************************
    449  * This function mount a given file system type for a given process.     
     305
     306/******************************************************************************************
     307 * This function mount a given file system type for a given process TODO.     
    450308 *****************************************************************************************/
    451309error_t vfs_mount_fs_root( struct device_s  * device,
     
    482340
    483341
    484 /*****************************************************************************************/
    485 /************************ File Descriptor related functions ******************************/
     342
     343/*****************************************************************************************/
     344/********************* Inode related functions *******************************************/
     345/*****************************************************************************************/
     346
     347/******************************************************************************************
     348 * This function allocates memory from local cluster for an inode descriptor and the
     349 * associated mapper. It initialise these descriptors from arguments values.
     350 * The parent dentry must have been previously created.
     351 * If the client thread is not running in the cluster containing this inode,
     352 * it must use the rpc_vfs_inode_create_client() function.
     353 ******************************************************************************************
     354 * @ dentry_xp  : extended pointer on associated dentry (in parent inode cluster).
     355 * @ fs_type    : file system type.
     356 * @ inode_type : inode type.
     357 * @ attr       : inode attributes.
     358 * @ rights     : inode access rights.
     359 * @ uid        : user owner ID.
     360 * @ gid        : group owner ID.
     361 * @ inode_xp   : [out] buffer for extended pointer on created inode.
     362 * # return 0 if success / return ENOMEM or EINVAL if error.
     363 *****************************************************************************************/
     364error_t vfs_inode_create( xptr_t            dentry_xp,
     365                          vfs_fs_type_t     fs_type,
     366                          vfs_inode_type_t  inode_type,
     367                          uint32_t          attr,
     368                          uint32_t          rights,
     369                          uid_t             uid,
     370                          gid_t             gid,
     371                          xptr_t          * inode_xp );
     372
     373/******************************************************************************************
     374 * This function releases memory allocated to an inode descriptor.
     375 * It must be executed by a thread running in the cluster containing the inode,
     376 * and the inode refcount must be zero.
     377 * If the client thread is not running in the owner cluster, it must use the
     378 * rpc_vfs_inode_destroy_client() function.
     379 ******************************************************************************************
     380 * @ inode  : local pointer on inode descriptor.
     381 *****************************************************************************************/
     382void vfs_inode_destroy( vfs_inode_t *  inode ); 
     383
     384/******************************************************************************************
     385 * This function atomically increment/decrement the inode refcount.
     386 * It can be called by any thread running in any cluster.
     387 *****************************************************************************************/
     388void vfs_inode_remote_up( xptr_t  inode_xp );
     389void vfs_inode_remote_down( xptr_t  inode_xp );
     390
     391/******************************************************************************************
     392 * This function returns the <size> of a file/dir from a remote inode,
     393 * taking the remote_rwlock protecting <size> in READ_MODE.
     394 *****************************************************************************************
     395 * @ inode_xp  : extended pointer on the remote inode.
     396 * @ return the current size.
     397 *****************************************************************************************/
     398uint32_t vfs_inode_get_size( xptr_t inode_xp );
     399
     400/******************************************************************************************
     401 * This function set the <size> of a file/dir to a remote inode,
     402 * taking the remote_rwlock protecting <size> in WRITE_MODE.
     403 *****************************************************************************************
     404 * @ inode_xp  : extended pointer on the remote inode.
     405 * @ size      : value to be written.
     406 *****************************************************************************************/
     407void vfs_inode_set_size( xptr_t   inode_xp,
     408                         uint32_t size );
     409
     410/******************************************************************************************
     411 * This function takes the main lock of a remote inode.
     412 * This lock protect all inode fiels, including the children dentries.
     413 *****************************************************************************************
     414 * @ inode_xp  : extended pointer on the remote inode.
     415 *****************************************************************************************/
     416void vfs_inode_remote_lock( xptr_t inode_xp );
     417
     418/******************************************************************************************
     419 * This function releases the main lock of a remote inode.
     420 * This lock protect all inode fiels, including the children dentries.
     421 *****************************************************************************************
     422 * @ inode_xp  : extended pointer on the remote inode.
     423 *****************************************************************************************/
     424void vfs_inode_remote_unlock( xptr_t inode_xp );
     425
     426
     427
     428
     429/******************************************************************************************
     430 * This function TODO                                                         
     431 *****************************************************************************************/
     432error_t vfs_inode_hold( vfs_inode_t * inode,
     433                        uint32_t      gc );
     434
     435/******************************************************************************************
     436 * This function TODO                                                         
     437 *****************************************************************************************/
     438error_t vfs_inode_trunc( vfs_inode_t * inode );
     439
     440/******************************************************************************************
     441 * This function TODO                                                         
     442 *****************************************************************************************/
     443error_t vfs_inode_link( vfs_inode_t * inode,
     444                        uint32_t      igc );
     445
     446/******************************************************************************************
     447 * This function TODO                                                         
     448 *****************************************************************************************/
     449error_t vfs_inode_unlink( vfs_inode_t * inode );
     450
     451/******************************************************************************************
     452 * This function TODO                                                         
     453 *****************************************************************************************/
     454error_t vfs_inode_stat( vfs_inode_t * inode,
     455                        uint32_t      inum );
     456
     457/******************************************************************************************
     458 * This function TODO                                                         
     459 *****************************************************************************************/
     460error_t vfs_icache_del( vfs_inode_t * inode );
     461
     462
     463/******************************************************************************************
     464 * This function TODO  Pourquoi 2 arguments ?
     465 *****************************************************************************************/
     466error_t vfs_stat_inode( vfs_inode_t * inode,
     467                        uint32_t      inum );
     468
     469
     470/*****************************************************************************************/
     471/***************** Dentry related functions **********************************************/
     472/*****************************************************************************************/
     473
     474/******************************************************************************************
     475 * This function allocates memory from local cluster for a dentry descriptor,
     476 * initialises it from  arguments values, and returns the extended pointer on dentry.
     477 * The inode field is not initialized, because the inode does not exist yet.
     478 * If the client thread is not running in the target cluster for this inode,
     479 * it must use the rpc_dentry_create_client() function.
     480 ******************************************************************************************
     481 * @ fs_type    : file system type.
     482 * @ name       : directory entry file/dir name.
     483 * @ parent     : local pointer on parent inode.
     484 * @ dentry_xp  : [out] buffer for extended pointer on created dentry.
     485 * @ return 0 if success / return ENOMEM or EINVAL if error.
     486 *****************************************************************************************/
     487error_t vfs_dentry_create( vfs_fs_type_t   fs_type,
     488                           char          * name,
     489                           vfs_inode_t   * parent,
     490                           xptr_t        * dentry_xp );
     491 
     492/******************************************************************************************
     493 * This function releases memory allocated to a dentry descriptor.
     494 * It must be executed by a thread running in the cluster containing the dentry,
     495 * and the dentry refcount must be zero.
     496 * If the client thread is not running in the owner cluster, it must use the
     497 * rpc_dentry_destroy_client() function.
     498 ******************************************************************************************
     499 * @ dentry  : local pointer on dentry descriptor.
     500 *****************************************************************************************/
     501void vfs_dentry_destroy( vfs_dentry_t *  dentry ); 
     502
     503/******************************************************************************************
     504 * These functions atomically increment/decrement the dentry refcount.
     505 * It can be called by any thread running in any cluster.
     506 *****************************************************************************************/
     507void vfs_dentry_remote_up( xptr_t dentry_xp );
     508void vfs_dentry_remote_down( xptr_t dentry_xp );
     509
     510
     511/*****************************************************************************************/
     512/************************ File descriptor related functions ******************************/
    486513/*****************************************************************************************/
    487514
    488515/******************************************************************************************
    489516 * This function allocates memory and initializes a new local file descriptor.
    490  * It must be executed in the owner cluster containing the inode.
     517 * It must be executed in the cluster containing the inode.
    491518 * If the client thread is not running in the owner cluster, it must use the
    492519 * rpc_vfs_file_create_client() function.
    493520 ******************************************************************************************
    494  * @ inode_xp : extended pointer on associated inode.
    495  * @ type     : file descriptor type.
     521 * @ inode    : local pointer on associated inode.
    496522 * @ attr     : file descriptor attributes.
    497523 * @ file_xp  : [out] buffer for extended pointer on created file descriptor.
    498524 * @ return 0 if success / return ENOMEM if error.
    499525 *****************************************************************************************/
    500 error_t vfs_file_create( xptr_t     inode_xp,
    501                          uint32_t   type,
    502                          uint32_t   attr,
    503                          xptr_t   * file_xp ); 
     526error_t vfs_file_create( vfs_inode_t * inode,
     527                         uint32_t      attr,
     528                         xptr_t      * file_xp ); 
    504529
    505530/******************************************************************************************
     
    510535 * rpc_vfs_file_destroy_client() function.
    511536 ******************************************************************************************
    512  * @ file_xp  : extended pointer on file descriptor.
    513  *****************************************************************************************/
    514 void vfs_file_destroy( xptr_t  file_xp ); 
    515 
     537 * @ file  : local pointer on file descriptor.
     538 *****************************************************************************************/
     539void vfs_file_destroy( vfs_file_t *  file ); 
    516540
    517541/******************************************************************************************
     
    525549
    526550/*****************************************************************************************/
    527 /********************* Inode related functions *******************************************/
    528 /*****************************************************************************************/
    529 
    530 /******************************************************************************************
    531  * This function allocates memory from local cluster for an inode descriptor and the
    532  * associated mapper. It initialise these descriptors from arguments values.
    533  * The parent dentry must have been previously created.
    534  * If the client thread is not running in the cluster containing this inode,
    535  * it must use the rpc_vfs_inode_create_client() function.
    536  ******************************************************************************************
    537  * @ dentry_xp  : extended pointer on associated dentry (in parent inode cluster).
    538  * @ type       : file system type.
    539  * @ attr       : inode attributes.
    540  * @ mode       : inode access mode.
    541  * @ uid        : user owner ID.
    542  * @ gid        : group owner ID.
    543  * @ inode_xp   : [out] buffer for extended pointer on created inode.
    544  * # return 0 if success / return ENOMEM or EINVAL if error.
    545  *****************************************************************************************/
    546 error_t vfs_inode_create( xptr_t      dentry_xp,
    547                           uint32_t    type,
    548                           uint32_t    attr,
    549                           uint32_t    mode,
    550                           uid_t       uid,
    551                           gid_t       gid,
    552                           xptr_t    * inode_xp );
    553 
    554 /******************************************************************************************
    555  * This function releases memory allocated to an inode descriptor.
    556  * It must be executed by a thread running in the cluster containing the inode,
    557  * and the inode refcount must be zero.
    558  * If the client thread is not running in the owner cluster, it must use the
    559  * rpc_vfs_inode_destroy_client() function.
    560  ******************************************************************************************
    561  * @ inode  : local pointer on inode descriptor.
    562  *****************************************************************************************/
    563 void vfs_inode_destroy( vfs_inode_t *  inode ); 
    564 
    565 /******************************************************************************************
    566  * This function atomically increment the inode refcount.
    567  * It can be called by any thread running in any cluster.
    568  *****************************************************************************************/
    569 void vfs_inode_remote_up( xptr_t  inode_xp );
    570 
    571 /******************************************************************************************
    572  * This function atomically decrement the inode refcount.
    573  * It can be called by any thread running in any cluster.
    574  *****************************************************************************************/
    575 void vfs_inode_remote_down( xptr_t  inode_xp );
    576 
    577 /******************************************************************************************
    578  * This function returns the <size> of a file/dir from a remote inode,
    579  * taking the remote_rwlock protecting <size> in READ_MODE.
    580  *****************************************************************************************
    581  * @ inode_xp  : extended pointer on the remote inode.
    582  * @ return the current size.
    583  *****************************************************************************************/
    584 uint32_t vfs_inode_get_size( xptr_t inode_xp );
    585 
    586 /******************************************************************************************
    587  * This function set the <size> of a file/dir to a remote inode,
    588  * taking the remote_rwlock protecting <size> in WRITE_MODE.
    589  *****************************************************************************************
    590  * @ inode_xp  : extended pointer on the remote inode.
    591  * @ size      : value to be written.
    592  *****************************************************************************************/
    593 void vfs_inode_set_size( xptr_t   inode_xp,
    594                          uint32_t size );
    595 
    596 /******************************************************************************************
    597  * This function takes the main lock of a remote inode.
    598  * This lock protect all inode fiels, including the children dentries.
    599  *****************************************************************************************
    600  * @ inode_xp  : extended pointer on the remote inode.
    601  *****************************************************************************************/
    602 void vfs_inode_remote_lock( xptr_t inode_xp );
    603 
    604 /******************************************************************************************
    605  * This function releases the main lock of a remote inode.
    606  * This lock protect all inode fiels, including the children dentries.
    607  *****************************************************************************************
    608  * @ inode_xp  : extended pointer on the remote inode.
    609  *****************************************************************************************/
    610 void vfs_inode_remote_unlock( xptr_t inode_xp );
    611 
    612 
    613 
    614 
    615 /******************************************************************************************
    616  * This function TODO                                                         
    617  *****************************************************************************************/
    618 error_t vfs_inode_hold( vfs_inode_t * inode,
    619                         uint32_t      gc );
    620 
    621 /******************************************************************************************
    622  * This function TODO                                                         
    623  *****************************************************************************************/
    624 error_t vfs_inode_trunc( vfs_inode_t * inode );
    625 
    626 /******************************************************************************************
    627  * This function TODO                                                         
    628  *****************************************************************************************/
    629 error_t vfs_inode_link( vfs_inode_t * inode,
    630                         uint32_t      igc );
    631 
    632 /******************************************************************************************
    633  * This function TODO                                                         
    634  *****************************************************************************************/
    635 error_t vfs_inode_unlink( vfs_inode_t * inode );
    636 
    637 /******************************************************************************************
    638  * This function TODO                                                         
    639  *****************************************************************************************/
    640 error_t vfs_inode_stat( vfs_inode_t * inode,
    641                         uint32_t      inum );
    642 
    643 /******************************************************************************************
    644  * This function TODO                                                         
    645  *****************************************************************************************/
    646 error_t vfs_icache_del( vfs_inode_t * inode );
    647 
    648 
    649 /******************************************************************************************
    650  * This function TODO  Pourquoi 2 arguments ?
    651  *****************************************************************************************/
    652 error_t vfs_stat_inode( vfs_inode_t * inode,
    653                         uint32_t      inum );
    654 
    655 
    656 /*****************************************************************************************/
    657 /***************** Dentry related functions **********************************************/
    658 /*****************************************************************************************/
    659 
    660 /******************************************************************************************
    661  * This function allocates memory from local cluster for a dentry descriptor,
    662  * initialises it from  arguments values, and returns the extended pointer on dentry.
    663  * The inode field is not initialized, because the inode does not exist yet.
    664  * If the client thread is not running in the target cluster for this inode,
    665  * it must use the rpc_dentry_create_client() function.
    666  ******************************************************************************************
    667  * @ type       : file system type.
    668  * @ name       : directory entry file/dir name.
    669  * @ parent     : local pointer on parent inode.
    670  * @ dentry_xp  : [out] buffer for extended pointer on created inode.
    671  * @ return 0 if success / return ENOMEM or EINVAL if error.
    672  *****************************************************************************************/
    673 error_t vfs_dentry_create( uint32_t      type,
    674                            char        * name,
    675                            vfs_inode_t * parent,
    676                            xptr_t      * dentry_xp );
    677  
    678 /******************************************************************************************
    679  * This function releases memory allocated to a dentry descriptor.
    680  * It must be executed by a thread running in the cluster containing the dentry,
    681  * and the dentry refcount must be zero.
    682  * If the client thread is not running in the owner cluster, it must use the
    683  * rpc_dentry_destroy_client() function.
    684  ******************************************************************************************
    685  * @ dentry  : local pointer on dentry descriptor.
    686  *****************************************************************************************/
    687 void vfs_dentry_destroy( vfs_dentry_t *  dentry ); 
    688 
    689 /******************************************************************************************
    690  * This function atomically increment the dentry refcount.                               
    691  * It can be called by any thread running in any cluster.
    692  *****************************************************************************************/
    693 void vfs_dentry_remote_up( xptr_t dentry_xp );
    694 
    695 /******************************************************************************************
    696  * This function atomically decrement the dentry refcount.                               
    697  * It can be called by any thread running in any cluster.
    698  *****************************************************************************************/
    699 void vfs_dentry_remote_down( xptr_t dentry_xp );
    700 
    701 
    702 /*****************************************************************************************/
    703 /*                 Inode-Tree related functions                                          */
     551/******************* Inode-Tree related functions ****************************************/
    704552/*****************************************************************************************/
    705553
     
    721569/******************************************************************************************
    722570 * This function takes a pathname (absolute or relative to cwd) and returns an extended
    723  * pointer on the associated inode, and an extended pointer on the inode context.
    724  * If a given name in the path is not found in the inode tree, it try to load the missing
    725  * dentry/inode couple, from informations found in the parent directory.
    726  * If this directory entry does not exist on device, it returns an error.
    727  ******************************************************************************************
    728  * @ cwd_xp     : extended pointer on current directory (for relative path).
    729  * @ pathname   : path in kernel space (can be relative or absolute).
    730  * @ client_uid : client thread user ID (for checking).
    731  * @ client_gid : client thread group ID (for checking).
    732  * @ inode_xp   : [out] buffer for extended pointer on inode.
    733  * @ ctx_xp     : [out] buffer for extended pointer on inode context.
    734  * @ return 0 if success / ENOENT if inode not found / EACCES if permissopn denied
    735  *****************************************************************************************/
    736 error_t vfs_lookup( xptr_t       cwd_xp,
    737                     char       * pathname,
    738                     uint32_t     client_uid,
    739                     uint32_t     client_gid,
    740                                         xptr_t     * inode_xp,
    741                     xptr_t     * ctx_xp );
     571 * pointer on the associated inode.
     572 * - If a given name in the path is not found in the inode tree, it try to load the missing
     573 *   dentry/inode couple, from informations found in the parent directory.
     574 * - If this directory entry does not exist on device, it returns an error.
     575 * - If the the file identified by the pathname does not exist on device but the
     576 *   flag CREATE is set, the inode is created.
     577 * - If the the file identified by the pathname exist on device but both flags EXCL
     578 *   and CREATE are set, an error is returned.
     579 ******************************************************************************************
     580 * @ cwd_xp      : extended pointer on current directory (for relative path).
     581 * @ pathname    : path in kernel space (can be relative or absolute).
     582 * @ lookup_mode : flags defining the working mode (defined above in this file).
     583 * @ inode_xp    : [out] buffer for extended pointer on inode.
     584 * @ return 0 if success / ENOENT if inode not found , EACCES if permissopn denied,
     585 *                        EAGAIN if a new complete lookup must be made
     586 *****************************************************************************************/
     587error_t vfs_lookup( xptr_t             cwd_xp,
     588                    char             * pathname,
     589                    uint32_t           lookup_mode,
     590                                        xptr_t           * inode_xp );
    742591
    743592/******************************************************************************************
     
    747596 * - The dentry is created in the cluster containing the existing <parent_xp> inode.
    748597 * - the child inode and its associated mapper are created in a randomly selected cluster.
    749  * - The dentry name is defined by the <name> argument.
    750  ******************************************************************************************
    751  * @ type       : new inode type
     598 * - The new dentry name is defined by the <name> argument.
     599 * - The new inode and the parent inode can have different FS types.
     600 ******************************************************************************************
     601 * @ inode_type : new inode type
     602 * @ fs_type    : new inode FS type.
    752603 * @ parent_xp  : extended pointer on parent inode.
    753604 * @ name       : new directory entry name.
     
    755606 * @ return 0 if success / ENOENT if entry not found in parent directory
    756607 *****************************************************************************************/
    757 error_t vfs_add_child_in_parent( uint32_t type,
    758                                  xptr_t   parent_xp,
    759                                  char   * name,   
    760                                  xptr_t * child_xp );
    761 
    762 /******************************************************************************************
    763  * TODO
     608error_t vfs_add_child_in_parent( vfs_inode_type_t   inode_type,
     609                                 vfs_fs_type_t      fs_type,
     610                                 xptr_t             parent_xp,
     611                                 char             * name,   
     612                                 xptr_t           * child_xp );
     613
     614/******************************************************************************************
     615 * This function removes a couple dentry/inode from the Inode-Tree, and remove it from
     616 * the external device.
     617 * TODO                   
    764618 ******************************************************************************************
    765619 * @ child_xp   : extended pointer on removed inode.
     
    767621error_t vfs_remove_child_from_parent( xptr_t child_xp );
    768622
    769 /*****************************************************************************************/
    770 /************************ File related functions *****************************************/
     623
     624
     625
     626
     627
     628/*****************************************************************************************/
     629/****************** File access API ******************************************************/
    771630/*****************************************************************************************/
    772631
    773632/******************************************************************************************
    774633 * This function allocates a vfs_file_t structure in the cluster containing the inode
    775  * associated to the requested file, initializes it, and returns an extended pointer
    776  * on this remote open file descriptor.
     634 * associated to the file identified by <cwd_xp> & <path>.
     635 * It initializes it, register it in the reference process fd_array, and returns both
     636 * the extended pointer on the remote file descriptor, and the index in the fd_array.
    777637 * The pathname can be relative to current directory or absolute.
    778  * If the inode does not exist in the inode cache, it try to find file on the mounted
     638 * If the inode does not exist in the inode cache, it try to find the file on the mounted
    779639 * device, and creates an inode on a pseudo randomly selected cluster if found.
    780640 * It the requested file does not exist on device, it creates a new inode if the
    781641 * O_CREAT flag is set and return an error otherwise.
    782642 ******************************************************************************************
    783  * @ cwd_xp    : extended pointer on current directory file descriptor (for relative path).
    784  * @ path      : file pathname (absolute or relative to current directory).
    785  * @ flags     : O_RDONLY, O_WRONLY, O_CREATE etc...
    786  * @ file_xp   : [out] buffer for extended pointer on created remote file descriptor.
     643 * @ cwd_xp      : extended pointer on current working directory file descriptor.
     644 * @ path        : file pathname (absolute or relative to current directory).
     645 * @ flags       : defined above
     646 * @ mode        : access rights (as defined by chmod)
     647 * @ file_xp     : [out] buffer for extended pointer on created remote file descriptor.
     648 * @ file_id     : [out] buffer for created file descriptor index in reference fd_array.
    787649 * @ return 0 if success / return non-zero if error.
    788650 *****************************************************************************************/
     
    790652                          char     * path,
    791653                          uint32_t   flags,
    792                           xptr_t   * file_xp );
    793 
    794 /******************************************************************************************
    795  * This function moves <size> bytes from the file identified by the open file descriptor
    796  * <file_xp> to the local kernel <buffer> , taken into account the offset in <file_xp>.
    797  ******************************************************************************************
    798  * @ file_xp   : extended pointer on the remote open file descriptor.
    799  * @ buffer    : local pointer on destination kernel buffer.
     654                  uint32_t   mode,
     655                          xptr_t   * file_xp,
     656                          uint32_t * file_id );
     657
     658/******************************************************************************************
     659 * This function moves <size> bytes between the file identified by the open file descriptor
     660 * <file_xp> and a local kernel <buffer> , taken into account the offset in <file_xp>.
     661 * The transfer direction is defined by the <to_buffer> argument.
     662 ******************************************************************************************
     663 * @ to_buffer : mapper -> buffer if true / buffer->mapper if false.
     664 * @ file_xp   : extended pointer on the remote file descriptor.
     665 * @ buffer    : local pointer on local kernel buffer.
    800666 * @ size      : requested number of bytes from offset.
    801  * @ returns number of bytes actually transfered / 0 if EOF / -1 if error.
    802  *****************************************************************************************/
    803 uint32_t vfs_read( xptr_t   file_xp,
    804                    void   * buffer,
    805                    uint32_t size );
    806 
    807 /******************************************************************************************
    808  * This function moves <size> bytes from the local kernel <buffer> to the open file
    809  * descriptor <file_xp>, taken into account the offset defined in <file_xp>.
    810  ******************************************************************************************
    811  * @ file_xp   : extended pointer on the remote open file descriptor.
    812  * @ buffer    : local pointer on source kernel buffer.
    813  * @ size      : requested number of bytes to be written from offset.
    814667 * @ returns number of bytes actually transfered / -1 if error.
    815668 *****************************************************************************************/
    816 uint32_t vfs_write( xptr_t   file_xp,
    817                     void   * buffer,
    818                     uint32_t size );
     669error_t vfs_move( bool_t   to_buffer,
     670                  xptr_t   file_xp,
     671                  void   * buffer,
     672                  uint32_t size );
    819673
    820674/******************************************************************************************
     
    837691
    838692/******************************************************************************************
    839  * This function close an open file descriptor.                             
     693 * This function close an open file descriptor:
     694 * 1) All entries in fd_array copies are directly cancelled by the calling thread,
     695 *    using remote accesses.
     696 * 2) The memory allocated to file descriptor in cluster containing the inode is released.
     697 *    It requires a RPC if cluster containing the file descriptor is remote.
    840698 ******************************************************************************************
    841699 * @ file_xp     : extended pointer on the file descriptor.
    842  * @ refcount    : number of references after close.
    843  * @ return 0 if success / return -1 if error
    844  *****************************************************************************************/
    845 error_t vfs_close( xptr_t     file_xp,
    846                    uint32_t * refcount );
    847 
    848 /******************************************************************************************
    849  * This function remove from the file system a directory entry identified by its pathname.
    850  * The pathname can be relative to current directory or absolute.
    851  ******************************************************************************************
    852  * @ cwd_xp   : extended pointer on the current directory file descriptor.
     700 * @ file_id     : file descriptor index in fd_array.
     701 * @ returns 0 if success / -1 if error.
     702 *****************************************************************************************/
     703error_t vfs_close( xptr_t    file_xp,
     704                   uint32_t  file_id );
     705
     706/******************************************************************************************
     707 * This function remove from the file system a directory entry identified by the
     708 * <cwd_xp> & <path> arguments.
     709 ******************************************************************************************
     710 * @ cwd_xp   : extended pointer on the current working directory file descriptor.
    853711 * @ path     : pathname (absolute or relative to current directory).
     712 * @ returns 0 if success / -1 if error.
    854713 *****************************************************************************************/
    855714error_t vfs_unlink( xptr_t   cwd_xp,
     
    857716
    858717/******************************************************************************************
    859  * This function returns in the <ustat> structure various informations on the file TODO
     718 * This function returns, in the structure pointed by the <k_stat> kernel pointer,
     719 * various informations on the file descriptor identified by the <file_xp> argument.
     720 * TODO not implemented yet...
     721 ******************************************************************************************
     722 * @ file_xp    : extended pointer on the file descriptor of the searched directory .
     723 * @ k_dirent   : local pointer on the dirent_t structure in kernel space.
     724 * @ returns 0 if success / -1 if error.
    860725 *****************************************************************************************/
    861726error_t vfs_stat( xptr_t       file_xp,
    862                   vfs_stat_t * ustat );
    863 
    864 
    865 
    866 
    867 /*****************************************************************************************/
    868 /************************ Directory related functions ************************************/
    869 /*****************************************************************************************/
    870 
    871 /******************************************************************************************
    872  * This function TODO                                                         
    873  *****************************************************************************************/
    874 error_t vfs_opendir( xptr_t      cwd_xp,
    875                      char      * path,
    876                      uint32_t    flags,
    877                      xptr_t      file_xp );
    878 
    879 /******************************************************************************************
    880  * This function TODO                                                         
    881  *    fat32_readdir need cleaning
    882  *****************************************************************************************/
    883 error_t vfs_readdir( xptr_t            file_xp,
    884                      char            * path );
    885 
    886 /******************************************************************************************
    887  * This function TODO                                                         
    888  *****************************************************************************************/
    889 error_t vfs_mkdir( xptr_t            file_xp,
    890                    char            * path,
    891                    uint32_t          mode );
    892 
    893 /******************************************************************************************
    894  * This function remove a directory from the file system.
    895  *****************************************************************************************/
    896 error_t vfs_rmdir( xptr_t            file_xp,
    897                    char            * path );
    898 
    899 /******************************************************************************************
    900  * This function TODO                                                         
    901  *****************************************************************************************/
    902 error_t vfs_chdir( char            * pathname,
    903                    xptr_t            cwd_xp );
    904 
    905 /******************************************************************************************
    906  * This function TODO                                                         
    907  *****************************************************************************************/
    908 error_t vfs_chmod( char            * pathname,
    909                    vfs_file_t      * cwd,
    910                    uint32_t          mode );
    911 
    912 /******************************************************************************************
    913  * This function TODO                                                         
    914  *****************************************************************************************/
    915 error_t vfs_closedir( xptr_t       file_xp,
    916                       uint32_t   * refcount );
    917 
    918 
    919 
    920 
    921 /*****************************************************************************************/
    922 /*******************  Pipe related functions *********************************************/
    923 /*****************************************************************************************/
    924 
    925 /******************************************************************************************
    926  * This function TODO ???                                                         
    927  *****************************************************************************************/
    928 error_t vfs_pipe( xptr_t pipefd[2] );
    929 
    930 /******************************************************************************************
    931  * This function TODO                                                         
    932  *****************************************************************************************/
    933 error_t vfs_mkfifo( xptr_t            cwd_xp,
    934                     char            * path,
    935                     uint32_t          mode );
    936 
    937 
    938 
     727                  vfs_stat_t * k_stat );
     728
     729/******************************************************************************************
     730 * This function returns, in the structure pointed by the <k_dirent> kernel pointer,
     731 * various infos on the directory entry currently pointed by the <file_xp> file descriptor.
     732 * TODO not implemented yet...
     733 ******************************************************************************************
     734 * @ file_xp    : extended pointer on the file descriptor of the searched directory .
     735 * @ k_dirent   : local pointer on the dirent_t structure in kernel space.
     736 * @ returns 0 if success / -1 if error.
     737 *****************************************************************************************/
     738error_t vfs_readdir( xptr_t         file_xp,
     739                     vfs_dirent_t * k_dirent );
     740
     741/******************************************************************************************
     742 * This function  creates a new inode and associated dentry  for the directory defined
     743 * by the <cwd_xp> & <path> arguments.
     744 * TODO not implemented yet...
     745 ******************************************************************************************
     746 * @ cwd_xp   : extended pointer on the current working directory file descriptor.
     747 * @ path     : pathname (absolute or relative to current directory).                     
     748 * @ mode     : access rights (as defined by chmod)
     749 * @ returns 0 if success / -1 if error.
     750 *****************************************************************************************/
     751error_t vfs_mkdir( xptr_t     cwd_xp,
     752                   char     * path,
     753                   uint32_t   mode );
     754
     755/******************************************************************************************
     756 * This function remove a directory identified by the <cwd_xp / path> arguments
     757 * from the file system.
     758 * TODO not implemented yet...
     759 ******************************************************************************************
     760 * @ cwd_xp   : extended pointer on the current working directory file descriptor.
     761 * @ path     : pathname (absolute or relative to current directory).                     
     762 * @ returns 0 if success / -1 if error.
     763 *****************************************************************************************/
     764error_t vfs_rmdir( xptr_t   cwd_xp,
     765                   char   * path );
     766
     767/******************************************************************************************
     768 * This function makes the directory identified by <cwd_xp / path> arguments to become
     769 * the working directory for the calling process.
     770 ******************************************************************************************
     771 * @ cwd_xp      : extended pointer on current directory file descriptor (relative path).
     772 * @ path        : file pathname (absolute or relative to current directory).
     773 * return 0 if success / -1 if error.
     774 *****************************************************************************************/
     775error_t vfs_chdir( xptr_t   cwd_xp,
     776                   char   * path );
     777
     778/******************************************************************************************
     779 * This function change the access rigths for the file identified by the <cwd_xp / path>
     780 * arguments. The new access rights are defined by the <mode> argument value.
     781 ******************************************************************************************
     782 * @ cwd_xp      : extended pointer on current directory file descriptor (relative path).
     783 * @ path        : file pathname (absolute or relative to current directory).
     784 * @ mode        : access rights new value.
     785 * return 0 if success / -1 if error.
     786 *****************************************************************************************/
     787error_t vfs_chmod( xptr_t        cwd_xp,
     788                   char        * path,
     789                   uint32_t      mode );
     790
     791/******************************************************************************************
     792 * This function creates a named FIFO file.
     793 * TODO not implemented yet                                                         
     794 ******************************************************************************************
     795 * @ path        : FIFO pathname (absolute or relative to current directory).
     796 * @ cwd_xp      : extended pointer on the current working directory file descriptor.
     797 * @ mode        : access rights new value.
     798 *****************************************************************************************/
     799error_t vfs_mkfifo( xptr_t       cwd_xp,
     800                    char       * path,
     801                    uint32_t     mode );
     802
     803
     804/*****************************************************************************************/
     805/****************** Mapper access API ****************************************************/
     806/*****************************************************************************************/
     807
     808/******************************************************************************************
     809 * This function makes an I/O operation to move one page from VFS to a given mapper,
     810 * in case of MISS on the mapper cache.
     811 * Depending on the file system type, it calls the proper, FS specific function.
     812 * It must be executed by a thread running in the cluster containing the mapper.
     813 * The mapper pointer is obtained from the page descriptor.
     814 * It takes the mapper lock before launching the IO operation.
     815 ******************************************************************************************
     816 * @ page   : local pointer on the page descriptor.
     817 * @ returns 0 if success / return EINVAL if it cannot access the external device.
     818 *****************************************************************************************/
     819error_t vfs_move_page_to_mapper( struct page_s * page );
     820
     821/******************************************************************************************
     822 * This function makes an I/0 operation to move one page from a given mapper to VFS,
     823 * when a dirty page in the mapper cache must be updated in the File System.
     824 * Depending on the file system type, it calls the proper, FS specific function.
     825 * It must be executed by a thread running in the cluster containing the mapper.
     826 * The mapper pointer is obtained from the page descriptor.
     827 * It takes the mapper lock before launching the IO operation.
     828 * It does nothing if the page is not dirty. If the page is dirty, it clear the page
     829 * dirty bit, and remove the page from the PPM dirty list.
     830 ******************************************************************************************
     831 * @ page   : local pointer on the page descriptor.
     832 * @ returns 0 if success / return EINVAL if it cannot access the external device.
     833 *****************************************************************************************/
     834error_t vfs_move_page_from_mapper( struct page_s * page );       
     835
     836
     837
     838
     839
     840
     841///////////////////////////////////////////////////////////////////////////////////////////
     842// These typedef define the FS specific operations that must be implemented by any
     843// specific file system to be supported by the ALMOS_MKH VFS.
     844// These typedef are not actually used, and are only defined for documentation
     845///////////////////////////////////////////////////////////////////////////////////////////
     846
     847typedef error_t (fs_init_t)          ( xptr_t vfs_root_xp );
     848
     849typedef error_t (fs_inode_extend_t)  ( struct vfs_inode_s * inode,
     850                                       void               * extend );
     851 
     852typedef void    (fs_inode_release_t) ( struct vfs_inode_s * inode );
     853
     854typedef error_t (fs_write_page_t)    ( struct page_s * page );
     855
     856typedef error_t (fs_read_page_t)     ( struct page_s * page );
     857
     858
     859
     860
     861
     862
     863
     864
     865/* deprecated [AG]
     866
     867typedef error_t (lookup_inode_t)  ( vfs_inode_t  * parent ,
     868                                    vfs_dentry_t * dentry );
     869
     870typedef error_t (write_inode_t)   ( vfs_inode_t  * inode );
     871
     872typedef error_t (release_inode_t) ( vfs_inode_t  * inode );
     873
     874typedef error_t (unlink_inode_t)  ( vfs_inode_t  * parent,
     875                                    vfs_dentry_t * dentry,
     876                                    uint32_t       flags );
     877
     878typedef error_t (stat_inode_t)    ( vfs_inode_t  * inode );
     879
     880typedef error_t (trunc_inode_t)   ( vfs_inode_t  * inode );
     881
     882typedef error_t (delete_inode_t)  ( vfs_inode_t  * inode );
     883
     884typedef struct vfs_inode_op_s
     885{
     886        init_inode_t    * init;   
     887        create_inode_t  * create; 
     888        lookup_inode_t  * lookup; 
     889        write_inode_t   * write;
     890        release_inode_t * release;
     891        unlink_inode_t  * unlink;
     892        delete_inode_t  * delete;
     893        stat_inode_t    * stat;
     894        trunc_inode_t   * trunc;    // change the size of a file
     895}
     896vfs_inode_op_t;
     897
     898 ******************************************************************************************
     899 * These typedef define the set of FS specific operations on a VFS DENTRY descriptor.
     900 * They must be implemented by any specific file system to be supported by ALMOS_MKH.
     901 * This code is not actually used, and is only defined for documentation
     902 ******************************************************************************************
     903
     904
     905typedef error_t (vfs_compare_dentry_t) ( char * first , char * second );
     906
     907typedef struct vfs_dentry_op_s
     908{
     909        vfs_compare_dentry_t * compare;
     910}
     911vfs_dentry_op_t;
     912
     913
     914 ******************************************************************************************
     915 * These typedef define the set of FS specific operations on FILE descriptors
     916 * They must be implemented by any specific file system to be supported by ALMOS_MKH.
     917 * This code is not actually used, and is only defined for documentation
     918 ******************************************************************************************
     919
     920
     921typedef error_t (open_file_t   ) ( vfs_file_t * file,
     922                                   void       * extend );
     923
     924typedef error_t (read_file_t   ) ( vfs_file_t * file,
     925                                   char       * buffer,
     926                                   uint32_t     count );
     927
     928typedef error_t (write_file_t  ) ( vfs_file_t * file,
     929                                   char       * buffer,
     930                                   uint32_t     count );
     931
     932typedef error_t (lseek_file_t  ) ( vfs_file_t * file );
     933
     934typedef error_t (close_file_t  ) ( vfs_file_t * file );
     935
     936typedef error_t (release_file_t) ( vfs_file_t * file );
     937
     938typedef error_t (read_dir_t    ) ( vfs_file_t * file );
     939
     940typedef error_t (mmap_file_t   ) ( vfs_file_t    * file ,
     941                                   struct vseg_s * vseg );
     942
     943typedef error_t (munmap_file_t ) ( vfs_file_t    * file,
     944                                   struct vseg_s * vseg );
     945
     946typedef struct vfs_file_op_s
     947{
     948        open_file_t    * open;
     949        read_file_t    * read;
     950        write_file_t   * write;
     951        lseek_file_t   * lseek;
     952        read_dir_t     * readdir;
     953        close_file_t   * close;
     954        release_file_t * release;
     955        mmap_file_t    * mmap;
     956        munmap_file_t  * munmap;
     957}
     958vfs_file_op_t;
     959
     960*/
    939961
    940962#endif  /* _VFS_H_ */
Note: See TracChangeset for help on using the changeset viewer.