Changeset 7c7a3209 in mainline for uspace/srv/loader/main.c


Ignore:
Timestamp:
2009-10-15T18:11:05Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7591b27d
Parents:
e035612 (diff), d8ef374 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge support for passing the current working directory to the spawned task.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/main.c

    re035612 r7c7a3209  
    7272static pcb_t pcb;
    7373
     74/** Current working directory */
     75static char *cwd = NULL;
     76
    7477/** Number of arguments */
    7578static int argc = 0;
     
    115118}
    116119
     120/** Receive a call setting the current working directory.
     121 *
     122 * @param rid
     123 * @param request
     124 */
     125static 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}
    117148
    118149/** Receive a call setting pathname of the program to execute.
     
    313344        elf_create_pcb(&prog_info, &pcb);
    314345       
     346        pcb.cwd = cwd;
     347       
    315348        pcb.argc = argc;
    316349        pcb.argv = argv;
     
    406439                case LOADER_GET_TASKID:
    407440                        ldr_get_taskid(callid, &call);
     441                        continue;
     442                case LOADER_SET_CWD:
     443                        ldr_set_cwd(callid, &call);
    408444                        continue;
    409445                case LOADER_SET_PATHNAME:
Note: See TracChangeset for help on using the changeset viewer.