Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: cgpt/cmd_add.c

Issue 5025003: The right implementation of CGPT label conversion between UTF8 and UTF16. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "cgpt.h" 5 #include "cgpt.h"
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 <string.h> 10 #include <string.h>
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 if (set_begin) 238 if (set_begin)
239 entry->starting_lba = begin; 239 entry->starting_lba = begin;
240 if (set_size) 240 if (set_size)
241 entry->ending_lba = begin + size - 1; 241 entry->ending_lba = begin + size - 1;
242 if (set_type) 242 if (set_type)
243 memcpy(&entry->type, &type_guid, sizeof(Guid)); 243 memcpy(&entry->type, &type_guid, sizeof(Guid));
244 if (set_unique) 244 if (set_unique)
245 memcpy(&entry->unique, &unique_guid, sizeof(Guid)); 245 memcpy(&entry->unique, &unique_guid, sizeof(Guid));
246 if (label) { 246 if (label) {
247 UTF8ToUTF16((uint8_t *)label, entry->name, 247 if (CGPT_OK != UTF8ToUTF16((uint8_t *)label, entry->name,
248 sizeof(entry->name) / sizeof(entry->name[0])); 248 sizeof(entry->name) / sizeof(entry->name[0]))) {
249 goto bad;
Bill Richardson 2010/11/17 17:41:49 We should print an error message indicating that t
Louis 2010/11/18 05:35:21 Done.
250 }
249 } 251 }
250 if (set_raw) { 252 if (set_raw) {
251 entry->attrs.fields.gpt_att = raw_value; 253 entry->attrs.fields.gpt_att = raw_value;
252 } else { 254 } else {
253 if (set_successful) 255 if (set_successful)
254 SetSuccessful(&drive.gpt, PRIMARY, index, successful); 256 SetSuccessful(&drive.gpt, PRIMARY, index, successful);
255 if (set_tries) 257 if (set_tries)
256 SetTries(&drive.gpt, PRIMARY, index, tries); 258 SetTries(&drive.gpt, PRIMARY, index, tries);
257 if (set_priority) 259 if (set_priority)
258 SetPriority(&drive.gpt, PRIMARY, index, priority); 260 SetPriority(&drive.gpt, PRIMARY, index, priority);
259 } 261 }
260 262
261 RepairEntries(&drive.gpt, MASK_PRIMARY); 263 RepairEntries(&drive.gpt, MASK_PRIMARY);
262 RepairHeader(&drive.gpt, MASK_PRIMARY); 264 RepairHeader(&drive.gpt, MASK_PRIMARY);
263 265
264 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | 266 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 |
265 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); 267 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2);
266 UpdateCrc(&drive.gpt); 268 UpdateCrc(&drive.gpt);
267 269
268 270
269 // Write it all out 271 // Write it all out
270 return DriveClose(&drive, 1); 272 return DriveClose(&drive, 1);
271 273
272 bad: 274 bad:
273 (void) DriveClose(&drive, 0); 275 (void) DriveClose(&drive, 0);
274 return CGPT_FAILED; 276 return CGPT_FAILED;
275 } 277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698