Changes in / [e035612:7c7a3209] in mainline
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/scli.c
re035612 r7c7a3209 61 61 usr->line = (char *) NULL; 62 62 usr->name = "root"; 63 usr->home = "/";64 63 usr->cwd = (char *) NULL; 65 64 usr->prompt = (char *) NULL; 66 chdir(usr->home);67 65 usr->lasterr = 0; 68 66 return (int) cli_set_prompt(usr); -
uspace/app/bdsh/scli.h
re035612 r7c7a3209 7 7 typedef struct { 8 8 char *name; 9 char *home;10 9 char *line; 11 10 char *cwd; -
uspace/lib/libc/generic/libc.c
re035612 r7c7a3209 80 80 __stdio_init(0, NULL); 81 81 } else { 82 (void) chdir(__pcb->cwd); 82 83 argc = __pcb->argc; 83 84 argv = __pcb->argv; -
uspace/lib/libc/generic/loader.c
re035612 r7c7a3209 101 101 } 102 102 103 /** Set current working directory for the loaded task. 104 * 105 * Sets the current working directory for the loaded task. 106 * 107 * @param ldr Loader connection structure. 108 * 109 * @return Zero on success or negative error code. 110 * 111 */ 112 int loader_set_cwd(loader_t *ldr) 113 { 114 char *cwd; 115 size_t len; 116 117 cwd = (char *) malloc(MAX_PATH_LEN + 1); 118 if (!cwd) 119 return ENOMEM; 120 if (!getcwd(cwd, MAX_PATH_LEN + 1)) 121 str_cpy(cwd, MAX_PATH_LEN + 1, "/"); 122 len = str_length(cwd); 123 124 ipc_call_t answer; 125 aid_t req = async_send_0(ldr->phone_id, LOADER_SET_CWD, &answer); 126 int rc = async_data_write_start(ldr->phone_id, cwd, len); 127 free(cwd); 128 if (rc != EOK) { 129 async_wait_for(req, NULL); 130 return rc; 131 } 132 133 ipcarg_t retval; 134 async_wait_for(req, &retval); 135 return (int) retval; 136 } 137 103 138 /** Set pathname of the program to load. 104 139 * -
uspace/lib/libc/generic/task.c
re035612 r7c7a3209 89 89 goto error; 90 90 91 /* Send spawner's current working directory. */ 92 rc = loader_set_cwd(ldr); 93 if (rc != EOK) 94 goto error; 95 91 96 /* Send program pathname. */ 92 97 rc = loader_set_pathname(ldr, path); … … 98 103 if (rc != EOK) 99 104 goto error; 100 101 105 102 106 /* Send default files */ -
uspace/lib/libc/generic/vfs/vfs.c
re035612 r7c7a3209 664 664 char *getcwd(char *buf, size_t size) 665 665 { 666 if (!cwd_size) 667 return NULL; 666 668 if (!size) 667 669 return NULL; -
uspace/lib/libc/include/ipc/loader.h
re035612 r7c7a3209 41 41 LOADER_HELLO = IPC_FIRST_USER_METHOD, 42 42 LOADER_GET_TASKID, 43 LOADER_SET_CWD, 43 44 LOADER_SET_PATHNAME, 44 45 LOADER_SET_ARGS, -
uspace/lib/libc/include/loader/loader.h
re035612 r7c7a3209 49 49 extern loader_t *loader_connect(void); 50 50 extern int loader_get_task_id(loader_t *, task_id_t *); 51 extern int loader_set_cwd(loader_t *); 51 52 extern int loader_set_pathname(loader_t *, const char *); 52 53 extern int loader_set_args(loader_t *, char *const[]); -
uspace/lib/libc/include/loader/pcb.h
re035612 r7c7a3209 52 52 /** Program entry point. */ 53 53 entry_point_t entry; 54 55 /** Current working directory. */ 56 char *cwd; 54 57 55 58 /** Number of command-line arguments. */ -
uspace/srv/loader/main.c
re035612 r7c7a3209 72 72 static pcb_t pcb; 73 73 74 /** Current working directory */ 75 static char *cwd = NULL; 76 74 77 /** Number of arguments */ 75 78 static int argc = 0; … … 115 118 } 116 119 120 /** Receive a call setting the current working directory. 121 * 122 * @param rid 123 * @param request 124 */ 125 static void ldr_set_cwd(ipc_callid_t rid, ipc_call_t *request) 126 { 127 ipc_callid_t callid; 128 size_t len; 129 130 if (!async_data_write_receive(&callid, &len)) { 131 ipc_answer_0(callid, EINVAL); 132 ipc_answer_0(rid, EINVAL); 133 return; 134 } 135 136 cwd = malloc(len + 1); 137 if (!cwd) { 138 ipc_answer_0(callid, ENOMEM); 139 ipc_answer_0(rid, ENOMEM); 140 return; 141 } 142 143 async_data_write_finalize(callid, cwd, len); 144 cwd[len] = '\0'; 145 146 ipc_answer_0(rid, EOK); 147 } 117 148 118 149 /** Receive a call setting pathname of the program to execute. … … 313 344 elf_create_pcb(&prog_info, &pcb); 314 345 346 pcb.cwd = cwd; 347 315 348 pcb.argc = argc; 316 349 pcb.argv = argv; … … 406 439 case LOADER_GET_TASKID: 407 440 ldr_get_taskid(callid, &call); 441 continue; 442 case LOADER_SET_CWD: 443 ldr_set_cwd(callid, &call); 408 444 continue; 409 445 case LOADER_SET_PATHNAME:
Note:
See TracChangeset
for help on using the changeset viewer.