Ignore:
Timestamp:
Dec 27, 2018, 7:38:58 PM (5 years ago)
Author:
alain
Message:

Fix several bugs in VFS to support the following
ksh commandis : cp, mv, rm, mkdir, cd, pwd

File:
1 edited

Legend:

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

    r602 r610  
    12461246vfs_inode_get_name( XPTR( local_cxy , inode ) , dir_name );
    12471247if( DEBUG_FATFS_REMOVE_DENTRY < cycle )
    1248 printk("\n[%s]  thread[%x,%x] enter / parent <%s> / child <%s> / cycle %d\n",
     1248printk("\n[%s] thread[%x,%x] enter / parent <%s> / child <%s> / cycle %d\n",
    12491249__FUNCTION__, this->process->pid, this->trdid, dir_name, dentry->name, cycle );
    12501250#endif
     
    12801280    uint32_t  page_id    = dentry_id >> 7;
    12811281    uint32_t  offset     = (dentry_id & 0x7F)<<5;
     1282
     1283#if DEBUG_FATFS_REMOVE_DENTRY & 1
     1284if( DEBUG_FATFS_REMOVE_DENTRY < cycle )
     1285printk("\n[%s] dentry_id %x / page_id %x / offset %x\n",
     1286__FUNCTION__, dentry_id, page_id, offset );
     1287#endif
    12821288
    12831289    // get extended pointer on page descriptor from parent directory mapper
     
    13451351cycle = (uint32_t)hal_get_cycles();
    13461352if( DEBUG_FATFS_REMOVE_DENTRY < cycle )
    1347 printk("\n[%s]  thread[%x,%x] exit / parent %s / child %s / cycle %d\n",
     1353printk("\n[%s] thread[%x,%x] exit / parent %s / child %s / cycle %d\n",
    13481354__FUNCTION__, this->process->pid, this->trdid, dir_name, dentry->name, cycle );
    13491355#endif
     
    13581364                          xptr_t        child_inode_xp )
    13591365{
    1360     // Two embedded loops:
     1366    // Two embedded loops to scan the directory mapper:
    13611367    // - scan the parent directory mapper pages
    13621368    // - scan the directory entries in each 4 Kbytes page
     
    15121518    // get child inode cluster and local pointer
    15131519    cxy_t          inode_cxy = GET_CXY( child_inode_xp );
    1514     vfs_inode_t  * inode_ptr = (vfs_inode_t *)GET_PTR( child_inode_xp );
     1520    vfs_inode_t  * inode_ptr = GET_PTR( child_inode_xp );
     1521
     1522    // build extended pointer on parent dentried root
     1523    xptr_t parents_root_xp = XPTR( inode_cxy , &inode_ptr->parents );
     1524
     1525// check child inode has at least one parent
     1526assert( (xlist_is_empty( parents_root_xp ) == false ), "child inode must have one parent\n");
    15151527
    15161528    // get dentry pointers and cluster
    1517     xptr_t         dentry_xp  = hal_remote_l64( XPTR( inode_cxy , &inode_ptr->parent_xp ) ); 
     1529    xptr_t         dentry_xp  = XLIST_FIRST( parents_root_xp , vfs_dentry_t , parents );
    15181530    vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp );
    15191531    cxy_t          dentry_cxy = GET_CXY( dentry_xp );
    15201532
    1521 // dentry descriptor must be in same cluster as parent inode
     1533// check dentry descriptor in same cluster as parent inode
    15221534assert( (dentry_cxy == local_cxy) , "illegal dentry cluster\n" );
    15231535
Note: See TracChangeset for help on using the changeset viewer.