Changeset 611 for trunk/kernel/syscalls/sys_opendir.c
- Timestamp:
- Jan 9, 2019, 3:02:51 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_opendir.c
r610 r611 1 1 /* 2 * sys_opendir.c - open adirectory.2 * sys_opendir.c - Open a VFS directory. 3 3 * 4 4 * Author Alain Greiner (2016,2017,2018) … … 22 22 */ 23 23 24 #include <kernel_config.h> 24 25 #include <hal_kernel_types.h> 25 26 #include <hal_uspace.h> 26 27 #include <thread.h> 27 28 #include <process.h> 29 #include <remote_dir.h> 28 30 #include <printk.h> 29 31 #include <errno.h> 32 #include <vseg.h> 30 33 #include <vfs.h> 31 34 #include <syscalls.h> … … 36 39 DIR ** dirp ) 37 40 { 38 error_t error; 39 vseg_t * vseg; // for user space checking 40 xptr_t root_inode_xp; // extended pointer on path root inode 41 41 error_t error; 42 xptr_t root_inode_xp; // extended pointer on path root inode 43 xptr_t inode_xp; // extended pointer on directory inode 44 vfs_inode_t * inode_ptr; // local pointer on directory inode 45 cxy_t inode_cxy; // directory inode cluster 46 uint32_t inode_type; // to check directory inode type 47 xptr_t dir_xp; // extended pointer on remote_dir_t 48 remote_dir_t * dir_ptr; // local pointer on remote_dir_t 49 cxy_t dir_cxy; // remote_dir_t cluster identifier 50 vseg_t * vseg; // for user space checking 51 intptr_t ident; // dirent array pointer in user space 42 52 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 43 53 44 thread_t * this = CURRENT_THREAD;45 process_t * process = this->process;54 thread_t * this = CURRENT_THREAD; // client thread 55 process_t * process = this->process; // client process 46 56 47 57 #if (DEBUG_SYS_OPENDIR || CONFIG_INSTRUMENTATION_SYSCALLS) … … 85 95 #endif 86 96 87 // compute root inode for path 97 // compute root inode for pathname 88 98 if( kbuf[0] == '/' ) // absolute path 89 99 { … … 102 112 } 103 113 104 /* 105 // call the relevant VFS function ??? 106 error = vfs_opendir( root_inode_xp, 107 kbuf ); 114 // get extended pointer on directory inode 115 error = vfs_lookup( root_inode_xp, 116 kbuf, 117 0, 118 &inode_xp, 119 NULL ); 108 120 if( error ) 109 121 { 110 122 111 123 #if DEBUG_SYSCALLS_ERROR 112 printk("\n[ERROR] in %s / thread[%x,%x] : cannot opendirectory <%s>\n",113 __FUNCTION__ , process->pid , this->trdid , pathname);124 printk("\n[ERROR] in %s / thread[%x,%x] : cannot found directory <%s>\n", 125 __FUNCTION__ , process->pid , this->trdid , kbuf ); 114 126 #endif 115 127 this->errno = ENFILE; … … 117 129 } 118 130 119 // copy to user space ??? 120 */ 131 // check inode type 132 inode_ptr = GET_PTR( inode_xp ); 133 inode_cxy = GET_CXY( inode_xp ); 134 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 135 136 if( inode_type != INODE_TYPE_DIR ) 137 { 138 139 #if DEBUG_SYSCALLS_ERROR 140 printk("\n[ERROR] in %s / thread[%x,%x] : cannot found directory <%s>\n", 141 __FUNCTION__ , process->pid , this->trdid , kbuf ); 142 #endif 143 this->errno = ENFILE; 144 return -1; 145 } 146 147 // allocate, initialize, and register a new remote_dir_t structure 148 // in the calling process reference cluster 149 dir_xp = remote_dir_create( inode_xp ); 150 dir_ptr = GET_PTR( dir_xp ); 151 dir_cxy = GET_CXY( dir_xp ); 152 153 if( dir_xp == XPTR_NULL ) 154 { 155 156 #if DEBUG_SYSCALLS_ERROR 157 printk("\n[ERROR] in %s / thread[%x,%x] : cannot create remote_dir for <%s>\n", 158 __FUNCTION__ , process->pid , this->trdid , kbuf ); 159 #endif 160 this->errno = ENFILE; 161 return -1; 162 } 163 164 // get ident from remote_dir structure 165 ident = (intptr_t)hal_remote_lpt( XPTR( dir_cxy , &dir_ptr->ident ) ); 166 167 // set ident value in user buffer 168 hal_copy_to_uspace( dirp , &ident , sizeof(intptr_t) ); 121 169 122 170 hal_fence();
Note: See TracChangeset
for help on using the changeset viewer.