Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

reboot_cmd.c 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. #include <getopt.h>
  24. #include <ipxe/command.h>
  25. #include <ipxe/parseopt.h>
  26. #include <ipxe/reboot.h>
  27. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  28. /** @file
  29. *
  30. * Reboot command
  31. *
  32. */
  33. /** "reboot" options */
  34. struct reboot_options {
  35. /** Perform a warm reboot */
  36. int warm;
  37. };
  38. /** "reboot" option list */
  39. static struct option_descriptor reboot_opts[] = {
  40. OPTION_DESC ( "warm", 'w', no_argument,
  41. struct reboot_options, warm, parse_flag ),
  42. };
  43. /** "reboot" command descriptor */
  44. static struct command_descriptor reboot_cmd =
  45. COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, NULL );
  46. /**
  47. * The "reboot" command
  48. *
  49. * @v argc Argument count
  50. * @v argv Argument list
  51. * @ret rc Return status code
  52. */
  53. static int reboot_exec ( int argc, char **argv ) {
  54. struct reboot_options opts;
  55. int rc;
  56. /* Parse options */
  57. if ( ( rc = parse_options ( argc, argv, &reboot_cmd, &opts ) ) != 0 )
  58. return rc;
  59. /* Reboot system */
  60. reboot ( opts.warm );
  61. return 0;
  62. }
  63. /** "reboot" command */
  64. struct command reboot_command __command = {
  65. .name = "reboot",
  66. .exec = reboot_exec,
  67. };