You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reboot_cmd.c 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. #include <getopt.h>
  20. #include <ipxe/command.h>
  21. #include <ipxe/parseopt.h>
  22. #include <ipxe/reboot.h>
  23. FILE_LICENCE ( GPL2_OR_LATER );
  24. /** @file
  25. *
  26. * Reboot command
  27. *
  28. */
  29. /** "reboot" options */
  30. struct reboot_options {
  31. /** Perform a warm reboot */
  32. int warm;
  33. };
  34. /** "reboot" option list */
  35. static struct option_descriptor reboot_opts[] = {
  36. OPTION_DESC ( "warm", 'w', no_argument,
  37. struct reboot_options, warm, parse_flag ),
  38. };
  39. /** "reboot" command descriptor */
  40. static struct command_descriptor reboot_cmd =
  41. COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, NULL );
  42. /**
  43. * The "reboot" command
  44. *
  45. * @v argc Argument count
  46. * @v argv Argument list
  47. * @ret rc Return status code
  48. */
  49. static int reboot_exec ( int argc, char **argv ) {
  50. struct reboot_options opts;
  51. int rc;
  52. /* Parse options */
  53. if ( ( rc = parse_options ( argc, argv, &reboot_cmd, &opts ) ) != 0 )
  54. return rc;
  55. /* Reboot system */
  56. reboot ( opts.warm );
  57. return 0;
  58. }
  59. /** "reboot" command */
  60. struct command reboot_command __command = {
  61. .name = "reboot",
  62. .exec = reboot_exec,
  63. };