Changeset 20f1597 in mainline for kernel/arch/ia32/src/boot/cboot.c


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/boot/cboot.c

    r16da5f8e r20f1597  
    4040#include <memstr.h>
    4141#include <string.h>
     42#include <macros.h>
    4243
    4344/* This is a symbol so the type is only dummy. Obtain the value using &. */
    4445extern 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 */
     53static 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}
    4581
    4682/** C part of ia32 boot sequence.
     
    73109                        /* Copy command line, if available. */
    74110                        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);
    79114                        } else {
    80115                                init.tasks[i].name[0] = '\0';
Note: See TracChangeset for help on using the changeset viewer.