Ignore:
Timestamp:
Jul 31, 2017, 2:46:50 PM (7 years ago)
Author:
max@…
Message:

Style, and use hal_strcpy_from_uspace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_unlink.c

    r23 r305  
    11/*
    22 * sys_unlink.c - file unlink
    3  * 
     3 *
    44 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
    55 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
     
    3131int sys_unlink ( char * pathname )
    3232{
    33         error_t   error;
    34     uint32_t  length;
     33    error_t   error;
    3534    char      kbuf[CONFIG_VFS_MAX_PATH_LENGTH];
    3635
    37         thread_t     * this     = CURRENT_THREAD;
    38         process_t    * process  = this->process;
     36    thread_t     * this     = CURRENT_THREAD;
     37    process_t    * process  = this->process;
    3938
    40     // get pathname length
    41     length = hal_strlen_from_uspace( pathname );
     39    // get pathname copy in kernel space
     40    error = hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    4241
    43     if( length >= CONFIG_VFS_MAX_PATH_LENGTH )
     42    if( error )
    4443    {
    4544        printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
    46                 this->errno = ENFILE;
     45        this->errno = ENFILE;
    4746        return -1;
    4847    }
    49  
    50         // get pathname copy in kernel space
    51     hal_copy_from_uspace( kbuf, pathname, length );
    5248
    5349    // get cluster and local pointer on reference process
     
    5753
    5854    // get the cwd lock in read mode from reference process
    59         remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     55    remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    6056
    6157    // get extended pointer on cwd inode
     
    6662
    6763    // release the cwd lock in reference process
    68         remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
     64    remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) );
    6965
    70         if( error )
    71         {
     66    if( error )
     67    {
    7268        printk("\n[ERROR] in %s : cannot unlink file/dir %s\n",
    7369               __FUNCTION__ , pathname );
    74                 this->errno = ENFILE;
    75             return -1;
    76         }
     70        this->errno = ENFILE;
     71        return -1;
     72    }
    7773
    78         return 0;
     74    return 0;
    7975
    8076} // end sys_unlink()
Note: See TracChangeset for help on using the changeset viewer.