| 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 * Update GPT attribute bits. | 5 * Update GPT attribute bits. |
| 6 */ | 6 */ |
| 7 #include <getopt.h> | 7 #include <getopt.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include "cgpt.h" | 10 #include "cgpt.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 attribute_options_details)) | 92 attribute_options_details)) |
| 93 return CGPT_FAILED; | 93 return CGPT_FAILED; |
| 94 if (help != NOT_INITED) { | 94 if (help != NOT_INITED) { |
| 95 AttributeHelp(); | 95 AttributeHelp(); |
| 96 return CGPT_FAILED; | 96 return CGPT_FAILED; |
| 97 } | 97 } |
| 98 | 98 |
| 99 if (CGPT_OK != OpenDriveInLastArgument(argc, argv, &drive)) | 99 if (CGPT_OK != OpenDriveInLastArgument(argc, argv, &drive)) |
| 100 return CGPT_FAILED; | 100 return CGPT_FAILED; |
| 101 | 101 |
| 102 if (CheckValid(&drive) != CGPT_OK) return CGPT_FAILED; |
| 103 |
| 102 debug("[OPTION] i:%d b:%d s:%d t:%d p:%d\n", partition, bad, successful, tries
, priority); /* FIXME */ | 104 debug("[OPTION] i:%d b:%d s:%d t:%d p:%d\n", partition, bad, successful, tries
, priority); /* FIXME */ |
| 103 | 105 |
| 104 /* partition is not specified, search for the first Chromeos kernel. */ | 106 /* partition is not specified, search for the first Chromeos kernel. */ |
| 105 if (partition == NOT_INITED) { | 107 if (partition == NOT_INITED) { |
| 106 int i; | 108 int i; |
| 107 for (i = 0; i < GetNumberOfEntries(&drive.gpt); ++i) { | 109 for (i = 0; i < GetNumberOfEntries(&drive.gpt); ++i) { |
| 108 static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; | 110 static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; |
| 109 GptEntry *entry; | 111 GptEntry *entry; |
| 110 entry = GetEntry(&drive.gpt, PRIMARY, i); | 112 entry = GetEntry(&drive.gpt, PRIMARY, i); |
| 111 if (!Memcmp(&chromeos_kernel, &entry->type, sizeof(Guid))) { | 113 if (!Memcmp(&chromeos_kernel, &entry->type, sizeof(Guid))) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 138 RepairHeader(&drive.gpt, MASK_PRIMARY); | 140 RepairHeader(&drive.gpt, MASK_PRIMARY); |
| 139 /* Forces headers and entries are modified so that CRC32 will be re-calculated | 141 /* Forces headers and entries are modified so that CRC32 will be re-calculated |
| 140 * and headers and entries will be updated to drive. */ | 142 * and headers and entries will be updated to drive. */ |
| 141 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | | 143 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | |
| 142 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); | 144 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); |
| 143 UpdateCrc(&drive.gpt); | 145 UpdateCrc(&drive.gpt); |
| 144 DriveClose(&drive); | 146 DriveClose(&drive); |
| 145 | 147 |
| 146 return CGPT_OK; | 148 return CGPT_OK; |
| 147 } | 149 } |
| OLD | NEW |