Changeset 302 for trunk/kernel/syscalls/sys_chmod.c
- Timestamp:
- Jul 31, 2017, 2:36:48 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_chmod.c
r23 r302 1 1 /* 2 2 * sys_chmod.c - Change file access rights. 3 * 3 * 4 4 * Author Alain Greiner (2016,2017) 5 5 * … … 35 35 { 36 36 error_t error; 37 paddr_t paddr;38 uint32_t length;39 37 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 40 41 thread_t * this = CURRENT_THREAD;42 process_t * process = this->process;43 38 44 // check pathname in user space45 error = vmm_v2p_translate( false , pathname , &paddr );39 thread_t * this = CURRENT_THREAD; 40 process_t * process = this->process; 46 41 47 if( error ) 48 { 49 printk("\n[ERROR] in %s : user pathname unmapped for thread %x in process %x\n", 50 __FUNCTION__ , this->trdid , process->pid ); 51 this->errno = EINVAL; 52 return -1; 53 } 42 // get pathname copy in kernel space 43 error = hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 54 44 55 // get pathname length 56 length = hal_strlen_from_uspace( pathname ); 57 58 if( length >= CONFIG_VFS_MAX_PATH_LENGTH ) 45 if( error ) 59 46 { 60 47 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 61 48 this->errno = ENFILE; 62 49 return -1; 63 50 } 64 65 // get pathname copy in kernel space66 hal_copy_from_uspace( kbuf, pathname, length );67 51 68 52 // get cluster and local pointer on reference process … … 73 57 // get extended pointer on cwd inode 74 58 xptr_t cwd_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->vfs_cwd_xp ) ); 75 59 76 60 // get the cwd lock in read mode from reference process 77 61 remote_rwlock_rd_lock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) ); 78 62 79 63 // call the relevant VFS function 80 64 error = vfs_chmod( cwd_xp, 81 65 kbuf, 82 66 rights ); 83 67 84 68 // release the cwd lock 85 69 remote_rwlock_rd_unlock( XPTR( ref_cxy , &ref_ptr->cwd_lock ) ); 86 70 87 71 if( error ) 88 72 { 89 73 printk("\n[ERROR] in %s : cannot remove directory %s\n", 90 74 __FUNCTION__ , kbuf ); 91 this->errno = error; 92 return -1; 93 } 94 95 return 0; 75 this->errno = error; 76 return -1; 77 } 96 78 97 } // end sys_chmod() 79 return 0; 80 81 } // end sys_chmod()
Note: See TracChangeset
for help on using the changeset viewer.