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