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 * Repair headers and tables. | 5 * Repair headers and tables. |
6 * | 6 * |
7 * If primary header or table is invalid, it copies from secondary (vice versa). | 7 * If primary header or table is invalid, it copies from secondary (vice versa). |
8 */ | 8 */ |
9 #include <getopt.h> | 9 #include <getopt.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
11 #include <stdlib.h> | 11 #include <stdlib.h> |
12 #include "cgpt.h" | 12 #include "cgpt.h" |
13 #include "cgptlib_internal.h" | 13 #include "cgptlib_internal.h" |
14 #include "utility.h" | 14 #include "utility.h" |
15 | 15 |
16 /* Integers to store parsed argument. */ | 16 /* Integers to store parsed argument. */ |
17 static int help; | 17 static int help; |
18 | 18 |
19 /* The structure for getopt_long(). When you add/delete any line, please refine | 19 /* The structure for getopt_long(). When you add/delete any line, please refine |
20 * attribute_comments[] and third parameter of getopt_long() too. */ | 20 * attribute_comments[] and third parameter of getopt_long() too. */ |
21 static struct option repair_options[] = { | 21 static struct option repair_options[] = { |
22 {.name = "help", .has_arg = no_argument, .flag = 0, .val = 'h'}, | 22 {.name = "help", .has_arg = no_argument, .flag = 0, .val = 'h'}, |
| 23 { /* last element, which should be zero. */ } |
23 }; | 24 }; |
24 | 25 |
25 /* Extra information than struct option, please update this structure if you | 26 /* Extra information than struct option, please update this structure if you |
26 * add/remove any line in attribute_options[]. */ | 27 * add/remove any line in attribute_options[]. */ |
27 static struct option_details repair_options_details[] = { | 28 static struct option_details repair_options_details[] = { |
28 /* help */ | 29 /* help */ |
29 { .comment = "print this help", | 30 { .comment = "print this help", |
30 .validator = AssignTrue, | 31 .validator = AssignTrue, |
31 .valid_range = 0, | 32 .valid_range = 0, |
32 .parsed = &help}, | 33 .parsed = &help}, |
| 34 { /* last element, which should be zero. */ } |
33 }; | 35 }; |
34 | 36 |
35 void RepairHelp() { | 37 void RepairHelp() { |
36 printf("\nUsage: %s repair [OPTIONS] device_name\n\n", progname); | 38 printf("\nUsage: %s repair [OPTIONS] device_name\n\n", progname); |
37 ShowOptions(repair_options, repair_options_details, | 39 ShowOptions(repair_options, repair_options_details, |
38 ARRAY_COUNT(repair_options)); | 40 ARRAY_COUNT(repair_options)); |
39 printf("\n"); | 41 printf("\n"); |
40 } | 42 } |
41 | 43 |
42 /* Parses all options (and validates them), then opens the drive and sets | 44 /* Parses all options (and validates them), then opens the drive and sets |
(...skipping 30 matching lines...) Expand all Loading... |
73 printf("* Pri Table Entries is updated.\n"); | 75 printf("* Pri Table Entries is updated.\n"); |
74 if (drive.gpt.modified & GPT_MODIFIED_ENTRIES2) | 76 if (drive.gpt.modified & GPT_MODIFIED_ENTRIES2) |
75 printf("* Sec Table Entries is updated.\n"); | 77 printf("* Sec Table Entries is updated.\n"); |
76 if (drive.gpt.modified & GPT_MODIFIED_HEADER2) | 78 if (drive.gpt.modified & GPT_MODIFIED_HEADER2) |
77 printf("* Sec Header is updated.\n"); | 79 printf("* Sec Header is updated.\n"); |
78 | 80 |
79 DriveClose(&drive); | 81 DriveClose(&drive); |
80 | 82 |
81 return CGPT_OK; | 83 return CGPT_OK; |
82 } | 84 } |
OLD | NEW |