Changeset 7c7a3209 in mainline for uspace/lib/libc/generic/loader.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/lib/libc/generic/loader.c

    re035612 r7c7a3209  
    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 */
     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        ipcarg_t retval;
     134        async_wait_for(req, &retval);
     135        return (int) retval;
     136}
     137
    103138/** Set pathname of the program to load.
    104139 *
Note: See TracChangeset for help on using the changeset viewer.