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. * */
| 218 | * |
| 219 | */ |
| 220 | sys_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 | */ |
nothing calls this directly
no test coverage detected