Changeset 20f1597 in mainline for kernel/generic/src


Ignore:
Timestamp:
2009-03-02T22:13:30Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
561db3f
Parents:
16da5f8e
Message:

Task names should only contain base names of commands. Also add 'boot:' prefix for binaries loaded by the kernel.

Location:
kernel/generic/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/lib/string.c

    r16da5f8e r20f1597  
    162162}
    163163
     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 */
     171extern 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 */
     188extern 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
    164205/** @}
    165206 */
  • kernel/generic/src/main/kinit.c

    r16da5f8e r20f1597  
    6565#include <lib/rd.h>
    6666#include <ipc/ipc.h>
     67#include <debug.h>
     68#include <string.h>
    6769
    6870#ifdef CONFIG_SMP
     
    7880static char alive[ALIVE_CHARS] = "-\\|/";
    7981#endif
     82
     83#define BOOT_PREFIX             "boot:"
     84#define BOOT_PREFIX_LEN         5
    8085
    8186/** Kernel initialization thread.
     
    176181                }
    177182
    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);
    180197               
    181198                int rc = program_create_from_image((void *) init.tasks[i].addr,
    182                     name, &programs[i]);
     199                    namebuf, &programs[i]);
    183200               
    184201                if ((rc == 0) && (programs[i].task != NULL)) {
Note: See TracChangeset for help on using the changeset viewer.