Changeset 407 for trunk/kernel/fs


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

First implementation of fork/exec.

Location:
trunk/kernel/fs
Files:
2 edited
4 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/devfs.c

    r406 r407  
    2525#include <hal_types.h>
    2626#include <hal_special.h>
     27#include <hal_uspace.h>
    2728#include <printk.h>
    2829#include <chdev.h>
     30#include <dev_txt.h>
    2931#include <cluster.h>
    3032#include <vfs.h>
     
    3941extern chdev_directory_t    chdev_dir;      // allocated in kernel_init.c
    4042
     43#if CONFIG_READ_DEBUG
     44extern uint32_t  enter_devfs_move;
     45extern uint32_t  exit_devfs_move;
     46#endif
     47
    4148///////////////////////////////
    4249devfs_ctx_t * devfs_ctx_alloc()
     
    7986    error_t  error;
    8087
    81     devfs_dmsg("\n[DMSG] %s : enter in cluster %x\n",
     88    devfs_dmsg("\n[DBG] %s : enter in cluster %x\n",
    8289               __FUNCTION__ , local_cxy );
    8390
     
    93100    assert( (error == 0) , __FUNCTION__ , "cannot create <dev>\n" );
    94101
    95     devfs_dmsg("\n[DMSG] %s : <dev> created in cluster %x\n",
     102    devfs_dmsg("\n[DBG] %s : <dev> created in cluster %x\n",
    96103               __FUNCTION__ , local_cxy );
    97104
     
    107114    assert( (error == 0) , __FUNCTION__ , "cannot create <external>\n" );
    108115
    109     devfs_dmsg("\n[DMSG] %s : <external> created in cluster %x\n",
     116    devfs_dmsg("\n[DBG] %s : <external> created in cluster %x\n",
    110117               __FUNCTION__ , local_cxy );
    111118}
     
    119126    xptr_t        chdev_xp;
    120127    cxy_t         chdev_cxy;
     128    chdev_t     * chdev_ptr;
    121129    xptr_t        inode_xp;
    122130    uint32_t      channel;
     
    132140                             devfs_internal_inode_xp );
    133141
     142devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     143__FUNCTION__ , node_name , local_cxy );
     144
    134145    // create MMC chdev inode
    135     chdev_xp = chdev_dir.mmc[local_cxy];
     146    chdev_xp  = chdev_dir.mmc[local_cxy];
    136147    if( chdev_xp != XPTR_NULL)
    137148    {
     149        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
    138150        vfs_add_child_in_parent( local_cxy,
    139151                                 INODE_TYPE_DEV,
    140152                                 FS_TYPE_DEVFS,
    141153                                 *devfs_internal_inode_xp,
    142                                  "mmc",
     154                                 chdev_ptr->name,
    143155                                 GET_PTR( chdev_xp ),
    144156                                 &inode_xp );
     157
     158devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     159__FUNCTION__ , chdev_ptr->name , local_cxy );
     160
    145161    }
    146162
     
    151167        if( chdev_xp != XPTR_NULL)
    152168        {
    153             snprintf( node_name , 16 , "dma_%d" , channel );
     169            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
    154170            vfs_add_child_in_parent( local_cxy,
    155171                                     INODE_TYPE_DEV,
    156172                                     FS_TYPE_DEVFS,
    157173                                     *devfs_internal_inode_xp,
    158                                      node_name,
     174                                     chdev_ptr->name,
    159175                                     GET_PTR( chdev_xp ),
    160176                                     &inode_xp );
     177
     178devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     179__FUNCTION__ , chdev_ptr->name , local_cxy );
     180
    161181        }
    162182    }
     
    167187    {
    168188        chdev_cxy = GET_CXY( chdev_xp );
     189        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
    169190        if( chdev_cxy == local_cxy )
    170191        {
     
    173194                                     FS_TYPE_DEVFS,
    174195                                     devfs_external_inode_xp,
    175                                      "iob",
     196                                     chdev_ptr->name,
    176197                                     GET_PTR( chdev_xp ),
    177198                                     &inode_xp );
     199
     200devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     201__FUNCTION__ , chdev_ptr->name , local_cxy );
     202
    178203        }
    179204    }
     
    184209    {
    185210        chdev_cxy = GET_CXY( chdev_xp );
     211        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
    186212        if( chdev_cxy == local_cxy )
    187213        {
     
    190216                                     FS_TYPE_DEVFS,
    191217                                     devfs_external_inode_xp,
    192                                      "pic",
     218                                     chdev_ptr->name,
    193219                                     GET_PTR( chdev_xp ),
    194220                                     &inode_xp );
    195         }
    196     }
    197 
    198     // create a TXT inode in each cluster containing a TXT chdev
     221
     222devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     223__FUNCTION__ , chdev_ptr->name , local_cxy );
     224
     225        }
     226    }
     227
     228    // create a TXT_RX inode in each cluster containing a TXT_RX chdev
    199229    for( channel = 0 ; channel < CONFIG_MAX_TXT_CHANNELS ; channel++ )
    200230    {
    201         chdev_xp = chdev_dir.txt[channel];
    202         if( chdev_xp != XPTR_NULL )
    203         {
    204             chdev_cxy = GET_CXY( chdev_xp );
    205             if( chdev_cxy == local_cxy )
    206             {
    207                 snprintf( node_name , 16 , "txt_%d" , channel );
    208                 vfs_add_child_in_parent( local_cxy,
    209                                          INODE_TYPE_DEV,
    210                                          FS_TYPE_DEVFS,
    211                                          devfs_external_inode_xp,
    212                                          node_name,
    213                                          GET_PTR( chdev_xp ),
    214                                          &inode_xp );
     231        chdev_xp = chdev_dir.txt_rx[channel];
     232        if( chdev_xp != XPTR_NULL )
     233        {
     234            chdev_cxy = GET_CXY( chdev_xp );
     235            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     236            if( chdev_cxy == local_cxy )
     237            {
     238                vfs_add_child_in_parent( local_cxy,
     239                                         INODE_TYPE_DEV,
     240                                         FS_TYPE_DEVFS,
     241                                         devfs_external_inode_xp,
     242                                         chdev_ptr->name,
     243                                         GET_PTR( chdev_xp ),
     244                                         &inode_xp );
     245
     246devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     247__FUNCTION__ , chdev_ptr->name , local_cxy );
     248
     249            }
     250        }
     251    }
     252
     253    // create a TXT_TX inode in each cluster containing a TXT_TX chdev
     254    for( channel = 0 ; channel < CONFIG_MAX_TXT_CHANNELS ; channel++ )
     255    {
     256        chdev_xp = chdev_dir.txt_tx[channel];
     257        if( chdev_xp != XPTR_NULL )
     258        {
     259            chdev_cxy = GET_CXY( chdev_xp );
     260            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     261            if( chdev_cxy == local_cxy )
     262            {
     263                vfs_add_child_in_parent( local_cxy,
     264                                         INODE_TYPE_DEV,
     265                                         FS_TYPE_DEVFS,
     266                                         devfs_external_inode_xp,
     267                                         chdev_ptr->name,
     268                                         GET_PTR( chdev_xp ),
     269                                         &inode_xp );
     270
     271devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     272__FUNCTION__ , chdev_ptr->name , local_cxy );
     273
    215274            }
    216275        }
     
    224283        {
    225284            chdev_cxy = GET_CXY( chdev_xp );
    226             if( chdev_cxy == local_cxy )
    227             {
    228                 snprintf( node_name , 16 , "ioc_%d" , channel );
    229                 vfs_add_child_in_parent( local_cxy,
    230                                          INODE_TYPE_DEV,
    231                                          FS_TYPE_DEVFS,
    232                                          devfs_external_inode_xp,
    233                                          node_name,
    234                                          GET_PTR( chdev_xp ),
    235                                          &inode_xp );
     285            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     286            if( chdev_cxy == local_cxy )
     287            {
     288                vfs_add_child_in_parent( local_cxy,
     289                                         INODE_TYPE_DEV,
     290                                         FS_TYPE_DEVFS,
     291                                         devfs_external_inode_xp,
     292                                         chdev_ptr->name,
     293                                         GET_PTR( chdev_xp ),
     294                                         &inode_xp );
     295
     296devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     297__FUNCTION__ , chdev_ptr->name , local_cxy );
     298
    236299            }
    237300        }
     
    245308        {
    246309            chdev_cxy = GET_CXY( chdev_xp );
    247             if( chdev_cxy == local_cxy )
    248             {
    249                 snprintf( node_name , 16 , "fbf_%d" , channel );
    250                 vfs_add_child_in_parent( local_cxy,
    251                                          INODE_TYPE_DEV,
    252                                          FS_TYPE_DEVFS,
    253                                          devfs_external_inode_xp,
    254                                          node_name,
    255                                          GET_PTR( chdev_xp ),
    256                                          &inode_xp );
     310            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     311            if( chdev_cxy == local_cxy )
     312            {
     313                vfs_add_child_in_parent( local_cxy,
     314                                         INODE_TYPE_DEV,
     315                                         FS_TYPE_DEVFS,
     316                                         devfs_external_inode_xp,
     317                                         chdev_ptr->name,
     318                                         GET_PTR( chdev_xp ),
     319                                         &inode_xp );
     320
     321devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     322__FUNCTION__ , chdev_ptr->name , local_cxy );
     323
    257324            }
    258325        }
     
    266333        {
    267334            chdev_cxy = GET_CXY( chdev_xp );
    268             if( chdev_cxy == local_cxy )
    269             {
    270                 snprintf( node_name , 16 , "nic_rx_%d" , channel );
    271                 vfs_add_child_in_parent( local_cxy,
    272                                          INODE_TYPE_DEV,
    273                                          FS_TYPE_DEVFS,
    274                                          devfs_external_inode_xp,
    275                                          node_name,
    276                                          GET_PTR( chdev_xp ),
    277                                          &inode_xp );
     335            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     336            if( chdev_cxy == local_cxy )
     337            {
     338                vfs_add_child_in_parent( local_cxy,
     339                                         INODE_TYPE_DEV,
     340                                         FS_TYPE_DEVFS,
     341                                         devfs_external_inode_xp,
     342                                         chdev_ptr->name,
     343                                         GET_PTR( chdev_xp ),
     344                                         &inode_xp );
     345
     346devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     347__FUNCTION__ , chdev_ptr->name , local_cxy );
     348
    278349            }
    279350        }
     
    287358        {
    288359            chdev_cxy = GET_CXY( chdev_xp );
    289             if( chdev_cxy == local_cxy )
    290             {
    291                 snprintf( node_name , 16 , "nic_tx_%d" , channel );
    292                 vfs_add_child_in_parent( local_cxy,
    293                                          INODE_TYPE_DEV,
    294                                          FS_TYPE_DEVFS,
    295                                          devfs_external_inode_xp,
    296                                          node_name,
    297                                          GET_PTR( chdev_xp ),
    298                                          &inode_xp );
     360            chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
     361            if( chdev_cxy == local_cxy )
     362            {
     363                vfs_add_child_in_parent( local_cxy,
     364                                         INODE_TYPE_DEV,
     365                                         FS_TYPE_DEVFS,
     366                                         devfs_external_inode_xp,
     367                                         chdev_ptr->name,
     368                                         GET_PTR( chdev_xp ),
     369                                         &inode_xp );
     370
     371devfs_dmsg("\n[DBG] %s : created <%s> inode in cluster %x\n",
     372__FUNCTION__ , chdev_ptr->name , local_cxy );
     373
    299374            }
    300375        }
     
    302377}  // end devfs_local_init()
    303378
     379//////////////////////////////////////////
     380int devfs_user_move( bool_t     to_buffer,
     381                     xptr_t     file_xp,
     382                     void     * u_buf,
     383                     uint32_t   size )
     384{
     385    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" );
     386
     387    assert( ( size < CONFIG_TXT_KBUF_SIZE ) , __FUNCTION__ , "string size too large" );
     388
     389    cxy_t              file_cxy;     // remote file descriptor cluster
     390    vfs_file_t       * file_ptr;     // remote file descriptor local pointer
     391    vfs_inode_type_t   inode_type;   // associated inode type
     392    vfs_inode_t      * inode_ptr;    // associated inode local pointer
     393    chdev_t          * chdev_ptr;    // associated chdev type
     394    uint32_t           func;         // chdev functionnal type
     395    uint32_t           channel;      // chdev channel index
     396    error_t            error;
     397
     398    char               k_buf[CONFIG_TXT_KBUF_SIZE];  // local kernel buffer
     399
     400devfs_dmsg("\n[DBG] %s enter / cycle %d\n",
     401__FUNCTION__ , hal_time_stamp() );
     402
     403#if CONFIG_READ_DEBUG
     404enter_devfs_move = hal_time_stamp();
     405#endif
     406
     407    // get cluster and local pointer on remote file descriptor
     408    // associated inode and chdev are stored in same cluster as the file desc.
     409    file_cxy  = GET_CXY( file_xp );
     410    file_ptr  = (vfs_file_t *)GET_PTR( file_xp );
     411
     412    // get inode type from remote file descriptor
     413    inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) );
     414    inode_ptr  = (vfs_inode_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
     415
     416    assert( (inode_type == INODE_TYPE_DEV) , __FUNCTION__ ,
     417    "inode type is not INODE_TYPE_DEV" );
     418
     419    // get chdev local pointer from remote inode extension
     420    chdev_ptr = (chdev_t *)hal_remote_lpt( XPTR( file_cxy , &inode_ptr->extend ) );
     421 
     422    // get chdev functionnal type and channel
     423    func    = hal_remote_lw( XPTR( file_cxy , &chdev_ptr->func ) );
     424    channel = hal_remote_lw( XPTR( file_cxy , &chdev_ptr->channel ) );
     425
     426    // action depends on "func" and "to_buffer"
     427    if( func == DEV_FUNC_TXT )
     428    {
     429        if( to_buffer )     // TXT read
     430        {
     431            uint32_t i;
     432            for( i = 0 ; i < size ; i++ )
     433            {
     434                error = dev_txt_read( channel , &k_buf[i] );
     435
     436                if( error )
     437                {
     438
     439devfs_dmsg("\n[DBG] %s exit error / cycle %d\n",
     440__FUNCTION__ , hal_time_stamp() );
     441
     442                    return -1;
     443                }
     444                else
     445                {
     446                    hal_strcpy_to_uspace( u_buf , k_buf , size );
     447                }
     448             }
     449
     450#if CONFIG_READ_DEBUG
     451exit_devfs_move = hal_time_stamp();
     452#endif
     453
     454devfs_dmsg("\n[DBG] %s exit success / size = %d / cycle %d\n",
     455__FUNCTION__ , size , hal_time_stamp() );
     456
     457            return size;
     458        }
     459        else                // TXT write 
     460        {
     461            hal_strcpy_from_uspace( k_buf , u_buf , size );
     462
     463            error = dev_txt_write( channel , k_buf , size );
     464            if( error )
     465            {
     466
     467devfs_dmsg("\n[DBG] %s exit error / cycle %d\n",
     468__FUNCTION__ , hal_time_stamp() );
     469
     470                return -1;
     471            }
     472            else
     473            {
     474
     475devfs_dmsg("\n[DBG] %s exit success / size = %d / cycle %d\n",
     476__FUNCTION__ , size , hal_time_stamp() );
     477
     478                return size;
     479            }
     480        }
     481    }
     482    else
     483    {
     484        panic("device type %s does not support direct user access", chdev_func_str(func) );
     485
     486        return -1;
     487    }
     488}  // end devfs_user_move()
     489
     490
  • trunk/kernel/fs/devfs.h

    r238 r407  
    4141//
    4242// The DEVFS extensions to the generic VFS are the following:
    43 // 1) The vfs_ctx_t "extend" field is a void* pointing on the devfs_ctx_t structure.
     43// 1) The vfs_ctx_t "extend" void* field is pointing on the devfs_ctx_t structure.
    4444//    This structure contains two extended pointers on the DEVFS "dev" directory inode,
    4545//    and on the "external" directory inode.
    46 // 2) The vfs_inode_t "extend" field is a void*, pointing on the associated
    47 //    chdev descriptor.
     46// 2) The vfs_inode_t "extend" void* field is pointing on the chdev descriptor.
    4847//////////////////////////////////////////////////////////////////////////////////////////
    4948
     
    119118                       xptr_t * devfs_internal_inode_xp );
    120119                       
     120/******************************************************************************************
     121 * This function moves <size> bytes between a device, and a - possibly distributed -
     122 * user space <buffer>. It uses the <file_xp> and <to_buffer> arguments, to call the
     123 * relevant device access function.
     124 * It is called by the sys_read() and sys_write() functions.
     125 * The <size> argument cannot be larger than the CONFIG_TXT_KBUF_SIZE configuration
     126 * parameter, as this function makes a copy between the user space buffer, and a local
     127 * kernel buffer allocated in the kernel stack.
     128 ******************************************************************************************
     129 * @ to_buffer : device -> buffer if true / buffer -> device if false.
     130 * @ file_xp   : extended pointer on the remote file descriptor.
     131 * @ u_buf     : user space buffer (virtual address).
     132 * @ size      : requested number of bytes from offset.
     133 * @ returns number of bytes actually moved if success / -1 if error.
     134 *****************************************************************************************/
     135int devfs_user_move( bool_t   to_buffer,
     136                     xptr_t   file_xp,
     137                     void   * u_buf,
     138                     uint32_t size );
     139
     140
    121141#endif  /* _DEVFS_H_ */
  • trunk/kernel/fs/fatfs.c

    r406 r407  
    262262    "no FAT access required for first page\n");
    263263
    264     fatfs_dmsg("\n[DMSG] %s : enter / first_cluster_id = %d / searched_page_index = %d\n",
    265     __FUNCTION__ , first_cluster_id , searched_page_index );
     264fatfs_dmsg("\n[DBG] %s : core[%x,%d] enters / first_cluster_id = %d / searched_index = %d\n",
     265__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first_cluster_id, searched_page_index );
    266266
    267267    // get number of FAT slots per page
     
    289289        next_cluster_id = current_page_buffer[current_page_offset];
    290290
    291         fatfs_dmsg("\n[DMSG] %s : traverse FAT / current_page_index = %d\n"
    292                    "       current_page_offset = %d / next_cluster_id = %d\n",
    293         __FUNCTION__ , current_page_index , current_page_offset , next_cluster_id );
     291fatfs_dmsg("\n[DBG] %s : core[%x,%d] traverse FAT / current_page_index = %d\n"
     292"current_page_offset = %d / next_cluster_id = %d\n",
     293__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, current_page_index,
     294current_page_offset , next_cluster_id );
    294295
    295296        // update loop variables
     
    301302    if( next_cluster_id == 0xFFFFFFFF ) return EIO;
    302303   
    303     fatfs_dmsg("\n[DMSG] %s : exit / cluster_id = %d\n", __FUNCTION__ , next_cluster_id );
     304fatfs_dmsg("\n[DBG] %s : core[%x;%d] exit / cluster_id = %d\n",
     305__FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, next_cluster_id );
    304306
    305307    *searched_cluster_id = next_cluster_id;
     
    333335    uint8_t     * buffer;
    334336
    335     fatfs_dmsg("\n[DMSG] %s : enter for fatfs_ctx = %x\n",
     337    fatfs_dmsg("\n[DBG] %s : enter for fatfs_ctx = %x\n",
    336338               __FUNCTION__ , fatfs_ctx );
    337339
     
    347349                   "cannot allocate memory for 512 bytes buffer\n" );
    348350     
    349     fatfs_dmsg("\n[DMSG] %s : allocated 512 bytes buffer\n", __FUNCTION__ );
     351    fatfs_dmsg("\n[DBG] %s : allocated 512 bytes buffer\n", __FUNCTION__ );
    350352
    351353    // load the boot record from device
     
    353355    error = dev_ioc_sync_read( buffer , 0 , 1 );
    354356
    355     fatfs_dmsg("\n[DMSG] %s : buffer loaded\n", __FUNCTION__ );
     357fatfs_dmsg("\n[DBG] %s : buffer loaded\n", __FUNCTION__ );
    356358
    357359    assert( (error == 0) , __FUNCTION__ , "cannot access boot record\n" );
     
    415417    kmem_free( &req );
    416418
    417     fatfs_dmsg("\n[DMSG] %s : boot record read & released\n",
     419    fatfs_dmsg("\n[DBG] %s : boot record read & released\n",
    418420               __FUNCTION__ );
    419421
     
    437439    fatfs_ctx->fat_mapper_xp         = XPTR( local_cxy , fat_mapper );
    438440
    439     fatfs_dmsg("\n[DMSG] %s : exit for fatfs_ctx = %x\n",
    440                __FUNCTION__ , fatfs_ctx );
     441fatfs_dmsg("\n[DBG] %s : exit for fatfs_ctx = %x\n", __FUNCTION__ , fatfs_ctx );
    441442
    442443}  // end fatfs_ctx_init()
     
    471472    inode = mapper->inode;
    472473
    473     fatfs_dmsg("\n[DMSG] %s : core[%x,%d] enter for page %d / inode %x / mapper %x\n",
    474     __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper );
     474fatfs_dmsg("\n[DBG] %s : core[%x,%d] enter for page %d / inode %x / mapper %x\n",
     475__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper );
    475476
    476477    // get page base address
     
    488489        lba = fatfs_ctx->fat_begin_lba + (count * index);
    489490 
    490         fatfs_dmsg("\n[DMSG] %s : core[%x,%d] access FAT on device / lba = %d\n",
    491         __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba );
     491fatfs_dmsg("\n[DBG] %s : core[%x,%d] access FAT on device / lba = %d\n",
     492__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba );
    492493
    493494        // access device
     
    511512        else                        // FAT mapper access required
    512513        {
    513             fatfs_dmsg("\n[DMSG] %s : core[%x,%d] must access FAT\n",
    514             __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid );
    515 
    516514            // get cluster and local pointer on FAT mapper
    517515            xptr_t     fat_mapper_xp  = fatfs_ctx->fat_mapper_xp;
     
    522520            if( fat_mapper_cxy == local_cxy )    // FAT mapper is local
    523521            {
     522
     523fatfs_dmsg("\n[DBG] %s : core[%x,%d] access local FAT mapper\n"
     524"fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n",
     525__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ,
     526fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index );
     527
    524528                error = fatfs_get_cluster( fat_mapper_ptr,
    525529                                           first_cluster_id,
     
    529533            else                                 // FAT mapper is remote
    530534            {
     535
     536fatfs_dmsg("\n[DBG] %s : core[%x,%d] access remote FAT mapper\n"
     537"fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n",
     538__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ,
     539fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index );
     540
    531541                rpc_fatfs_get_cluster_client( fat_mapper_cxy,
    532542                                              fat_mapper_ptr,
     
    540550        }
    541551
    542         fatfs_dmsg("\n[DMSG] %s : core[%x,%d] access device for inode %x / cluster_id %d\n",
    543         __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , searched_cluster_id );
     552fatfs_dmsg("\n[DBG] %s : core[%x,%d] access device for inode %x / cluster_id %d\n",
     553__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , searched_cluster_id );
    544554
    545555        // get lba from cluster_id
     
    553563    }
    554564
    555     fatfs_dmsg("\n[DMSG] %s : core[%x,%d] exit for page %d / inode %x / mapper %x\n",
    556     __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper );
     565fatfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / inode %x / mapper %x\n",
     566__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper );
    557567
    558568#if (CONFIG_FATFS_DEBUG & 0x1)
     
    584594    // - scan the directory entries in each 4 Kbytes page
    585595
    586     fatfs_dmsg("\n[DMSG] %s : enter for child <%s> in parent inode %l\n",
    587                __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
     596fatfs_dmsg("\n[DBG] %s : enter for child <%s> in parent inode %l\n",
     597__FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
    588598
    589599    mapper_t * mapper = parent_inode->mapper;
     
    705715    if ( found == -1 )  // found end of directory => failure
    706716    {
    707         fatfs_dmsg("\n[DMSG] %s : exit / child <%s> not found in parent inode %l\n",
    708                    __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
     717
     718fatfs_dmsg("\n[DBG] %s : exit / child <%s> not found in parent inode %l\n",
     719__FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
    709720
    710721        return ENOENT;
     
    723734        hal_remote_sw( XPTR( child_cxy , &child_ptr->extend ) , cluster );
    724735
    725         fatfs_dmsg("\n[DMSG] %s : exit / child <%s> found in parent inode %l\n",
    726                    __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
     736fatfs_dmsg("\n[DBG] %s : exit / child <%s> found in parent inode %l\n",
     737__FUNCTION__ , name , XPTR( local_cxy , parent_inode ) );
    727738
    728739        return 0;
  • trunk/kernel/fs/vfs.c

    r406 r407  
    156156    error_t            error;
    157157
    158     vfs_dmsg("\n[INFO] %s : core[%x,%d] enter / dentry_xp = %l\n",
    159     __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , dentry_xp );
     158vfs_dmsg("\n[DBG] %s : core[%x,%d] enter / dentry = %x in cluster %x\n",
     159__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, GET_PTR(dentry_xp), GET_CXY(dentry_xp) );
    160160 
    161161    // check fs type and get pointer on context
     
    229229    remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) );
    230230
    231     vfs_dmsg("\n[INFO] %s : core[%x,%d] exit / inode_xp = %l / dentry_xp = %l\n",
    232     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy,inode), dentry_xp );
     231vfs_dmsg("\n[DBG] %s : core[%x,%d] exit / inode = %x in cluster %x\n",
     232__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy );
    233233 
    234234    // return extended pointer on inode
     
    262262                        xptr_t        child_xp )
    263263{
    264     vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
    265     __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
     264vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
     265__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
    266266
    267267    error_t error = 0;
     
    292292    }
    293293
    294     vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / cycle %d\n",
    295     __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
     294vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / cycle %d\n",
     295__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
    296296
    297297    return error;
     
    413413
    414414    // display inode header
    415     printk("\n*** inode <%s> / inode_xp = %l / dentry_xp = %l ***\n",
    416            name , inode_xp , dentry_xp );
     415    printk("\n***** inode <%s> [%x in cluster %x]\n",
     416           name , GET_PTR(inode_xp) , GET_CXY(inode_xp) );
    417417
    418418    // display children from xhtab
     
    435435        kmem_req_t       req;        // request to kernel memory allocator
    436436
    437     vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",
    438     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() );
     437vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",
     438__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() );
    439439
    440440    // get pointer on context
     
    484484    *dentry_xp = XPTR( local_cxy , dentry );
    485485
    486     vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / dentry = %l / cycle %d\n",
    487     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, *dentry_xp, hal_time_stamp() );
     486vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / dentry = %x in cluster %x / cycle %d\n",
     487__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, dentry, local_cxy , hal_time_stamp() );
    488488
    489489    return 0;
     
    586586//////////////////////////////////////////////////////////////////////////////////////////
    587587
    588 ////////////////////////////////////
    589 error_t vfs_open( xptr_t     cwd_xp,
    590                           char     * path,
    591                           uint32_t   flags,
    592                   uint32_t   mode,
    593                           xptr_t   * new_file_xp,
    594                   uint32_t * new_file_id )
     588//////////////////////////////////////
     589error_t vfs_open( process_t * process,
     590                          char      * path,
     591                          uint32_t    flags,
     592                  uint32_t    mode,
     593                          xptr_t    * new_file_xp,
     594                  uint32_t  * new_file_id )
    595595{
    596596    error_t       error;
     
    603603    uint32_t      file_id;      // created file descriptor index in reference fd_array
    604604
    605     vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
    606     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() );
     605vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
     606__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() );
    607607
    608608    // compute lookup working mode
     
    614614    // compute attributes for the created file
    615615    file_attr = 0;
    616     if( (flags & O_RDONLY ) == 0 )  file_attr |= FD_ATTR_READ_ENABLE;
    617     if( (flags & O_WRONLY ) == 0 )  file_attr |= FD_ATTR_WRITE_ENABLE;
     616    if( (flags & O_RDONLY ) == 0 )  file_attr |= FD_ATTR_WRITE_ENABLE;
     617    if( (flags & O_WRONLY ) == 0 )  file_attr |= FD_ATTR_READ_ENABLE;
    618618    if( (flags & O_SYNC   )      )  file_attr |= FD_ATTR_SYNC;
    619619    if( (flags & O_APPEND )      )  file_attr |= FD_ATTR_APPEND;
     
    621621
    622622    // get extended pointer on target inode
    623     error = vfs_lookup( cwd_xp , path , lookup_mode , &inode_xp );
     623    error = vfs_lookup( process->vfs_cwd_xp , path , lookup_mode , &inode_xp );
    624624
    625625    if( error ) return error;
     
    629629    inode_ptr = (vfs_inode_t *)GET_PTR( inode_xp );
    630630   
     631vfs_dmsg("\n[DBG] %s : core[%x,%d] found inode for <%s> in cluster %x / cycle %d\n",
     632__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, inode_cxy , (uint32_t)hal_time_stamp() );
     633
    631634    // create a new file descriptor in cluster containing inode
    632635    if( inode_cxy == local_cxy )      // target cluster is local
     
    641644    if( error )  return error;
    642645
    643     // allocate and register a new file descriptor index in reference cluster fd_array
    644     error = process_fd_register( file_xp , &file_id );
     646    // allocate and register a new file descriptor index in reference process
     647    error = process_fd_register( process , file_xp , &file_id );
    645648
    646649    if( error ) return error;
    647650
    648     vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / file_xp = %l / cycle %d\n",
    649     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, file_xp, hal_time_stamp() );
     651vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / file = %x in cluster %x / cycle %d\n",
     652__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path,
     653GET_PTR(file_xp), GET_CXY(file_xp), hal_time_stamp() );
    650654
    651655    // success
     
    656660}  // end vfs_open()
    657661
    658 ////////////////////////////////////////////
    659 error_t vfs_user_move( bool_t   to_buffer,
    660                        xptr_t   file_xp,
    661                        void   * buffer,
    662                        uint32_t size )
    663 {
    664     assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" );
     662//////////////////////////////////////
     663int vfs_user_move( bool_t   to_buffer,
     664                   xptr_t   file_xp,
     665                   void   * buffer,
     666                   uint32_t size )
     667{
     668    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ ,
     669    "file_xp == XPTR_NULL" );
    665670
    666671    cxy_t              file_cxy;     // remote file descriptor cluster
     
    678683    inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type   ) );
    679684   
    680     // action depends on inode type
    681     if( inode_type == INODE_TYPE_FILE )
    682     {
    683         // get mapper pointer and file offset from file descriptor
    684         file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) );
    685         mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) );
    686 
    687         // move data between mapper and buffer
    688         if( file_cxy == local_cxy )
    689         {
    690             error = mapper_move_user( mapper,
    691                                       to_buffer,
    692                                       file_offset,
    693                                       buffer,
    694                                       size );
    695         }
    696         else
    697         {
    698             rpc_mapper_move_buffer_client( file_cxy,
    699                                            mapper,
    700                                            to_buffer,
    701                                            true,          // user buffer
    702                                            file_offset,
    703                                            (uint64_t)(intptr_t)buffer,
    704                                            size,
    705                                            &error );
    706         }
    707 
    708         if( error ) return -1;
    709         else        return 0;
    710     }
    711     else
    712     {
    713         printk("\n[ERROR] in %s : inode is not a file", __FUNCTION__ );
    714         return -1;
    715     }
     685    assert( (inode_type == INODE_TYPE_FILE) , __FUNCTION__ ,
     686    "inode type is not INODE_TYPE_FILE" );
     687
     688    // get mapper pointer and file offset from file descriptor
     689    file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) );
     690    mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) );
     691
     692    // move data between mapper and buffer
     693    if( file_cxy == local_cxy )
     694    {
     695        error = mapper_move_user( mapper,
     696                                  to_buffer,
     697                                  file_offset,
     698                                  buffer,
     699                                  size );
     700    }
     701    else
     702    {
     703        rpc_mapper_move_buffer_client( file_cxy,
     704                                       mapper,
     705                                       to_buffer,
     706                                       true,          // user buffer
     707                                       file_offset,
     708                                       (uint64_t)(intptr_t)buffer,
     709                                       size,
     710                                       &error );
     711    }
     712
     713    if( error ) return -1;
     714    else        return size;
     715
    716716}  // end vfs_user_move()
    717717
     
    905905    panic("not implemented");
    906906    return 0;
    907 }  // vfs_unlink()
    908 
    909 ///////////////////////////////////////
    910 error_t vfs_stat( xptr_t       file_xp,
    911                   vfs_stat_t * k_stat )
     907}
     908
     909////////////////////////////////////////
     910error_t vfs_stat( xptr_t        file_xp,
     911                  struct stat * k_stat )
    912912{
    913913    panic("not implemented");
     
    915915}
    916916
    917 ////////////////////////////////////////////
    918 error_t vfs_readdir( xptr_t         file_xp,
    919                      vfs_dirent_t * k_dirent )
     917/////////////////////////////////////////////
     918error_t vfs_readdir( xptr_t          file_xp,
     919                     struct dirent * k_dirent )
    920920{
    921921    panic("not implemented");
     
    10941094
    10951095    // display inode
    1096     nolock_printk("%s%s <%s> : inode = %l / mapper = %l / dentry = %l\n",
     1096    nolock_printk("%s%s <%s> : inode = %x / mapper = %x / cluster %x\n",
    10971097                  indent_str[indent], vfs_inode_type_str( inode_type ), name,
    1098                   inode_xp , XPTR( inode_cxy , mapper_ptr ) , dentry_xp );
     1098                  inode_ptr , mapper_ptr , inode_cxy );
    10991099
    11001100    // scan directory entries 
     
    11711171
    11721172    // get pointers on TXT0 chdev
    1173     xptr_t    txt0_xp  = chdev_dir.txt[0];
     1173    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
    11741174    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
    11751175    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     
    13381338    process = this->process;
    13391339
    1340     vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
    1341     __FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() );
     1340vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n",
     1341__FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() );
    13421342
    13431343    // get extended pointer on first inode to search
     
    13621362        vfs_get_name_from_path( current , name , &next , &last );
    13631363
    1364         vfs_dmsg("\n[INFO] %s : core[%x,%d] look for <%s> / last = %d\n",
    1365         __FUNCTION__ , local_cxy , this->core->lid , name , last );
     1364vfs_dmsg("\n[DBG] %s : core[%x,%d] look for <%s> / last = %d\n",
     1365__FUNCTION__ , local_cxy , this->core->lid , name , last );
    13661366
    13671367        // search a child dentry matching name in parent inode
     
    13801380        if (found == false ) // child node not found in inode tree
    13811381        {
    1382             vfs_dmsg("\n[INFO] %s : core[%x,%d] miss <%s> => load it\n",
    1383             __FUNCTION__ , local_cxy , this->core->lid , name );
     1382
     1383vfs_dmsg("\n[DBG] %s : core[%x,%d] miss <%s> => load it\n",
     1384__FUNCTION__ , local_cxy , this->core->lid , name );
    13841385
    13851386            // release lock on parent inode
     
    14051406            if( error )
    14061407            {
    1407                 printk("\n[ERROR] in %s : no memory for inode %s in path %s\n",
     1408                printk("\n[ERROR] in %s : no memory for inode <%s> in path <%s>\n",
    14081409                __FUNCTION__ , name , pathname );
    14091410                return ENOMEM;
     
    14281429            if ( error )
    14291430            {
    1430                 printk("\n[ERROR] in %s : core[%x,%d] / <%s> not found in parent\n",
    1431                 __FUNCTION__ , local_cxy , this->core->lid , name );
     1431                printk("\n[ERROR] in %s : core[%x,%d] / <%s> node not found in <%s>\n",
     1432                __FUNCTION__ , local_cxy , this->core->lid , name , pathname );
    14321433                return ENOENT;
    14331434            }
     
    14641465            vfs_inode_lock( parent_xp );
    14651466
    1466             vfs_dmsg("\n[INFO] %s : core[%x,%d] created node <%s>\n",
    1467             __FUNCTION__ , local_cxy , this->core->lid , name );
     1467vfs_dmsg("\n[DBG] %s : core[%x,%d] created node <%s>\n",
     1468__FUNCTION__ , local_cxy , this->core->lid , name );
     1469
    14681470        }
    14691471
    1470         vfs_dmsg("\n[INFO] %s : core[%x,%d] found <%s> / parent = %l / child = %l\n",
    1471         __FUNCTION__ , local_cxy , this->core->lid , name , parent_xp , child_xp );
     1472vfs_dmsg("\n[DBG] %s : core[%x,%d] found <%s> / inode = %x in cluster %x\n",
     1473__FUNCTION__ , local_cxy , this->core->lid , name , GET_PTR(child_xp) , GET_CXY(child_xp) );
    14721474
    14731475        // TODO check access rights here [AG]
     
    14941496    vfs_inode_unlock( parent_xp );
    14951497
    1496     vfs_dmsg("\n[INFO] %s : exit <%s> found / inode = %l\n",
    1497                  __FUNCTION__ , pathname , child_xp );
     1498vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / inode = %x in cluster %x\n",
     1499__FUNCTION__,local_cxy,this->core->lid,pathname,GET_PTR(child_xp),GET_CXY(child_xp) );
    14981500
    14991501    // return searched pointer
     
    15931595    parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp );
    15941596
    1595     vfs_dmsg("\n[INFO] %s : enter for <%s> / core[%x,%d] / child_cxy = %x / parent_xp = %l\n",
    1596     __FUNCTION__ , name , local_cxy , CURRENT_THREAD->core->lid , child_cxy , parent_xp );
     1597vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / child_cxy = %x / parent_cxy = %x\n",
     1598__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , child_cxy , parent_cxy );
    15971599
    15981600    // 1. create dentry
     
    16041606                                   &dentry_xp );
    16051607
    1606         vfs_dmsg("\n[INFO] %s : dentry <%s> created in local cluster %x\n",
    1607         __FUNCTION__ , name , local_cxy );
     1608vfs_dmsg("\n[DBG] %s : dentry <%s> created in local cluster %x\n",
     1609__FUNCTION__ , name , local_cxy );
     1610
    16081611    }
    16091612    else                               // parent cluster is remote
     
    16161619                                      &error );
    16171620
    1618         vfs_dmsg("\n[INFO] %s : dentry <%s> created in remote cluster %x\n",
    1619         __FUNCTION__ , name , parent_cxy );
     1621vfs_dmsg("\n[DBG] %s : dentry <%s> created in remote cluster %x\n",
     1622__FUNCTION__ , name , parent_cxy );
     1623
    16201624    }
    16211625                                     
     
    16231627    {
    16241628        printk("\n[ERROR] in %s : cannot create dentry in cluster %x\n",
    1625                __FUNCTION__ , parent_cxy );
     1629        __FUNCTION__ , parent_cxy );
    16261630        return ENOMEM;
    16271631    }
     
    16451649                                  &inode_xp );
    16461650
    1647         vfs_dmsg("\n[INFO] %s : inode %l created in local cluster %x\n",
    1648                  __FUNCTION__ , inode_xp , local_cxy );
     1651vfs_dmsg("\n[DBG] %s : inode %x created in local cluster %x\n",
     1652__FUNCTION__ , GET_PTR(inode_xp) , local_cxy );
     1653
    16491654    }
    16501655    else                              // child cluster is remote
     
    16621667                                     &error );
    16631668
    1664         vfs_dmsg("\n[INFO] %s : inode %l created in remote cluster %x\n",
    1665                  __FUNCTION__ , inode_xp , child_cxy );
     1669vfs_dmsg("\n[DBG] %s : inode %x created in remote cluster %x\n",
     1670__FUNCTION__ , GET_PTR(inode_xp) , child_cxy );
     1671
    16661672    }
    16671673                                     
     
    16821688    hal_remote_swd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp );
    16831689
    1684     vfs_dmsg("\n[INFO] %s : exit in cluster %x for <%s>\n",
    1685     __FUNCTION__ , local_cxy , name );
     1690vfs_dmsg("\n[DBG] %s : exit in cluster %x for <%s>\n",
     1691__FUNCTION__ , local_cxy , name );
    16861692
    16871693    // success : return extended pointer on child inode
     
    17071713    assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" );
    17081714
    1709     vfs_dmsg("\n[DMSG] %s : enters for page %d / inode_cxy = %x / inode_ptr = %x\n",
    1710     __FUNCTION__ , page->index , local_cxy , mapper->inode );
     1715vfs_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper = %x / inode = %x\n",
     1716__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid , page->index , mapper, mapper->inode );
    17111717
    17121718    // get FS type
     
    17331739    }
    17341740
    1735     vfs_dmsg("\n[DMSG] %s : exit for page %d / inode_cxy = %x / inode_ptr = %x\n",
    1736     __FUNCTION__ , page->index , local_cxy , mapper->inode );
     1741vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / mapper = %x / inode = %x\n",
     1742__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, page->index, mapper, mapper->inode );
    17371743
    17381744    return error;
     
    17531759    assert( (mapper != NULL) , __FUNCTION__ , "mapper pointer is NULL\n" );
    17541760
    1755     vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %l / cycle %d\n",
    1756     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) );
     1761vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for inode %x in cluster %x/ cycle %d\n",
     1762__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() );
    17571763
    17581764    // compute number of pages
     
    17701776    }
    17711777
    1772     vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %l / cycle %d\n",
    1773     __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) );
     1778vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for inode %x in cluster %x / cycle %d\n",
     1779__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() );
    17741780
    17751781    return 0;
  • 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.