Changeset f35749e in mainline for uspace/app/shutdown/shutdown.c


Ignore:
Timestamp:
2025-02-28T23:38:26Z (2 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
8300c72
Parents:
4285f384
Message:

System restart via shutdown -r

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/shutdown/shutdown.c

    r4285f384 rf35749e  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939#include <fibril_synch.h>
    4040#include <nchoice.h>
     41#include <shutdown.h>
    4142#include <stdio.h>
    4243#include <stdbool.h>
     
    113114
    114115        rc = nchoice_add(nchoice, "Power off", (void *)(uintptr_t)sd_poweroff,
     116            0);
     117        if (rc != EOK) {
     118                printf(NAME ": Out of memory.\n");
     119                goto error;
     120        }
     121
     122        rc = nchoice_add(nchoice, "Restart", (void *)(uintptr_t)sd_restart,
    115123            0);
    116124        if (rc != EOK) {
     
    157165                        action = sd_poweroff;
    158166                        continue;
     167                } else if (str_cmp(*argv, "-r") == 0) {
     168                        --argc;
     169                        ++argv;
     170                        action = sd_restart;
     171                        continue;
    159172                }
    160173
     
    187200        }
    188201
    189         rc = system_shutdown(system);
     202        switch (action) {
     203        case sd_poweroff:
     204                rc = system_poweroff(system);
     205                break;
     206        case sd_restart:
     207                rc = system_restart(system);
     208                break;
     209        case sd_cancel:
     210                assert(false);
     211                rc = EINVAL;
     212                break;
     213        }
     214
    190215        if (rc != EOK) {
    191216                system_close(system);
     
    223248            "\tshutdown [<options>]\n"
    224249            "options:\n"
    225             "\t-p Power off\n");
     250            "\t-p Power off\n"
     251            "\t-r Restart off\n");
    226252}
    227253
Note: See TracChangeset for help on using the changeset viewer.