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

Side by Side Diff: src/platform/vboot_reference/utility/cgpt/cgpt.c

Issue 2614002: Enable attributes to display and set properly. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Created 10 years, 6 months 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
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 * Utility for ChromeOS-specific GPT partitions, Please see corresponding .c 5 * Utility for ChromeOS-specific GPT partitions, Please see corresponding .c
6 * files for more details. 6 * files for more details.
7 */ 7 */
8 /* To compile on host without compatility to BSD, we include 8 /* To compile on host without compatility to BSD, we include
9 * endian.h under chroot. */ 9 * endian.h under chroot. */
10 #define _BSD_SOURCE 10 #define _BSD_SOURCE
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 utf8[s8idx++] = 0xe0 | (utfchar >> 12); 135 utf8[s8idx++] = 0xe0 | (utfchar >> 12);
136 utf8[s8idx++] = 0x80 | ((utfchar >> 6) & 0x3f); 136 utf8[s8idx++] = 0x80 | ((utfchar >> 6) & 0x3f);
137 utf8[s8idx++] = 0x80 | (utfchar & 0x3f); 137 utf8[s8idx++] = 0x80 | (utfchar & 0x3f);
138 } else if (utfchar < 0x200000) { 138 } else if (utfchar < 0x200000) {
139 utf8[s8idx++] = 0xf0 | (utfchar >> 18); 139 utf8[s8idx++] = 0xf0 | (utfchar >> 18);
140 utf8[s8idx++] = 0x80 | ((utfchar >> 12) & 0x3f); 140 utf8[s8idx++] = 0x80 | ((utfchar >> 12) & 0x3f);
141 utf8[s8idx++] = 0x80 | ((utfchar >> 6) & 0x3f); 141 utf8[s8idx++] = 0x80 | ((utfchar >> 6) & 0x3f);
142 utf8[s8idx++] = 0x80 | (utfchar & 0x3f); 142 utf8[s8idx++] = 0x80 | (utfchar & 0x3f);
143 } 143 }
144 } 144 }
145 utf8[s8idx++] = 0;
145 } 146 }
146 147
147 /* Convert UTF8 string to UTF16. Rewritten from gpt utility. 148 /* Convert UTF8 string to UTF16. Rewritten from gpt utility.
148 * Caller must prepare enough space for UTF16. The conservative estimation is: 149 * Caller must prepare enough space for UTF16. The conservative estimation is:
149 * 150 *
150 * utf16 bytecount = bytecount(utf8) / 3 * 4 151 * utf16 bytecount = bytecount(utf8) / 3 * 4
151 */ 152 */
152 void UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16) 153 void UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16)
153 { 154 {
154 size_t s16idx, s8idx, s8len; 155 size_t s16idx, s8idx, s8len;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (s16idx < SIZEOF_GPTENTRY_NAME) 203 if (s16idx < SIZEOF_GPTENTRY_NAME)
203 utf16[s16idx++] = 0; 204 utf16[s16idx++] = 0;
204 } 205 }
205 206
206 struct { 207 struct {
207 Guid type; 208 Guid type;
208 char *name; 209 char *name;
209 char *description; 210 char *description;
210 } supported_types[] = { 211 } supported_types[] = {
211 {GPT_ENT_TYPE_UNUSED, "unused", "Unused partition"}, 212 {GPT_ENT_TYPE_UNUSED, "unused", "Unused partition"},
212 {GPT_ENT_TYPE_EFI, "efi", "EFI partition"}, 213 {GPT_ENT_TYPE_EFI, "efi", "EFI System Partition"},
213 {GPT_ENT_TYPE_CHROMEOS_KERNEL, "croskern", "ChromeOS kernel"}, 214 {GPT_ENT_TYPE_CHROMEOS_KERNEL, "croskern", "ChromeOS kernel"},
214 {GPT_ENT_TYPE_CHROMEOS_ROOTFS, "crosroot", "ChromeOS rootfs"}, 215 {GPT_ENT_TYPE_CHROMEOS_ROOTFS, "crosroot", "ChromeOS rootfs"},
215 {GPT_ENT_TYPE_CHROMEOS_RESERVED, "crosresv", "ChromeOS reserved"}, 216 {GPT_ENT_TYPE_CHROMEOS_RESERVED, "crosresv", "ChromeOS reserved"},
217 {GPT_ENT_TYPE_LINUX_DATA, "data", "Linux data"},
216 }; 218 };
217 219
218 /* Resolves human-readable GPT type. 220 /* Resolves human-readable GPT type.
219 * Returns CGPT_OK if found. 221 * Returns CGPT_OK if found.
220 * Returns CGPT_FAILED if no known type found. */ 222 * Returns CGPT_FAILED if no known type found. */
221 int ResolveType(const Guid *type, char *buf) { 223 int ResolveType(const Guid *type, char *buf) {
222 int i; 224 int i;
223 for (i = 0; i < ARRAY_COUNT(supported_types); ++i) { 225 for (i = 0; i < ARRAY_COUNT(supported_types); ++i) {
224 if (!Memcmp(type, &supported_types[i].type, sizeof(Guid))) { 226 if (!Memcmp(type, &supported_types[i].type, sizeof(Guid))) {
225 strcpy(buf, supported_types[i].description); 227 strcpy(buf, supported_types[i].description);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 439
438 drive->inited = 0; 440 drive->inited = 0;
439 return CGPT_OK; 441 return CGPT_OK;
440 } 442 }
441 443
442 int main(int argc, char *argv[]) { 444 int main(int argc, char *argv[]) {
443 char *cmd; 445 char *cmd;
444 int i; 446 int i;
445 447
446 progname = argv[0]; 448 progname = argv[0];
447 printf("Copyright (c) 2010 The Chromium OS Authors. All rights reserved.\n");
448 cmd = argv[optind++]; 449 cmd = argv[optind++];
449 for (i = 0; i < sizeof(cmds)/sizeof(cmds[0]); ++i) { 450 for (i = 0; i < sizeof(cmds)/sizeof(cmds[0]); ++i) {
450 if (cmd && !strcmp(cmds[i].name, cmd)) 451 if (cmd && !strcmp(cmds[i].name, cmd))
451 return cmds[i].fp(argc, argv); 452 return cmds[i].fp(argc, argv);
452 } 453 }
453 454
454 Usage(0); 455 Usage(0);
455 return CGPT_FAILED; 456 return CGPT_FAILED;
456 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698