Changeset 04803bf in mainline for uspace/lib/c/generic/loader.c


Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (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 mainline changes (needs fixes).

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/loader.c

    rb50b5af2 r04803bf  
    3333 */
    3434
    35 #include <ipc/ipc.h>
    3635#include <ipc/loader.h>
    3736#include <ipc/services.h>
     37#include <ipc/ns.h>
    3838#include <libc.h>
    3939#include <task.h>
    40 #include <string.h>
     40#include <str.h>
    4141#include <stdlib.h>
    4242#include <async.h>
     
    6363loader_t *loader_connect(void)
    6464{
    65         int phone_id = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0);
     65        int phone_id = service_connect_blocking(SERVICE_LOAD, 0, 0);
    6666        if (phone_id < 0)
    6767                return NULL;
     
    9090        ipc_call_t answer;
    9191        aid_t req = async_send_0(ldr->phone_id, LOADER_GET_TASKID, &answer);
    92         int rc = ipc_data_read_start(ldr->phone_id, task_id, sizeof(task_id_t));
    93         if (rc != EOK) {
    94                 async_wait_for(req, NULL);
    95                 return rc;
    96         }
    97        
    98         ipcarg_t retval;
     92        int rc = async_data_read_start(ldr->phone_id, task_id, sizeof(task_id_t));
     93        if (rc != EOK) {
     94                async_wait_for(req, NULL);
     95                return rc;
     96        }
     97       
     98        sysarg_t retval;
     99        async_wait_for(req, &retval);
     100        return (int) retval;
     101}
     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 */
     112int 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        sysarg_t retval;
    99134        async_wait_for(req, &retval);
    100135        return (int) retval;
     
    123158        ipc_call_t answer;
    124159        aid_t req = async_send_0(ldr->phone_id, LOADER_SET_PATHNAME, &answer);
    125         int rc = ipc_data_write_start(ldr->phone_id, (void *) pa, pa_len);
    126         if (rc != EOK) {
     160        int rc = async_data_write_start(ldr->phone_id, (void *) pa, pa_len);
     161        if (rc != EOK) {
     162                free(pa);
    127163                async_wait_for(req, NULL);
    128164                return rc;
     
    131167        free(pa);
    132168       
    133         ipcarg_t retval;
     169        sysarg_t retval;
    134170        async_wait_for(req, &retval);
    135171        return (int) retval;
     
    148184 *
    149185 */
    150 int loader_set_args(loader_t *ldr, char *const argv[])
     186int loader_set_args(loader_t *ldr, const char *const argv[])
    151187{
    152188        /*
     
    154190         * compute size of the buffer needed.
    155191         */
    156         char *const *ap = argv;
     192        const char *const *ap = argv;
    157193        size_t buffer_size = 0;
    158194        while (*ap != NULL) {
     
    178214        ipc_call_t answer;
    179215        aid_t req = async_send_0(ldr->phone_id, LOADER_SET_ARGS, &answer);
    180         ipcarg_t rc = ipc_data_write_start(ldr->phone_id, (void *) arg_buf, buffer_size);
     216        sysarg_t rc = async_data_write_start(ldr->phone_id, (void *) arg_buf, buffer_size);
    181217        if (rc != EOK) {
    182218                async_wait_for(req, NULL);
     
    232268        ipc_call_t answer;
    233269        aid_t req = async_send_0(ldr->phone_id, LOADER_SET_FILES, &answer);
    234         ipcarg_t rc = ipc_data_write_start(ldr->phone_id, (void *) files_buf,
     270        sysarg_t rc = async_data_write_start(ldr->phone_id, (void *) files_buf,
    235271            count * sizeof(fdi_node_t));
    236272        if (rc != EOK) {
     
    284320                return rc;
    285321       
    286         ipc_hangup(ldr->phone_id);
     322        async_hangup(ldr->phone_id);
    287323        ldr->phone_id = 0;
    288324        return EOK;
     
    302338void loader_abort(loader_t *ldr)
    303339{
    304         ipc_hangup(ldr->phone_id);
     340        async_hangup(ldr->phone_id);
    305341        ldr->phone_id = 0;
    306342}
Note: See TracChangeset for help on using the changeset viewer.