Changeset 670 for trunk/kernel/syscalls/sys_open.c
- Timestamp:
- Nov 19, 2020, 11:45:52 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_open.c
r637 r670 39 39 uint32_t mode ) 40 40 { 41 vseg_t * vseg; 41 42 error_t error; 42 43 xptr_t file_xp; // extended pointer on vfs_file_t 43 44 uint32_t file_id; // file descriptor index 44 xptr_t root_inode_xp; // extended pointer on pathroot inode45 xptr_t root_inode_xp; // extended pointer on root inode 45 46 46 47 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; … … 49 50 process_t * process = this->process; 50 51 51 #if (DEBUG_SYS_OPEN || CONFIG_INSTRUMENTATION_SYSCALLS)52 #if DEBUG_SYS_OPEN || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 52 53 uint64_t tm_start = hal_get_cycles(); 53 54 #endif … … 58 59 59 60 #if DEBUG_SYSCALLS_ERROR 60 printk("\n[ERROR] in %s : file descriptor array full for process %x\n", 61 __FUNCTION__ , process->pid ); 61 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 62 printk("\n[ERROR] in %s : file descriptor array full for thread[%x,%x]\n", 63 __FUNCTION__ , process->pid , this->trdid ); 62 64 #endif 63 65 this->errno = ENFILE; 64 66 return -1; 65 67 } 68 69 // check pathname in user space 70 if( vmm_get_vseg( process, (intptr_t)pathname , &vseg ) ) 71 { 72 73 #if DEBUG_SYSCALLS_ERROR 74 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 75 printk("\n[ERROR] in %s : user buffer unmapped %x for thread[%x,%x]\n", 76 __FUNCTION__ , (intptr_t)pathname , process->pid, this->trdid ); 77 #endif 78 this->errno = EINVAL; 79 return -1; 80 } 66 81 67 82 // check pathname length … … 70 85 71 86 #if DEBUG_SYSCALLS_ERROR 72 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 87 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 88 printk("\n[ERROR] in %s : pathname too long for thread[%x,%x]\n", 89 __FUNCTION__ , process->pid , this->trdid ); 73 90 #endif 74 91 this->errno = ENFILE; … … 77 94 78 95 // copy pathname in kernel space 79 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ) , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 80 96 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 97 pathname, 98 CONFIG_VFS_MAX_PATH_LENGTH ); 81 99 #if DEBUG_SYS_OPEN 82 100 if( DEBUG_SYS_OPEN < tm_start ) … … 86 104 87 105 // get cluster and local pointer on reference process 88 xptr_t ref_xp = process->ref_xp;89 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );90 cxy_t ref_cxy = GET_CXY( ref_xp );106 xptr_t owner_xp = process->owner_xp; 107 process_t * owner_ptr = GET_PTR( owner_xp ); 108 cxy_t owner_cxy = GET_CXY( owner_xp ); 91 109 92 // compute root inode for path93 if( kbuf[0] == '/' ) // absolute path110 // get extended pointer on root inode in path 111 if( kbuf[0] == '/' ) // absolute path 94 112 { 95 113 // use extended pointer on VFS root inode 96 114 root_inode_xp = process->vfs_root_xp; 97 115 } 98 else // relative path116 else // relative path 99 117 { 100 118 // use extended pointer on CWD inode 101 root_inode_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->cwd_xp ) );119 root_inode_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->cwd_xp ) ); 102 120 } 103 121 … … 105 123 error = vfs_open( root_inode_xp, 106 124 kbuf, 107 ref_xp,125 owner_xp, 108 126 flags, 109 127 mode, … … 113 131 if( error ) 114 132 { 115 printk("\n[ERROR] in %s : cannot create file descriptor for %s\n", 116 __FUNCTION__ , kbuf ); 133 134 #if DEBUG_SYSCALLS_ERROR 135 if( DEBUG_SYSCALLS_ERROR < tm_start ) 136 printk("\n[ERROR] in %s : thread[%x,%x] cannot create file descriptor for %s\n", 137 __FUNCTION__ , process->pid , this->trdid , kbuf ); 138 #endif 117 139 this->errno = ENFILE; 118 140 return -1;
Note: See TracChangeset
for help on using the changeset viewer.