Changeset bc18d63 in mainline


Ignore:
Timestamp:
2009-03-01T15:00:24Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4b241f3
Parents:
4c7257b
Message:

task_set_name() syscall so that we can have names (for userspace-loaded) tasks again.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/proc/task.h

    r4c7257b rbc18d63  
    145145
    146146extern unative_t sys_task_get_id(task_id_t *uspace_task_id);
     147extern unative_t sys_task_set_name(const char *uspace_name, size_t name_len);
    147148
    148149#endif
  • kernel/generic/include/syscall/syscall.h

    r4c7257b rbc18d63  
    4545       
    4646        SYS_TASK_GET_ID,
     47        SYS_TASK_SET_NAME,
    4748        SYS_PROGRAM_SPAWN_LOADER,
    4849       
  • kernel/generic/src/proc/program.c

    r4c7257b rbc18d63  
    207207        /* Cap length of name and copy it from userspace. */
    208208
    209         if (name_len > THREAD_NAME_BUFLEN - 1)
    210                 name_len = THREAD_NAME_BUFLEN - 1;
     209        if (name_len > TASK_NAME_BUFLEN - 1)
     210                name_len = TASK_NAME_BUFLEN - 1;
    211211
    212212        rc = copy_from_uspace(namebuf, uspace_name, name_len);
  • kernel/generic/src/proc/task.c

    r4c7257b rbc18d63  
    250250}
    251251
     252/** Syscall for setting the task name.
     253 *
     254 * The name simplifies identifying the task in the task list.
     255 *
     256 * @param name  The new name for the task. (typically the same
     257 *              as the command used to execute it).
     258 *
     259 * @return 0 on success or an error code from @ref errno.h.
     260 */
     261unative_t sys_task_set_name(const char *uspace_name, size_t name_len)
     262{
     263        int rc;
     264        char namebuf[TASK_NAME_BUFLEN];
     265
     266        /* Cap length of name and copy it from userspace. */
     267
     268        if (name_len > TASK_NAME_BUFLEN - 1)
     269                name_len = TASK_NAME_BUFLEN - 1;
     270
     271        rc = copy_from_uspace(namebuf, uspace_name, name_len);
     272        if (rc != 0)
     273                return (unative_t) rc;
     274
     275        namebuf[name_len] = '\0';
     276        strcpy(TASK->name, namebuf);
     277
     278        return EOK;
     279}
     280
    252281/** Find task structure corresponding to task ID.
    253282 *
  • kernel/generic/src/syscall/syscall.c

    r4c7257b rbc18d63  
    150150       
    151151        (syshandler_t) sys_task_get_id,
     152        (syshandler_t) sys_task_set_name,
    152153        (syshandler_t) sys_program_spawn_loader,
    153154       
  • uspace/lib/libc/generic/task.c

    r4c7257b rbc18d63  
    3939#include <errno.h>
    4040#include <loader/loader.h>
     41#include <string.h>
    4142
    4243task_id_t task_get_id(void)
     
    4748
    4849        return task_id;
     50}
     51
     52/** Set the task name.
     53 *
     54 * @param name  The new name, typically the command used to execute the
     55 *              program.
     56 * @return      Zero on success or negative error code.
     57 */
     58int task_set_name(const char *name)
     59{
     60        return __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, strlen(name));
    4961}
    5062
  • uspace/lib/libc/include/task.h

    r4c7257b rbc18d63  
    4141
    4242extern task_id_t task_get_id(void);
     43extern int task_set_name(const char *name);
    4344extern task_id_t task_spawn(const char *path, char *const argv[]);
    4445
  • uspace/srv/loader/main.c

    r4c7257b rbc18d63  
    271271static void loader_run(ipc_callid_t rid, ipc_call_t *request)
    272272{
     273        /* Set the task name. */
     274        task_set_name(pathname);
     275
    273276        if (is_dyn_linked == true) {
    274277                /* Dynamically linked program */
Note: See TracChangeset for help on using the changeset viewer.