Changes in / [7c7a3209:e035612] in mainline


Ignore:
Location:
uspace
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/scli.c

    r7c7a3209 re035612  
    6161        usr->line = (char *) NULL;
    6262        usr->name = "root";
     63        usr->home = "/";
    6364        usr->cwd = (char *) NULL;
    6465        usr->prompt = (char *) NULL;
     66        chdir(usr->home);
    6567        usr->lasterr = 0;
    6668        return (int) cli_set_prompt(usr);
  • uspace/app/bdsh/scli.h

    r7c7a3209 re035612  
    77typedef struct {
    88        char *name;
     9        char *home;
    910        char *line;
    1011        char *cwd;
  • uspace/lib/libc/generic/libc.c

    r7c7a3209 re035612  
    8080                __stdio_init(0, NULL);
    8181        } else {
    82                 (void) chdir(__pcb->cwd);
    8382                argc = __pcb->argc;
    8483                argv = __pcb->argv;
  • uspace/lib/libc/generic/loader.c

    r7c7a3209 re035612  
    101101}
    102102
    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 
    138103/** Set pathname of the program to load.
    139104 *
  • uspace/lib/libc/generic/task.c

    r7c7a3209 re035612  
    8989                goto error;
    9090       
    91         /* Send spawner's current working directory. */
    92         rc = loader_set_cwd(ldr);
    93         if (rc != EOK)
    94                 goto error;
    95        
    9691        /* Send program pathname. */
    9792        rc = loader_set_pathname(ldr, path);
     
    10398        if (rc != EOK)
    10499                goto error;
     100       
    105101       
    106102        /* Send default files */
  • uspace/lib/libc/generic/vfs/vfs.c

    r7c7a3209 re035612  
    664664char *getcwd(char *buf, size_t size)
    665665{
    666         if (!cwd_size)
    667                 return NULL;
    668666        if (!size)
    669667                return NULL;
  • uspace/lib/libc/include/ipc/loader.h

    r7c7a3209 re035612  
    4141        LOADER_HELLO = IPC_FIRST_USER_METHOD,
    4242        LOADER_GET_TASKID,
    43         LOADER_SET_CWD,
    4443        LOADER_SET_PATHNAME,
    4544        LOADER_SET_ARGS,
  • uspace/lib/libc/include/loader/loader.h

    r7c7a3209 re035612  
    4949extern loader_t *loader_connect(void);
    5050extern int loader_get_task_id(loader_t *, task_id_t *);
    51 extern int loader_set_cwd(loader_t *);
    5251extern int loader_set_pathname(loader_t *, const char *);
    5352extern int loader_set_args(loader_t *, char *const[]);
  • uspace/lib/libc/include/loader/pcb.h

    r7c7a3209 re035612  
    5252        /** Program entry point. */
    5353        entry_point_t entry;
    54 
    55         /** Current working directory. */
    56         char *cwd;
    5754       
    5855        /** Number of command-line arguments. */
  • uspace/srv/loader/main.c

    r7c7a3209 re035612  
    7272static pcb_t pcb;
    7373
    74 /** Current working directory */
    75 static char *cwd = NULL;
    76 
    7774/** Number of arguments */
    7875static int argc = 0;
     
    118115}
    119116
    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 }
    148117
    149118/** Receive a call setting pathname of the program to execute.
     
    344313        elf_create_pcb(&prog_info, &pcb);
    345314       
    346         pcb.cwd = cwd;
    347        
    348315        pcb.argc = argc;
    349316        pcb.argv = argv;
     
    439406                case LOADER_GET_TASKID:
    440407                        ldr_get_taskid(callid, &call);
    441                         continue;
    442                 case LOADER_SET_CWD:
    443                         ldr_set_cwd(callid, &call);
    444408                        continue;
    445409                case LOADER_SET_PATHNAME:
Note: See TracChangeset for help on using the changeset viewer.