Changeset 305 for trunk/kernel/syscalls/sys_unlink.c
- Timestamp:
- Jul 31, 2017, 2:46:50 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_unlink.c
r23 r305 1 1 /* 2 2 * sys_unlink.c - file unlink 3 * 3 * 4 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites … … 31 31 int sys_unlink ( char * pathname ) 32 32 { 33 error_t error; 34 uint32_t length; 33 error_t error; 35 34 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 36 35 37 38 36 thread_t * this = CURRENT_THREAD; 37 process_t * process = this->process; 39 38 40 // get pathname length41 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 ); 42 41 43 if( length >= CONFIG_VFS_MAX_PATH_LENGTH)42 if( error ) 44 43 { 45 44 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 46 45 this->errno = ENFILE; 47 46 return -1; 48 47 } 49 50 // get pathname copy in kernel space51 hal_copy_from_uspace( kbuf, pathname, length );52 48 53 49 // get cluster and local pointer on reference process … … 57 53 58 54 // get the cwd lock in read mode from reference process 59 55 remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) ); 60 56 61 57 // get extended pointer on cwd inode … … 66 62 67 63 // release the cwd lock in reference process 68 64 remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) ); 69 65 70 71 66 if( error ) 67 { 72 68 printk("\n[ERROR] in %s : cannot unlink file/dir %s\n", 73 69 __FUNCTION__ , pathname ); 74 75 76 70 this->errno = ENFILE; 71 return -1; 72 } 77 73 78 74 return 0; 79 75 80 76 } // end sys_unlink()
Note: See TracChangeset
for help on using the changeset viewer.