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


Ignore:
Timestamp:
Nov 7, 2017, 3:08:12 PM (5 years ago)
Author:
alain
Message:

First implementation of fork/exec.

Location:
trunk/kernel/fs
Files:
1 edited
1 moved

Legend:

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

    r317 r407  
    3838#include <xhtab.h>
    3939#include <errno.h>
    40 #include <metafs.h>
    41 
     40#include <shared_syscalls.h>
    4241#include <fatfs.h>
    4342#include <ramfs.h>
     
    235234typedef enum
    236235{
    237     VFS_SEEK_SET,
    238     VFS_SEEK_CUR,
    239     VFS_SEEK_END,
    240 }
    241 vfs_lseek_cmd_t;
    242 
    243 typedef enum
    244 {
    245236    FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                         */
    246237    FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                        */
     
    267258vfs_file_t;
    268259
    269 /******************************************************************************************
    270  * This structure define the informations associated to a file descriptor,
    271  * returned to user space by the stat() system call.
    272  *****************************************************************************************/
    273 
    274 typedef struct vfs_stat_s
    275 {
    276         uint32_t    dev;        /*! ID of device containing file                             */
    277         uint32_t    ino;        /*! inode number                                             */
    278         uint32_t    mode;       /*! protection                                               */
    279         uint32_t    nlink;      /*! number of hard links                                     */
    280         uint32_t    uid;        /*! user ID of owner                                         */
    281         uint32_t    gid;        /*! group ID of owner                                        */
    282         uint32_t    rdev;       /*! device ID (if special file)                              */
    283         uint64_t    size;       /*! total size, in bytes                                     */
    284         uint32_t    blksize;    /*! blocksize for file system I/O                            */
    285         uint32_t    blocks;     /*! number of 512B blocks allocated                          */
    286         uint64_t    atime;      /*! time of last access                                      */
    287         uint64_t    mtime;      /*! time of last modification                                */
    288         uint64_t    ctime;      /*! time of last status change                               */
    289 }
    290 vfs_stat_t;
    291 
    292 /*********************************************************************************************
    293  * This structure defines the information associated to a directory entry,
    294  * returned to user space by the readdir() system call.
    295  ********************************************************************************************/
    296 
    297 typedef struct vfs_dirent_s
    298 {
    299     uint32_t    inum;                               /*! inode identifier                    */
    300     uint32_t    type;                               /*! inode type                          */
    301     char        name[CONFIG_VFS_MAX_NAME_LENGTH];   /*! dentry name                         */
    302 }
    303 vfs_dirent_t;
    304 
    305 
    306260
    307261/*****************************************************************************************/
     
    503457error_t vfs_inode_unlink( vfs_inode_t * inode );
    504458
    505 /******************************************************************************************
    506  * This function TODO                                                         
    507  *****************************************************************************************/
    508 error_t vfs_inode_stat( vfs_inode_t * inode,
    509                         uint32_t      inum );
    510 
    511 /******************************************************************************************
    512  * This function TODO                                                         
    513  *****************************************************************************************/
    514 error_t vfs_icache_del( vfs_inode_t * inode );
    515 
    516 
    517 /******************************************************************************************
    518  * This function TODO  Pourquoi 2 arguments ?
    519  *****************************************************************************************/
    520 error_t vfs_stat_inode( vfs_inode_t * inode,
    521                         uint32_t      inum );
    522 
    523459
    524460/*****************************************************************************************/
     
    643579 * @ lookup_mode : flags defining the working mode (defined above in this file).
    644580 * @ inode_xp    : [out] buffer for extended pointer on searched inode.
    645  * @ return 0 if success / ENOENT if inode not found , EACCES if permissopn denied,
    646  *                        EAGAIN if a new complete lookup must be made
     581 * @ return 0 if success / ENOENT if inode not found , EACCES if permisson denied,
     582 *                         EAGAIN if a new complete lookup must be made
    647583 *****************************************************************************************/
    648584error_t vfs_lookup( xptr_t             cwd_xp,
     
    653589/******************************************************************************************
    654590 * This function creates a new couple dentry/inode, and insert it in the Inode-Tree.
    655  * It can be executed by any thread running in any cluster ( can be differente from both
     591 * It can be executed by any thread running in any cluster (can be different from both
    656592 * the child cluster and the parent cluster), as it uses the rpc_dentry_create_client()
    657593 * and rpc_inode_create client() if required. This is done in three steps:
     
    707643/******************************************************************************************
    708644 * This function allocates a vfs_file_t structure in the cluster containing the inode
    709  * associated to the file identified by <cwd_xp> & <path>.
    710  * It initializes it, register it in the reference process fd_array, and returns both
    711  * the extended pointer on the remote file descriptor, and the index in the fd_array.
     645 * associated to the file identified by the <cwd_xp> & <path> arguments.
     646 * It initializes it, register it in the reference process fd_array identified by the
     647 * <process> argument, and returns both the extended pointer on the file descriptor,
     648 * and the allocated index in the fd_array.
    712649 * The pathname can be relative to current directory or absolute.
    713650 * If the inode does not exist in the inode cache, it try to find the file on the mounted
    714651 * device, and creates an inode on a pseudo randomly selected cluster if found.
    715652 * It the requested file does not exist on device, it creates a new inode if the
    716  * O_CREAT flag is set and return an error otherwise.
    717  ******************************************************************************************
    718  * @ cwd_xp      : extended pointer on current working directory file descriptor.
     653 * O_CREAT flag is set, and return an error otherwise.
     654 ******************************************************************************************
     655 * @ process     : local pointer on local process descriptor copy.
    719656 * @ path        : file pathname (absolute or relative to current directory).
    720  * @ flags       : defined above 
     657 * @ flags       : defined above.
    721658 * @ mode        : access rights (as defined by chmod)
    722659 * @ file_xp     : [out] buffer for extended pointer on created remote file descriptor.
     
    724661 * @ return 0 if success / return non-zero if error.
    725662 *****************************************************************************************/
    726 error_t vfs_open( xptr_t     cwd_xp,
    727                           char     * path,
    728                           uint32_t   flags,
    729                   uint32_t   mode,
    730                           xptr_t   * file_xp,
    731                           uint32_t * file_id );
     663error_t vfs_open( struct process_s * process,
     664                          char             * path,
     665                          uint32_t           flags,
     666                  uint32_t           mode,
     667                          xptr_t           * file_xp,
     668                          uint32_t         * file_id );
    732669
    733670/******************************************************************************************
     
    735672 * <file_xp> argument, and a - possibly distributed - user space <buffer>, taken into
    736673 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>.
    737  * This function is called by the elf_load_process() function.
     674 * It is called by the sys_read() and sys_write() functions.
    738675 ******************************************************************************************
    739676 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false.
     
    741678 * @ buffer    : user space pointer on buffer (can be physically distributed).
    742679 * @ size      : requested number of bytes from offset.
    743  * @ returns 0 f success / -1 if error.
    744  *****************************************************************************************/
    745 error_t vfs_user_move( bool_t   to_buffer,
    746                        xptr_t   file_xp,
    747                        void   * buffer,
    748                        uint32_t size );
     680 * @ returns number of bytes actually moved if success / -1 if error.
     681 *****************************************************************************************/
     682int vfs_user_move( bool_t   to_buffer,
     683                   xptr_t   file_xp,
     684                   void   * buffer,
     685                   uint32_t size );
    749686
    750687/******************************************************************************************
     
    752689 * <file_xp> argument, and a - possibly remote - kernel <buffer_xp>, taken into
    753690 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>.
    754  * This function is called by the  system calls.
     691 * It is called by the elf_load_process() function.
    755692 ******************************************************************************************
    756693 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false.
     
    758695 * @ buffer_xp : user space pointer on buffer (can be physically distributed).
    759696 * @ size      : requested number of bytes from offset.
    760  * @ returns number of bytes actually transfered / -1 if error.
     697 * @ returns 0 if success / -1 if error.
    761698 *****************************************************************************************/
    762699error_t vfs_kernel_move( bool_t   to_buffer,
     
    814751 ******************************************************************************************
    815752 * @ file_xp    : extended pointer on the file descriptor of the searched directory .
    816  * @ k_dirent   : local pointer on the dirent_t structure in kernel space.
     753 * @ k_stat     : local pointer on the stat structure in kernel space.
    817754 * @ returns 0 if success / -1 if error.
    818755 *****************************************************************************************/
    819 error_t vfs_stat( xptr_t       file_xp,
    820                   vfs_stat_t * k_stat );
     756error_t vfs_stat( xptr_t        file_xp,
     757                  struct stat * k_stat );
    821758
    822759/******************************************************************************************
     
    826763 ******************************************************************************************
    827764 * @ file_xp    : extended pointer on the file descriptor of the searched directory .
    828  * @ k_dirent   : local pointer on the dirent_t structure in kernel space.
     765 * @ k_dirent   : local pointer on the dirent structure in kernel space.
    829766 * @ returns 0 if success / -1 if error.
    830767 *****************************************************************************************/
    831 error_t vfs_readdir( xptr_t         file_xp,
    832                      vfs_dirent_t * k_dirent );
     768error_t vfs_readdir( xptr_t          file_xp,
     769                     struct dirent * k_dirent );
    833770
    834771/******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.