| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (size_lba != NOT_INITED) { | 235 if (size_lba != NOT_INITED) { |
| 236 entry->ending_lba = entry->starting_lba + size_lba - 1; | 236 entry->ending_lba = entry->starting_lba + size_lba - 1; |
| 237 ++dirty; | 237 ++dirty; |
| 238 } | 238 } |
| 239 if (name[0]) { | 239 if (name[0]) { |
| 240 UTF8ToUTF16((uint8_t*)name, entry->name); | 240 UTF8ToUTF16((uint8_t*)name, entry->name); |
| 241 ++dirty; | 241 ++dirty; |
| 242 } | 242 } |
| 243 | 243 |
| 244 if (command == DELETE) { | 244 if (command == DELETE) { |
| 245 Guid unused = GPT_ENT_TYPE_UNUSED; | 245 Memcpy(&entry->type, &guid_unused, sizeof(Guid)); |
| 246 Memcpy(&entry->type, &unused, sizeof(Guid)); | |
| 247 } | 246 } |
| 248 | 247 |
| 249 if (dirty) { | 248 if (dirty) { |
| 250 uint32_t valid_entries; | 249 uint32_t valid_entries; |
| 251 | 250 |
| 252 valid_entries = drive.gpt.valid_entries; | 251 valid_entries = drive.gpt.valid_entries; |
| 253 if ((valid_entries != CheckValidEntries(&drive.gpt)) || | 252 if ((valid_entries != CheckValidEntries(&drive.gpt)) || |
| 254 (valid_entries != CheckOverlappedPartition(&drive.gpt))) { | 253 (valid_entries != CheckOverlappedPartition(&drive.gpt))) { |
| 255 printf("\n[ERROR] Your change makes GPT invalid (or worse). " | 254 printf("\n[ERROR] Your change makes GPT invalid (or worse). " |
| 256 "Please check your arguments.\n\n"); | 255 "Please check your arguments.\n\n"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 268 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); | 267 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); |
| 269 UpdateCrc(&drive.gpt); | 268 UpdateCrc(&drive.gpt); |
| 270 } | 269 } |
| 271 DriveClose(&drive); | 270 DriveClose(&drive); |
| 272 return CGPT_OK; | 271 return CGPT_OK; |
| 273 | 272 |
| 274 error_close: | 273 error_close: |
| 275 DriveClose(&drive); | 274 DriveClose(&drive); |
| 276 return CGPT_FAILED; | 275 return CGPT_FAILED; |
| 277 } | 276 } |
| OLD | NEW |