Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: utility/cgpt/cgpt_repair.c

Issue 2719008: Nearly complete rewrite of cgpt tool. (Closed) Base URL: ssh://git@chromiumos-git//vboot_reference.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utility/cgpt/cgpt_options.c ('k') | utility/cgpt/cgpt_show.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utility/cgpt/cgpt_repair.c
diff --git a/utility/cgpt/cgpt_repair.c b/utility/cgpt/cgpt_repair.c
deleted file mode 100644
index f75e4a2c626b050ea05dc3ad12b98f48ef4d8574..0000000000000000000000000000000000000000
--- a/utility/cgpt/cgpt_repair.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Repair headers and tables.
- *
- * If primary header or table is invalid, it copies from secondary (vice versa).
- */
-#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "cgpt.h"
-#include "cgptlib_internal.h"
-#include "utility.h"
-
-/* Integers to store parsed argument. */
-static int help;
-
-/* The structure for getopt_long(). When you add/delete any line, please refine
- * attribute_comments[] and third parameter of getopt_long() too. */
-static struct option repair_options[] = {
- {.name = "help", .has_arg = no_argument, .flag = 0, .val = 'h'},
- { /* last element, which should be zero. */ }
-};
-
-/* Extra information than struct option, please update this structure if you
- * add/remove any line in attribute_options[]. */
-static struct option_details repair_options_details[] = {
- /* help */
- { .comment = "print this help",
- .validator = AssignTrue,
- .valid_range = 0,
- .parsed = &help},
- { /* last element, which should be zero. */ }
-};
-
-void RepairHelp() {
- printf("\nUsage: %s repair [OPTIONS] device_name\n\n", progname);
- ShowOptions(repair_options, repair_options_details,
- ARRAY_COUNT(repair_options));
- printf("\n");
-}
-
-/* Parses all options (and validates them), then opens the drive and sets
- * corresponding bits in GPT entry. */
-int CgptRepair(int argc, char *argv[]) {
- struct drive drive;
-
- /* I know this is NOT the perfect place to put code to make options[] and
- * details[] are synced. But this is the best place we have right now since C
- * preprocessor doesn't know sizeof() for #if directive. */
- assert(ARRAY_COUNT(repair_options) ==
- ARRAY_COUNT(repair_options_details));
-
- help = NOT_INITED;
-
- if (CGPT_OK != HandleOptions(argc, argv,
- "hr",
- ARRAY_COUNT(repair_options),
- repair_options,
- repair_options_details))
- return CGPT_FAILED;
- if (help != NOT_INITED) {
- RepairHelp();
- return CGPT_FAILED;
- }
-
- if (CGPT_OK != OpenDriveInLastArgument(argc, argv, &drive))
- return CGPT_FAILED;
-
- GptRepair(&drive.gpt);
- if (drive.gpt.modified & GPT_MODIFIED_HEADER1)
- printf("* Pri Header is updated.\n");
- if (drive.gpt.modified & GPT_MODIFIED_ENTRIES1)
- printf("* Pri Table Entries is updated.\n");
- if (drive.gpt.modified & GPT_MODIFIED_ENTRIES2)
- printf("* Sec Table Entries is updated.\n");
- if (drive.gpt.modified & GPT_MODIFIED_HEADER2)
- printf("* Sec Header is updated.\n");
-
- DriveClose(&drive);
-
- return CGPT_OK;
-}
« no previous file with comments | « utility/cgpt/cgpt_options.c ('k') | utility/cgpt/cgpt_show.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698