Rev 4241 | Rev 4268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4241 | Rev 4256 | ||
---|---|---|---|
Line 52... | Line 52... | ||
52 | * de-allocated using free() after use). |
52 | * de-allocated using free() after use). |
53 | */ |
53 | */ |
54 | int loader_spawn(const char *name) |
54 | int loader_spawn(const char *name) |
55 | { |
55 | { |
56 | return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER, |
56 | return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER, |
57 | (sysarg_t) name, strlen(name)); |
57 | (sysarg_t) name, str_size(name)); |
58 | } |
58 | } |
59 | 59 | ||
60 | loader_t *loader_connect(void) |
60 | loader_t *loader_connect(void) |
61 | { |
61 | { |
62 | loader_t *ldr; |
62 | loader_t *ldr; |
Line 166... | Line 166... | ||
166 | * compute size of the buffer needed. |
166 | * compute size of the buffer needed. |
167 | */ |
167 | */ |
168 | ap = argv; |
168 | ap = argv; |
169 | buffer_size = 0; |
169 | buffer_size = 0; |
170 | while (*ap != NULL) { |
170 | while (*ap != NULL) { |
171 | buffer_size += strlen(*ap) + 1; |
171 | buffer_size += str_size(*ap) + 1; |
172 | ++ap; |
172 | ++ap; |
173 | } |
173 | } |
174 | 174 | ||
175 | arg_buf = malloc(buffer_size); |
175 | arg_buf = malloc(buffer_size); |
176 | if (arg_buf == NULL) return ENOMEM; |
176 | if (arg_buf == NULL) return ENOMEM; |
177 | 177 | ||
178 | /* Now fill the buffer with null-terminated argument strings */ |
178 | /* Now fill the buffer with null-terminated argument strings */ |
179 | ap = argv; |
179 | ap = argv; |
180 | dp = arg_buf; |
180 | dp = arg_buf; |
- | 181 | ||
181 | while (*ap != NULL) { |
182 | while (*ap != NULL) { |
182 | strcpy(dp, *ap); |
183 | str_ncpy(dp, *ap, buffer_size - (dp - arg_buf)); |
183 | dp += strlen(*ap) + 1; |
184 | dp += str_size(*ap) + 1; |
184 | 185 | ||
185 | ++ap; |
186 | ++ap; |
186 | } |
187 | } |
187 | 188 | ||
188 | /* Send serialized arguments to the loader */ |
189 | /* Send serialized arguments to the loader */ |