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