Ignore:
Timestamp:
Dec 27, 2018, 7:38:58 PM (3 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/syscalls/sys_unlink.c

    r604 r610  
    11/*
    2  * sys_unlink.c - file unlink a file
     2 * sys_unlink.c - unlink a file or directorya from VFS
    33 *
    44 * Author     Alain Greiner (2016,2017,2018)
     
    3737{
    3838    error_t   error;
     39    xptr_t    root_inode_xp;           // extended pointer on path root inode
     40
    3941    char      kbuf[CONFIG_VFS_MAX_PATH_LENGTH];
    4042
     
    6668#endif
    6769 
    68     // get cluster and local pointer on reference process
    69     xptr_t      ref_xp  = process->ref_xp;
    70     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
    71     cxy_t       ref_cxy = GET_CXY( ref_xp );
     70    // compute root inode for path
     71    if( kbuf[0] == '/' )                        // absolute path
     72    {
     73        // use extended pointer on VFS root inode
     74        root_inode_xp = process->vfs_root_xp;
     75    }
     76    else                                        // relative path
     77    {
     78        // get cluster and local pointer on reference process
     79        xptr_t      ref_xp  = process->ref_xp;
     80        process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
     81        cxy_t       ref_cxy = GET_CXY( ref_xp );
    7282
    73     // get the cwd lock in write mode from reference process
    74     remote_rwlock_wr_acquire( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     83        // use extended pointer on CWD inode
     84        root_inode_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->cwd_xp ) );
     85    }
    7586
    76     // get extended pointer on cwd inode
    77     xptr_t cwd_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) );
    78 
    79     // call relevant VFS function
    80     error  = vfs_unlink( cwd_xp , kbuf );
    81 
    82     // release the cwd lock in reference process
    83     remote_rwlock_wr_release( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     87    // call the relevant VFS function
     88    error  = vfs_unlink( root_inode_xp , kbuf );
    8489
    8590    if( error )
Note: See TracChangeset for help on using the changeset viewer.