Changeset 20f1597 in mainline
- Timestamp:
- 2009-03-02T22:13:30Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 561db3f
- Parents:
- 16da5f8e
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/boot/cboot.c
r16da5f8e r20f1597 40 40 #include <memstr.h> 41 41 #include <string.h> 42 #include <macros.h> 42 43 43 44 /* This is a symbol so the type is only dummy. Obtain the value using &. */ 44 45 extern int _hardcoded_unmapped_size; 46 47 /** Extract command name from the multiboot module command line. 48 * 49 * @param buf Destination buffer (will always null-terminate). 50 * @param n Size of destination buffer. 51 * @param cmd_line Input string (the command line). 52 */ 53 static void extract_command(char *buf, size_t n, const char *cmd_line) 54 { 55 const char *start, *end, *cp; 56 size_t max_len; 57 58 /* Find the first space. */ 59 end = strchr(cmd_line, ' '); 60 if (end == NULL) end = cmd_line + strlen(cmd_line); 61 62 /* 63 * Find last occurence of '/' before 'end'. If found, place start at 64 * next character. Otherwise, place start at beginning of buffer. 65 */ 66 cp = end; 67 start = buf; 68 while (cp != start) { 69 if (*cp == '/') { 70 start = cp + 1; 71 break; 72 } 73 --cp; 74 } 75 76 /* Copy the command and null-terminate the string. */ 77 max_len = min(n - 1, (size_t) (end - start)); 78 strncpy(buf, start, max_len + 1); 79 buf[max_len] = '\0'; 80 } 45 81 46 82 /** C part of ia32 boot sequence. … … 73 109 /* Copy command line, if available. */ 74 110 if (mods[i].string) { 75 strncpy(init.tasks[i].name, mods[i].string, 76 CONFIG_TASK_NAME_BUFLEN - 1); 77 init.tasks[i].name[CONFIG_TASK_NAME_BUFLEN - 1] 78 = '\0'; 111 extract_command(init.tasks[i].name, 112 CONFIG_TASK_NAME_BUFLEN, 113 mods[i].string); 79 114 } else { 80 115 init.tasks[i].name[0] = '\0'; -
kernel/generic/include/string.h
r16da5f8e r20f1597 44 44 extern char *strcpy(char *dest, const char *src); 45 45 46 extern char *strchr(const char *s, int i); 47 extern char *strrchr(const char *s, int i); 48 46 49 #endif 47 50 -
kernel/generic/src/lib/string.c
r16da5f8e r20f1597 162 162 } 163 163 164 /** Find first occurence of character in string. 165 * 166 * @param s String to search. 167 * @param i Character to look for. 168 * 169 * @return Pointer to character in @a s or NULL if not found. 170 */ 171 extern char *strchr(const char *s, int i) 172 { 173 while (*s != '\0') { 174 if (*s == i) return (char *) s; 175 ++s; 176 } 177 178 return NULL; 179 } 180 181 /** Find last occurence of character in string. 182 * 183 * @param s String to search. 184 * @param i Character to look for. 185 * 186 * @return Pointer to character in @a s or NULL if not found. 187 */ 188 extern char *strrchr(const char *s, int i) 189 { 190 const char *start; 191 192 start = s; 193 if (*s == '\0') return NULL; 194 195 while (*s != '\0') ++s; 196 197 while (s != start) { 198 --s; 199 if (*s == i) return (char *) s; 200 } 201 202 return NULL; 203 } 204 164 205 /** @} 165 206 */ -
kernel/generic/src/main/kinit.c
r16da5f8e r20f1597 65 65 #include <lib/rd.h> 66 66 #include <ipc/ipc.h> 67 #include <debug.h> 68 #include <string.h> 67 69 68 70 #ifdef CONFIG_SMP … … 78 80 static char alive[ALIVE_CHARS] = "-\\|/"; 79 81 #endif 82 83 #define BOOT_PREFIX "boot:" 84 #define BOOT_PREFIX_LEN 5 80 85 81 86 /** Kernel initialization thread. … … 176 181 } 177 182 178 char *name = init.tasks[i].name; 179 if (name[0] == '\0') name = "init-bin"; 183 /* 184 * Construct task name from the 'boot:' prefix and the 185 * name stored in the init structure (if any). 186 */ 187 188 char namebuf[TASK_NAME_BUFLEN], *name; 189 190 name = init.tasks[i].name; 191 if (name[0] == '\0') name = "<unknown>"; 192 193 ASSERT(TASK_NAME_BUFLEN >= BOOT_PREFIX_LEN); 194 strncpy(namebuf, BOOT_PREFIX, TASK_NAME_BUFLEN); 195 strncpy(namebuf + BOOT_PREFIX_LEN, name, 196 TASK_NAME_BUFLEN - BOOT_PREFIX_LEN); 180 197 181 198 int rc = program_create_from_image((void *) init.tasks[i].addr, 182 name , &programs[i]);199 namebuf, &programs[i]); 183 200 184 201 if ((rc == 0) && (programs[i].task != NULL)) { -
uspace/srv/loader/main.c
r16da5f8e r20f1597 271 271 static void loader_run(ipc_callid_t rid, ipc_call_t *request) 272 272 { 273 const char *cp; 274 273 275 /* Set the task name. */ 274 task_set_name(pathname); 276 cp = strrchr(pathname, '/'); 277 cp = (cp == NULL) ? pathname : (cp + 1); 278 task_set_name(cp); 275 279 276 280 if (is_dyn_linked == true) {
Note:
See TracChangeset
for help on using the changeset viewer.