| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 * | 4 * |
| 5 * Utility for ChromeOS-specific GPT partitions, Please see corresponding .c | 5 * Utility for ChromeOS-specific GPT partitions, Please see corresponding .c |
| 6 * files for more details. | 6 * files for more details. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "cgpt.h" | 9 #include "cgpt.h" |
| 10 | 10 |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <string.h> | 12 #include <string.h> |
| 13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 | 14 |
| 15 | 15 |
| 16 const char* progname; | 16 const char* progname; |
| 17 const char* command; | 17 const char* command; |
| 18 | 18 |
| 19 struct { | 19 struct { |
| 20 const char *name; | 20 const char *name; |
| 21 int (*fp)(int argc, char *argv[]); | 21 int (*fp)(int argc, char *argv[]); |
| 22 const char *comment; | 22 const char *comment; |
| 23 } cmds[] = { | 23 } cmds[] = { |
| 24 {"create", cmd_create, "Create or reset GPT headers and tables"}, | 24 {"create", cmd_create, "Create or reset GPT headers and tables"}, |
| 25 {"add", cmd_add, "Add, edit or remove a partition entry"}, | 25 {"add", cmd_add, "Add, edit or remove a partition entry"}, |
| 26 {"show", cmd_show, "Show partition table and entries"}, | 26 {"show", cmd_show, "Show partition table and entries"}, |
| 27 {"repair", cmd_repair, "Repair damaged GPT headers and tables"}, | 27 {"repair", cmd_repair, "Repair damaged GPT headers and tables"}, |
| 28 {"boot", cmd_boot, "Edit the PMBR sector for legacy BIOSes"}, | 28 {"boot", cmd_boot, "Edit the PMBR sector for legacy BIOSes"}, |
| 29 {"find", cmd_find, "Locate a partition by its GUID"}, |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 | 32 |
| 32 void Usage(void) { | 33 void Usage(void) { |
| 33 int i; | 34 int i; |
| 34 | 35 |
| 35 printf("Usage: %s COMMAND [OPTIONS] DRIVE\n\n" | 36 printf("Usage: %s COMMAND [OPTIONS] DRIVE\n\n" |
| 36 "Supported COMMANDs:\n\n", | 37 "Supported COMMANDs:\n\n", |
| 37 progname); | 38 progname); |
| 38 | 39 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 if (0 == strcmp(cmds[i].name, command)) { | 67 if (0 == strcmp(cmds[i].name, command)) { |
| 67 return cmds[i].fp(argc, argv); | 68 return cmds[i].fp(argc, argv); |
| 68 } | 69 } |
| 69 } | 70 } |
| 70 | 71 |
| 71 // Couldn't find the command. | 72 // Couldn't find the command. |
| 72 Usage(); | 73 Usage(); |
| 73 | 74 |
| 74 return CGPT_FAILED; | 75 return CGPT_FAILED; |
| 75 } | 76 } |
| OLD | NEW |