Changeset 8fab3f6 in mainline for uspace/app/sysctl/main.c


Ignore:
Timestamp:
2019-08-17T13:50:05Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
31ef7c1
Parents:
504d103
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-12-04 17:21:21)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-17 13:50:05)
Message:

sysctl: Add start operation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sysctl/main.c

    r504d103 r8fab3f6  
    9797}
    9898
     99static int start(int argc, char *argv[])
     100{
     101        unit_handle_t handle;
     102        char *unit_name = argv[1];
     103
     104        int rc = sysman_unit_handle(unit_name, &handle);
     105        if (rc != EOK) {
     106                printf("Cannot obtain handle for unit '%s' (%s).\n",
     107                    unit_name, str_error(rc));
     108                return rc;
     109        }
     110
     111        rc = sysman_unit_start(handle, IPC_FLAG_BLOCKING);
     112        if (rc != EOK) {
     113                printf("Error when starting unit '%s' error (%s).\n",
     114                    unit_name, str_error(rc));
     115                return rc;
     116        }
     117
     118        return 0;
     119}
     120
    99121static int stop(int argc, char *argv[])
    100122{
     
    111133        rc = sysman_unit_stop(handle, IPC_FLAG_BLOCKING);
    112134        if (rc != EOK) {
    113                 printf("Error when stopping unit '%s' handle (%s).\n",
     135                printf("Error when stopping unit '%s' error (%s).\n",
    114136                    unit_name, str_error(rc));
    115137                return rc;
     
    121143command_t commands[] = {
    122144        { "list-units", 0, &list_units },
     145        { "start",      1, &start },
    123146        { "stop",       1, &stop },
    124147        { 0 }
     
    127150static void print_syntax(void)
    128151{
    129         printf("syntax:\n");
    130         printf("\t%s\n", NAME);
    131         // TODO update as functionality grows
     152        printf("%s commands:\n", NAME);
     153        for (command_t *it = commands; it->name != NULL; ++it) {
     154                printf("\t%s", it->name);
     155                for (int i = 0; i < it->args; ++i) {
     156                        printf(" <arg%i>", i + 1);
     157                }
     158                printf("\n");
     159        }
    132160}
    133161
Note: See TracChangeset for help on using the changeset viewer.