Changeset 246 for trunk/kernel/vfs/vfs.c


Ignore:
Timestamp:
Jul 20, 2017, 12:55:23 PM (7 years ago)
Author:
alain
Message:

Fix a major bug in FATFS : miss handling in the FAT mapper.

File:
1 edited

Legend:

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

    r238 r246  
    161161    {
    162162        ctx = NULL;
    163         printk("\n[PANIC] in %s : undefined file system type\n", __FUNCTION__ );
     163                printk("\n[PANIC] in %s : illegal file system type = %d\n", __FUNCTION__ , fs_type );
    164164        hal_core_sleep();
    165165    }
     
    175175
    176176    // allocate memory for mapper
    177     mapper = mapper_create();
     177    mapper = mapper_create( fs_type );
    178178
    179179    if( mapper == NULL )
     
    209209    inode->parent_xp  = dentry_xp;
    210210    inode->ctx        = ctx;
    211     inode->mapper     = NULL; 
     211    inode->mapper     = mapper;
    212212    inode->extend     = extend;
    213213
     214    // initialise inode field in mapper
     215    mapper->inode     = inode;
     216 
    214217    // initialise threads waiting queue
    215218    xlist_root_init( XPTR( local_cxy , &inode->wait_root ) );
     
    253256                        xptr_t        child_xp )
    254257{
     258    vfs_dmsg("\n[INFO] %s : enter for child <%s>\n",
     259             __FUNCTION__ , name );
     260
    255261    error_t error = 0;
    256262
     
    279285        assert( false , __FUNCTION__ , "undefined file system type\n" );
    280286    }
     287
     288    vfs_dmsg("\n[INFO] %s : exit for child <%s>\n",
     289             __FUNCTION__ , name );
    281290
    282291    return error;
     
    12531262        // for the last name, the behaviour depends on the "mode" argument:
    12541263
    1255         if (found == false ) // directory node not found in inode tree
     1264        if (found == false ) // child node not found in inode tree
    12561265        {
    12571266            vfs_dmsg("\n[INFO] %s : <%s> not found, try to load it\n",
     
    15591568    assert( (page != NULL) , __FUNCTION__ , "page pointer is NULL\n" );
    15601569
    1561     mapper_t * mapper = page->mapper;
     1570    mapper_t    * mapper = page->mapper;
     1571
    15621572
    15631573    assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" );
    15641574
     1575    vfs_dmsg("\n[INFO] %s : enters for page = %d in mapper = %x\n",
     1576             __FUNCTION__ , page->index , mapper );
     1577
    15651578    // get FS type
    1566     vfs_fs_type_t fs_type = mapper->inode->ctx->type;
     1579    vfs_fs_type_t fs_type = mapper->type;
    15671580
    15681581    // call relevant FS function
     
    15701583    {
    15711584        rwlock_wr_lock( &mapper->lock );
    1572         error = fatfs_move_page( page , to_mapper );
     1585        error = fatfs_mapper_move_page( page , to_mapper );
    15731586        rwlock_wr_unlock( &mapper->lock );
    15741587    }
     
    15851598        assert( false , __FUNCTION__ , "undefined file system type\n" );
    15861599    }
     1600
     1601    vfs_dmsg("\n[INFO] %s : exit for page = %d in mapper = %x\n",
     1602             __FUNCTION__ , page->index , mapper );
    15871603
    15881604    return error;
Note: See TracChangeset for help on using the changeset viewer.