Changeset d8a9155 in rtems
- Timestamp:
- 04/20/01 21:11:25 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 6de4727f
- Parents:
- dd74e612
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/include/rtems/libio_.h
rdd74e612 rd8a9155 210 210 */ 211 211 typedef struct { 212 rtems_id task_id; 212 213 rtems_filesystem_location_info_t current_directory; 213 214 rtems_filesystem_location_info_t root_directory; … … 230 231 231 232 rtems_status_code rtems_libio_set_private_env(void); 233 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; 234 232 235 233 236 -
c/src/exec/libcsupport/include/rtems/libio_.h
rdd74e612 rd8a9155 210 210 */ 211 211 typedef struct { 212 rtems_id task_id; 212 213 rtems_filesystem_location_info_t current_directory; 213 214 rtems_filesystem_location_info_t root_directory; … … 230 231 231 232 rtems_status_code rtems_libio_set_private_env(void); 233 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; 234 232 235 233 236 -
c/src/exec/libcsupport/src/chroot.c
rdd74e612 rd8a9155 31 31 rtems_filesystem_location_info_t loc; 32 32 33 if (rtems_current_user_env == &rtems_global_user_env) 33 /* an automatic call to new private env the first time */ 34 if (rtems_current_user_env == &rtems_global_user_env) { 35 rtems_libio_set_private_env(); /* try to set a new private env*/ 36 if (rtems_current_user_env == &rtems_global_user_env) /* not ok */ 34 37 set_errno_and_return_minus_one( ENOTSUP ); 38 }; 35 39 36 40 loc = rtems_filesystem_root; /* save the value */ 37 38 /* if has been already changed */39 rtems_filesystem_root = rtems_global_user_env.root_directory;40 41 41 42 result = chdir(pathname); … … 46 47 rtems_filesystem_root = rtems_filesystem_current; 47 48 48 result = chdir("/");49 if (result) {50 rtems_filesystem_root = loc; /* restore the value */51 set_errno_and_return_minus_one( errno );52 };53 54 /*XXX : Call this? Sorry but I don't known if it is necesary */55 /* The old root.56 rtems_filesystem_freenode( &loc );57 */58 49 return 0; 59 50 } -
c/src/exec/libcsupport/src/privateenv.c
rdd74e612 rd8a9155 24 24 rtems_status_code rtems_libio_set_private_env(void) { 25 25 rtems_status_code sc; 26 rtems_id task_id; 26 27 27 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free); 28 if (sc != RTEMS_SUCCESSFUL) 29 return sc; 28 sc=rtems_task_ident(RTEMS_SELF,0,&task_id); 29 if (sc != RTEMS_SUCCESSFUL) return sc; 30 30 31 rtems_current_user_env = malloc(sizeof(rtems_user_env_t)); 32 if (!rtems_current_user_env) 33 return RTEMS_NO_MEMORY; 31 /* Only for the first time a malloc is necesary */ 32 if (rtems_current_user_env==&rtems_global_user_env) { 33 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free); 34 if (sc != RTEMS_SUCCESSFUL) return sc; 35 rtems_current_user_env = malloc(sizeof(rtems_user_env_t)); 36 if (!rtems_current_user_env) 37 return RTEMS_NO_MEMORY; 38 }; 34 39 35 *rtems_current_user_env = rtems_global_user_env; 40 /* the side effect desired . chroot("/") */ 41 *rtems_current_user_env = rtems_global_user_env; /* get the global values*/ 42 rtems_current_user_env->task_id=task_id; /* mark the local values*/ 43 36 44 return RTEMS_SUCCESSFUL; 37 45 } 46 47 /* 48 * Share a same private environment beetween two task: 49 * Task_id (remote) and RTEMS_SELF(current). 50 */ 51 52 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) { 53 rtems_status_code sc; 54 rtems_user_env_t * shared_user_env; 55 rtems_id current_task_id; 56 57 sc=rtems_task_ident(RTEMS_SELF,0,¤t_task_id); 58 if (sc != RTEMS_SUCCESSFUL) return sc; 59 60 if (rtems_current_user_env->task_id==current_task_id) { 61 /* kill the current user env & task_var*/ 62 free(rtems_current_user_env); 63 sc = rtems_task_variable_delete(RTEMS_SELF,(void*)&rtems_current_user_env); 64 if (sc != RTEMS_SUCCESSFUL) return sc; 65 }; 66 67 sc = rtems_task_variable_get(task_id,(void*)&rtems_current_user_env, 68 (void*)&shared_user_env ); 69 if (sc != RTEMS_SUCCESSFUL) return sc; 70 71 /* don't free(NULL'ed) at the task_delete. It is a shared var... */ 72 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,NULL); 73 if (sc != RTEMS_SUCCESSFUL) return sc; 74 75 /* the current_user_env is the same pointer that remote env */ 76 rtems_current_user_env = shared_user_env; 77 78 return RTEMS_SUCCESSFUL; 79 } -
c/src/lib/ChangeLog
rdd74e612 rd8a9155 1 2001-04-20 Correo Fernando-ruiz <correo@fernando-ruiz.com> 2 3 * include/rtems/libio_.h, libc/chroot.c, libc/privateenv.c: 4 Private environment and chroot() enhancements and fixes. Comments: 5 + privateenv has been modified to let at chroot() to be more 6 POSIX like Sergei Organov recommended. 7 + A task owner lets that rtems_set_private_env() will be 8 called twice or more times. 9 + chroot() can be called without a previous 10 rtems_set_private_env(); (transpanrently) 11 + The second call of rtems_set_private_env() makes a internal 12 chroot("/") into global imfs_root. 13 + chroot() runs like chdir() without a previous chdir("/") with 14 the global root. 15 + The current directory can be in a wrong place like Linux and 16 many other Unices. 17 1 18 2001-04-16 Joel Sherrill <joel@OARcorp.com> 2 19 -
c/src/lib/include/rtems/libio_.h
rdd74e612 rd8a9155 210 210 */ 211 211 typedef struct { 212 rtems_id task_id; 212 213 rtems_filesystem_location_info_t current_directory; 213 214 rtems_filesystem_location_info_t root_directory; … … 230 231 231 232 rtems_status_code rtems_libio_set_private_env(void); 233 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; 234 232 235 233 236 -
c/src/lib/libc/chroot.c
rdd74e612 rd8a9155 31 31 rtems_filesystem_location_info_t loc; 32 32 33 if (rtems_current_user_env == &rtems_global_user_env) 33 /* an automatic call to new private env the first time */ 34 if (rtems_current_user_env == &rtems_global_user_env) { 35 rtems_libio_set_private_env(); /* try to set a new private env*/ 36 if (rtems_current_user_env == &rtems_global_user_env) /* not ok */ 34 37 set_errno_and_return_minus_one( ENOTSUP ); 38 }; 35 39 36 40 loc = rtems_filesystem_root; /* save the value */ 37 38 /* if has been already changed */39 rtems_filesystem_root = rtems_global_user_env.root_directory;40 41 41 42 result = chdir(pathname); … … 46 47 rtems_filesystem_root = rtems_filesystem_current; 47 48 48 result = chdir("/");49 if (result) {50 rtems_filesystem_root = loc; /* restore the value */51 set_errno_and_return_minus_one( errno );52 };53 54 /*XXX : Call this? Sorry but I don't known if it is necesary */55 /* The old root.56 rtems_filesystem_freenode( &loc );57 */58 49 return 0; 59 50 } -
c/src/lib/libc/privateenv.c
rdd74e612 rd8a9155 24 24 rtems_status_code rtems_libio_set_private_env(void) { 25 25 rtems_status_code sc; 26 rtems_id task_id; 26 27 27 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free); 28 if (sc != RTEMS_SUCCESSFUL) 29 return sc; 28 sc=rtems_task_ident(RTEMS_SELF,0,&task_id); 29 if (sc != RTEMS_SUCCESSFUL) return sc; 30 30 31 rtems_current_user_env = malloc(sizeof(rtems_user_env_t)); 32 if (!rtems_current_user_env) 33 return RTEMS_NO_MEMORY; 31 /* Only for the first time a malloc is necesary */ 32 if (rtems_current_user_env==&rtems_global_user_env) { 33 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free); 34 if (sc != RTEMS_SUCCESSFUL) return sc; 35 rtems_current_user_env = malloc(sizeof(rtems_user_env_t)); 36 if (!rtems_current_user_env) 37 return RTEMS_NO_MEMORY; 38 }; 34 39 35 *rtems_current_user_env = rtems_global_user_env; 40 /* the side effect desired . chroot("/") */ 41 *rtems_current_user_env = rtems_global_user_env; /* get the global values*/ 42 rtems_current_user_env->task_id=task_id; /* mark the local values*/ 43 36 44 return RTEMS_SUCCESSFUL; 37 45 } 46 47 /* 48 * Share a same private environment beetween two task: 49 * Task_id (remote) and RTEMS_SELF(current). 50 */ 51 52 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) { 53 rtems_status_code sc; 54 rtems_user_env_t * shared_user_env; 55 rtems_id current_task_id; 56 57 sc=rtems_task_ident(RTEMS_SELF,0,¤t_task_id); 58 if (sc != RTEMS_SUCCESSFUL) return sc; 59 60 if (rtems_current_user_env->task_id==current_task_id) { 61 /* kill the current user env & task_var*/ 62 free(rtems_current_user_env); 63 sc = rtems_task_variable_delete(RTEMS_SELF,(void*)&rtems_current_user_env); 64 if (sc != RTEMS_SUCCESSFUL) return sc; 65 }; 66 67 sc = rtems_task_variable_get(task_id,(void*)&rtems_current_user_env, 68 (void*)&shared_user_env ); 69 if (sc != RTEMS_SUCCESSFUL) return sc; 70 71 /* don't free(NULL'ed) at the task_delete. It is a shared var... */ 72 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,NULL); 73 if (sc != RTEMS_SUCCESSFUL) return sc; 74 75 /* the current_user_env is the same pointer that remote env */ 76 rtems_current_user_env = shared_user_env; 77 78 return RTEMS_SUCCESSFUL; 79 } -
cpukit/include/rtems/libio_.h
rdd74e612 rd8a9155 210 210 */ 211 211 typedef struct { 212 rtems_id task_id; 212 213 rtems_filesystem_location_info_t current_directory; 213 214 rtems_filesystem_location_info_t root_directory; … … 230 231 231 232 rtems_status_code rtems_libio_set_private_env(void); 233 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; 234 232 235 233 236 -
cpukit/libcsupport/include/rtems/libio_.h
rdd74e612 rd8a9155 210 210 */ 211 211 typedef struct { 212 rtems_id task_id; 212 213 rtems_filesystem_location_info_t current_directory; 213 214 rtems_filesystem_location_info_t root_directory; … … 230 231 231 232 rtems_status_code rtems_libio_set_private_env(void); 233 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ; 234 232 235 233 236 -
cpukit/libcsupport/src/chroot.c
rdd74e612 rd8a9155 31 31 rtems_filesystem_location_info_t loc; 32 32 33 if (rtems_current_user_env == &rtems_global_user_env) 33 /* an automatic call to new private env the first time */ 34 if (rtems_current_user_env == &rtems_global_user_env) { 35 rtems_libio_set_private_env(); /* try to set a new private env*/ 36 if (rtems_current_user_env == &rtems_global_user_env) /* not ok */ 34 37 set_errno_and_return_minus_one( ENOTSUP ); 38 }; 35 39 36 40 loc = rtems_filesystem_root; /* save the value */ 37 38 /* if has been already changed */39 rtems_filesystem_root = rtems_global_user_env.root_directory;40 41 41 42 result = chdir(pathname); … … 46 47 rtems_filesystem_root = rtems_filesystem_current; 47 48 48 result = chdir("/");49 if (result) {50 rtems_filesystem_root = loc; /* restore the value */51 set_errno_and_return_minus_one( errno );52 };53 54 /*XXX : Call this? Sorry but I don't known if it is necesary */55 /* The old root.56 rtems_filesystem_freenode( &loc );57 */58 49 return 0; 59 50 } -
cpukit/libcsupport/src/privateenv.c
rdd74e612 rd8a9155 24 24 rtems_status_code rtems_libio_set_private_env(void) { 25 25 rtems_status_code sc; 26 rtems_id task_id; 26 27 27 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free); 28 if (sc != RTEMS_SUCCESSFUL) 29 return sc; 28 sc=rtems_task_ident(RTEMS_SELF,0,&task_id); 29 if (sc != RTEMS_SUCCESSFUL) return sc; 30 30 31 rtems_current_user_env = malloc(sizeof(rtems_user_env_t)); 32 if (!rtems_current_user_env) 33 return RTEMS_NO_MEMORY; 31 /* Only for the first time a malloc is necesary */ 32 if (rtems_current_user_env==&rtems_global_user_env) { 33 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free); 34 if (sc != RTEMS_SUCCESSFUL) return sc; 35 rtems_current_user_env = malloc(sizeof(rtems_user_env_t)); 36 if (!rtems_current_user_env) 37 return RTEMS_NO_MEMORY; 38 }; 34 39 35 *rtems_current_user_env = rtems_global_user_env; 40 /* the side effect desired . chroot("/") */ 41 *rtems_current_user_env = rtems_global_user_env; /* get the global values*/ 42 rtems_current_user_env->task_id=task_id; /* mark the local values*/ 43 36 44 return RTEMS_SUCCESSFUL; 37 45 } 46 47 /* 48 * Share a same private environment beetween two task: 49 * Task_id (remote) and RTEMS_SELF(current). 50 */ 51 52 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) { 53 rtems_status_code sc; 54 rtems_user_env_t * shared_user_env; 55 rtems_id current_task_id; 56 57 sc=rtems_task_ident(RTEMS_SELF,0,¤t_task_id); 58 if (sc != RTEMS_SUCCESSFUL) return sc; 59 60 if (rtems_current_user_env->task_id==current_task_id) { 61 /* kill the current user env & task_var*/ 62 free(rtems_current_user_env); 63 sc = rtems_task_variable_delete(RTEMS_SELF,(void*)&rtems_current_user_env); 64 if (sc != RTEMS_SUCCESSFUL) return sc; 65 }; 66 67 sc = rtems_task_variable_get(task_id,(void*)&rtems_current_user_env, 68 (void*)&shared_user_env ); 69 if (sc != RTEMS_SUCCESSFUL) return sc; 70 71 /* don't free(NULL'ed) at the task_delete. It is a shared var... */ 72 sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,NULL); 73 if (sc != RTEMS_SUCCESSFUL) return sc; 74 75 /* the current_user_env is the same pointer that remote env */ 76 rtems_current_user_env = shared_user_env; 77 78 return RTEMS_SUCCESSFUL; 79 }
Note: See TracChangeset
for help on using the changeset viewer.