Subversion Repositories HelenOS

Rev

Rev 3216 | Rev 3474 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3216 Rev 3403
Line 39... Line 39...
39
#include <libc.h>
39
#include <libc.h>
40
#include <string.h>
40
#include <string.h>
41
#include <stdlib.h>
41
#include <stdlib.h>
42
#include <async.h>
42
#include <async.h>
43
#include <errno.h>
43
#include <errno.h>
-
 
44
#include <vfs/vfs.h>
44
 
45
 
45
task_id_t task_get_id(void)
46
task_id_t task_get_id(void)
46
{
47
{
47
    task_id_t task_id;
48
    task_id_t task_id;
48
 
49
 
Line 128... Line 129...
128
    ipc_call_t answer;
129
    ipc_call_t answer;
129
    aid_t req;
130
    aid_t req;
130
    int rc;
131
    int rc;
131
    ipcarg_t retval;
132
    ipcarg_t retval;
132
 
133
 
-
 
134
    char *pa;
-
 
135
    size_t pa_len;
-
 
136
 
-
 
137
    pa = absolutize(path, &pa_len);
-
 
138
    if (!pa)
-
 
139
        return 0;
-
 
140
 
133
    /* Spawn a program loader */   
141
    /* Spawn a program loader */   
134
    phone_id = task_spawn_loader();
142
    phone_id = task_spawn_loader();
135
    if (phone_id < 0) return 0;
143
    if (phone_id < 0)
-
 
144
        return 0;
136
 
145
 
137
    /*
146
    /*
138
     * Say hello so that the loader knows the incoming connection's
147
     * Say hello so that the loader knows the incoming connection's
139
     * phone hash.
148
     * phone hash.
140
     */
149
     */
141
    rc = async_req_0_0(phone_id, LOADER_HELLO);
150
    rc = async_req_0_0(phone_id, LOADER_HELLO);
142
    if (rc != EOK) return 0;
151
    if (rc != EOK)
-
 
152
        return 0;
143
 
153
 
144
    /* Send program pathname */
154
    /* Send program pathname */
145
    req = async_send_0(phone_id, LOADER_SET_PATHNAME, &answer);
155
    req = async_send_0(phone_id, LOADER_SET_PATHNAME, &answer);
146
    rc = ipc_data_write_start(phone_id, (void *)path, strlen(path));
156
    rc = ipc_data_write_start(phone_id, (void *)pa, pa_len);
147
    if (rc != EOK) {
157
    if (rc != EOK) {
148
        async_wait_for(req, NULL);
158
        async_wait_for(req, NULL);
149
        return 1;
159
        return 1;
150
    }
160
    }
151
 
161
 
152
    async_wait_for(req, &retval);
162
    async_wait_for(req, &retval);
153
    if (retval != EOK) goto error;
163
    if (retval != EOK)
-
 
164
        goto error;
154
 
165
 
155
    /* Send arguments */
166
    /* Send arguments */
156
    rc = loader_set_args(phone_id, argv);
167
    rc = loader_set_args(phone_id, argv);
157
    if (rc != EOK) goto error;
168
    if (rc != EOK)
-
 
169
        goto error;
158
 
170
 
159
    /* Request loader to start the program */  
171
    /* Request loader to start the program */  
160
    rc = async_req_0_0(phone_id, LOADER_RUN);
172
    rc = async_req_0_0(phone_id, LOADER_RUN);
161
    if (rc != EOK) goto error;
173
    if (rc != EOK)
-
 
174
        goto error;
162
 
175
 
163
    /* Success */
176
    /* Success */
164
    ipc_hangup(phone_id);
177
    ipc_hangup(phone_id);
165
    return 1;
178
    return 1;
166
 
179