summaryrefslogtreecommitdiff
path: root/cgpt/cmd_repair.c
diff options
context:
space:
mode:
Diffstat (limited to 'cgpt/cmd_repair.c')
-rw-r--r--cgpt/cmd_repair.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/cgpt/cmd_repair.c b/cgpt/cmd_repair.c
index aafdc938..10d4ee8b 100644
--- a/cgpt/cmd_repair.c
+++ b/cgpt/cmd_repair.c
@@ -1,15 +1,13 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 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.
#include "cgpt.h"
#include <getopt.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include "cgptlib_internal.h"
+#include "cgpt_params.h"
static void Usage(void)
{
@@ -22,8 +20,10 @@ static void Usage(void)
int cmd_repair(int argc, char *argv[]) {
struct drive drive;
- int verbose = 0;
-
+
+ CgptRepairParams params;
+ memset(&params, 0, sizeof(params));
+
int c;
int errorcnt = 0;
@@ -33,7 +33,7 @@ int cmd_repair(int argc, char *argv[]) {
switch (c)
{
case 'v':
- verbose++;
+ params.verbose++;
break;
case 'h':
@@ -58,28 +58,7 @@ int cmd_repair(int argc, char *argv[]) {
return CGPT_FAILED;
}
- if (optind >= argc) {
- Error("missing drive argument\n");
- return CGPT_FAILED;
- }
-
- if (CGPT_OK != DriveOpen(argv[optind], &drive))
- return CGPT_FAILED;
-
- int gpt_retval = GptSanityCheck(&drive.gpt);
- if (verbose)
- printf("GptSanityCheck() returned %d: %s\n",
- gpt_retval, GptError(gpt_retval));
-
- GptRepair(&drive.gpt);
- if (drive.gpt.modified & GPT_MODIFIED_HEADER1)
- printf("Primary Header is updated.\n");
- if (drive.gpt.modified & GPT_MODIFIED_ENTRIES1)
- printf("Primary Entries is updated.\n");
- if (drive.gpt.modified & GPT_MODIFIED_ENTRIES2)
- printf("Secondary Entries is updated.\n");
- if (drive.gpt.modified & GPT_MODIFIED_HEADER2)
- printf("Secondary Header is updated.\n");
+ params.driveName = argv[optind];
- return DriveClose(&drive, 1);
+ return cgpt_repair(&params);
}