Changeset 24345a5 in mainline for kernel/generic/src/proc/program.c
- Timestamp:
- 2008-11-08T10:01:59Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 24d6efc
- Parents:
- 7faabb7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/program.c
r7faabb7 r24345a5 68 68 * @param as Address space containing a binary program image. 69 69 * @param entry_addr Program entry-point address in program address space. 70 * @param name Name to set for the program's task. 70 71 * @param p Buffer for storing program information. 71 72 */ 72 void program_create(as_t *as, uintptr_t entry_addr, program_t *p)73 void program_create(as_t *as, uintptr_t entry_addr, char *name, program_t *p) 73 74 { 74 75 as_area_t *a; … … 82 83 kernel_uarg->uspace_uarg = NULL; 83 84 84 p->task = task_create(as, "app");85 p->task = task_create(as, name); 85 86 ASSERT(p->task); 86 87 … … 107 108 * 108 109 * @param image_addr Address of an executable program image. 110 * @param name Name to set for the program's task. 109 111 * @param p Buffer for storing program info. If image_addr 110 112 * points to a loader image, p->task will be set to … … 113 115 * @return EOK on success or negative error code. 114 116 */ 115 int program_create_from_image(void *image_addr, program_t *p)117 int program_create_from_image(void *image_addr, char *name, program_t *p) 116 118 { 117 119 as_t *as; … … 137 139 } 138 140 139 program_create(as, ((elf_header_t *) image_addr)->e_entry, p);141 program_create(as, ((elf_header_t *) image_addr)->e_entry, name, p); 140 142 141 143 return EOK; … … 144 146 /** Create a task from the program loader image. 145 147 * 146 * @param p Buffer for storing program info. 148 * @param p Buffer for storing program info. 149 * @param name Name to set for the program's task. 150 * 147 151 * @return EOK on success or negative error code. 148 152 */ 149 int program_create_loader(program_t *p )153 int program_create_loader(program_t *p, char *name) 150 154 { 151 155 as_t *as; … … 168 172 } 169 173 170 program_create(as, ((elf_header_t *) program_loader)->e_entry, p); 174 program_create(as, ((elf_header_t *) program_loader)->e_entry, 175 name, p); 171 176 172 177 return EOK; … … 189 194 * to it and stores the phone id into the provided buffer. 190 195 * 191 * @param uspace_phone_id Userspace address where to store the phone id. 196 * @param uspace_phone_id Userspace address where to store the phone id. 197 * @param name Name to set on the new task (typically the same 198 * as the command used to execute it). 192 199 * 193 200 * @return 0 on success or an error code from @ref errno.h. 194 201 */ 195 unative_t sys_program_spawn_loader(int *uspace_phone_id) 202 unative_t sys_program_spawn_loader(int *uspace_phone_id, char *uspace_name, 203 size_t name_len) 196 204 { 197 205 program_t p; … … 199 207 int rc; 200 208 int phone_id; 209 char namebuf[TASK_NAME_BUFLEN]; 201 210 202 211 fake_id = 0; … … 208 217 return rc; 209 218 219 /* Cap length of name and copy it from userspace. */ 220 221 if (name_len > THREAD_NAME_BUFLEN - 1) 222 name_len = THREAD_NAME_BUFLEN - 1; 223 224 rc = copy_from_uspace(namebuf, uspace_name, name_len); 225 if (rc != 0) 226 return (unative_t) rc; 227 228 namebuf[name_len] = '\0'; 229 230 /* Allocate the phone for communicating with the new task. */ 231 210 232 phone_id = phone_alloc(); 211 233 if (phone_id < 0) 212 234 return ELIMIT; 213 235 214 rc = program_create_loader(&p); 236 /* Spawn the new task. */ 237 238 rc = program_create_loader(&p, namebuf); 215 239 if (rc != 0) 216 240 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.