diff options
Diffstat (limited to 'cgpt/cgpt_repair.c')
-rw-r--r-- | cgpt/cgpt_repair.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cgpt/cgpt_repair.c b/cgpt/cgpt_repair.c new file mode 100644 index 00000000..3d7ca64c --- /dev/null +++ b/cgpt/cgpt_repair.c @@ -0,0 +1,37 @@ +// 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 <string.h> + +#include "cgptlib_internal.h" +#include "cgpt_params.h" + +int cgpt_repair(CgptRepairParams *params) { + struct drive drive; + + if (params == NULL) + return CGPT_FAILED; + + if (CGPT_OK != DriveOpen(params->driveName, &drive)) + return CGPT_FAILED; + + int gpt_retval = GptSanityCheck(&drive.gpt); + if (params->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"); + + return DriveClose(&drive, 1); +} |