MCPcopy Create free account
hub / github.com/HelenOS/helenos / sys_program_spawn_loader

Function sys_program_spawn_loader

kernel/generic/src/proc/program.c:220–244  ·  view source on GitHub ↗

Syscall for creating a new loader instance from userspace. * * Creates a new task from the program loader image and sets * the task name. * * @param uspace_name Name to set on the new task (typically the same * as the command used to execute it). * @param name_len Length of the name. * * @return EOK on success or an error code from @ref errno.h. * */

Source from the content-addressed store, hash-verified

218 *
219 */
220sys_errno_t sys_program_spawn_loader(uspace_ptr_char uspace_name, size_t name_len)
221{
222 /* Cap length of name and copy it from userspace. */
223 if (name_len > TASK_NAME_BUFLEN - 1)
224 name_len = TASK_NAME_BUFLEN - 1;
225
226 char namebuf[TASK_NAME_BUFLEN];
227 errno_t rc = copy_from_uspace(namebuf, uspace_name, name_len);
228 if (rc != EOK)
229 return (sys_errno_t) rc;
230
231 namebuf[name_len] = 0;
232
233 /* Spawn the new task. */
234 program_t prg;
235 rc = program_create_loader(&prg, namebuf);
236 if (rc != EOK)
237 return rc;
238
239 // FIXME: control the permissions
240 perm_set(prg.task, perm_get(TASK));
241 program_ready(&prg);
242
243 return EOK;
244}
245
246/** @}
247 */

Callers

nothing calls this directly

Calls 5

copy_from_uspaceFunction · 0.85
program_create_loaderFunction · 0.85
perm_setFunction · 0.85
perm_getFunction · 0.85
program_readyFunction · 0.85

Tested by

no test coverage detected