1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 6 #include <string.h> 7 8 #include "cgpt.h" 9 #include "cgptlib_internal.h" 10 #include "vboot_host.h" 11 CgptRepair(CgptRepairParams * params)12int CgptRepair(CgptRepairParams *params) { 13 struct drive drive; 14 15 if (params == NULL) 16 return CGPT_FAILED; 17 18 if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR, 19 params->drive_size)) 20 return CGPT_FAILED; 21 22 int gpt_retval = GptSanityCheck(&drive.gpt); 23 if (params->verbose) 24 printf("GptSanityCheck() returned %d: %s\n", 25 gpt_retval, GptError(gpt_retval)); 26 27 GptRepair(&drive.gpt); 28 if (drive.gpt.modified & GPT_MODIFIED_HEADER1) 29 printf("Primary Header is updated.\n"); 30 if (drive.gpt.modified & GPT_MODIFIED_ENTRIES1) 31 printf("Primary Entries is updated.\n"); 32 if (drive.gpt.modified & GPT_MODIFIED_ENTRIES2) 33 printf("Secondary Entries is updated.\n"); 34 if (drive.gpt.modified & GPT_MODIFIED_HEADER2) 35 printf("Secondary Header is updated.\n"); 36 37 return DriveClose(&drive, 1); 38 } 39