Subversion Repositories HelenOS

Rev

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

Rev 4263 Rev 4327
Line 148... Line 148...
148
 * @param request
148
 * @param request
149
 */
149
 */
150
static void loader_set_args(ipc_callid_t rid, ipc_call_t *request)
150
static void loader_set_args(ipc_callid_t rid, ipc_call_t *request)
151
{
151
{
152
    ipc_callid_t callid;
152
    ipc_callid_t callid;
153
    size_t buf_len, arg_len;
153
    size_t buf_size, arg_size;
154
    char *p;
154
    char *p;
155
    int n;
155
    int n;
156
   
156
   
157
    if (!ipc_data_write_receive(&callid, &buf_len)) {
157
    if (!ipc_data_write_receive(&callid, &buf_size)) {
158
        ipc_answer_0(callid, EINVAL);
158
        ipc_answer_0(callid, EINVAL);
159
        ipc_answer_0(rid, EINVAL);
159
        ipc_answer_0(rid, EINVAL);
160
        return;
160
        return;
161
    }
161
    }
162
   
162
   
Line 168... Line 168...
168
    if (argv != NULL) {
168
    if (argv != NULL) {
169
        free(argv);
169
        free(argv);
170
        argv = NULL;
170
        argv = NULL;
171
    }
171
    }
172
   
172
   
173
    arg_buf = malloc(buf_len + 1);
173
    arg_buf = malloc(buf_size + 1);
174
    if (!arg_buf) {
174
    if (!arg_buf) {
175
        ipc_answer_0(callid, ENOMEM);
175
        ipc_answer_0(callid, ENOMEM);
176
        ipc_answer_0(rid, ENOMEM);
176
        ipc_answer_0(rid, ENOMEM);
177
        return;
177
        return;
178
    }
178
    }
179
   
179
   
180
    ipc_data_write_finalize(callid, arg_buf, buf_len);
180
    ipc_data_write_finalize(callid, arg_buf, buf_size);
181
   
181
   
182
    arg_buf[buf_len] = '\0';
182
    arg_buf[buf_size] = '\0';
183
   
183
   
184
    /*
184
    /*
185
     * Count number of arguments
185
     * Count number of arguments
186
     */
186
     */
187
    p = arg_buf;
187
    p = arg_buf;
188
    n = 0;
188
    n = 0;
189
    while (p < arg_buf + buf_len) {
189
    while (p < arg_buf + buf_size) {
190
        arg_len = strlen(p);
190
        arg_size = str_size(p);
191
        p = p + arg_len + 1;
191
        p = p + arg_size + 1;
192
        ++n;
192
        ++n;
193
    }
193
    }
194
   
194
   
195
    /* Allocate argv */
195
    /* Allocate argv */
196
    argv = malloc((n + 1) * sizeof(char *));
196
    argv = malloc((n + 1) * sizeof(char *));
Line 204... Line 204...
204
    /*
204
    /*
205
     * Fill argv with argument pointers
205
     * Fill argv with argument pointers
206
     */
206
     */
207
    p = arg_buf;
207
    p = arg_buf;
208
    n = 0;
208
    n = 0;
209
    while (p < arg_buf + buf_len) {
209
    while (p < arg_buf + buf_size) {
210
        argv[n] = p;
210
        argv[n] = p;
211
       
211
       
212
        arg_len = strlen(p);
212
        arg_size = str_size(p);
213
        p = p + arg_len + 1;
213
        p = p + arg_size + 1;
214
        ++n;
214
        ++n;
215
    }
215
    }
216
   
216
   
217
    argc = n;
217
    argc = n;
218
    argv[n] = NULL;
218
    argv[n] = NULL;
Line 273... Line 273...
273
static void loader_run(ipc_callid_t rid, ipc_call_t *request)
273
static void loader_run(ipc_callid_t rid, ipc_call_t *request)
274
{
274
{
275
    const char *cp;
275
    const char *cp;
276
   
276
   
277
    /* Set the task name. */
277
    /* Set the task name. */
278
    cp = strrchr(pathname, '/');
278
    cp = str_rchr(pathname, '/');
279
    cp = (cp == NULL) ? pathname : (cp + 1);
279
    cp = (cp == NULL) ? pathname : (cp + 1);
280
    task_set_name(cp);
280
    task_set_name(cp);
281
   
281
   
282
    if (is_dyn_linked == true) {
282
    if (is_dyn_linked == true) {
283
        /* Dynamically linked program */
283
        /* Dynamically linked program */