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 #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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 entry = GetEntry(&drive.gpt, ANY_VALID, i); | 174 entry = GetEntry(&drive.gpt, ANY_VALID, i); |
175 | 175 |
176 if (IsZero(&entry->type)) | 176 if (IsZero(&entry->type)) |
177 continue; | 177 continue; |
178 | 178 |
179 int found = 0; | 179 int found = 0; |
180 if ((set_unique && !memcmp(&unique_guid, &entry->unique, sizeof(Guid))) || | 180 if ((set_unique && !memcmp(&unique_guid, &entry->unique, sizeof(Guid))) || |
181 (set_type && !memcmp(&type_guid, &entry->type, sizeof(Guid)))) { | 181 (set_type && !memcmp(&type_guid, &entry->type, sizeof(Guid)))) { |
182 found = 1; | 182 found = 1; |
183 } else if (set_label) { | 183 } else if (set_label) { |
184 UTF16ToUTF8(entry->name, sizeof(entry->name) / sizeof(entry->name[0]), | 184 if (CGPT_OK != UTF16ToUTF8(entry->name, |
185 (uint8_t *)partlabel, sizeof(partlabel)); | 185 sizeof(entry->name) / sizeof(entry->name[0]), |
| 186 (uint8_t *)partlabel, sizeof(partlabel))) { |
| 187 Error("The label cannot be converted to UTF16, so abort.\n"); |
| 188 return 0; |
| 189 } |
186 if (!strncmp(label, partlabel, sizeof(partlabel))) { | 190 if (!strncmp(label, partlabel, sizeof(partlabel))) { |
187 found = 1; | 191 found = 1; |
188 } | 192 } |
189 } | 193 } |
190 if (found && match_content(&drive, entry)) { | 194 if (found && match_content(&drive, entry)) { |
191 hits++; | 195 hits++; |
192 retval++; | 196 retval++; |
193 showmatch(filename, i+1, entry); | 197 showmatch(filename, i+1, entry); |
194 if (!match_partnum) { | 198 if (!match_partnum) { |
195 match_partnum = i+1; | 199 match_partnum = i+1; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (oneonly && hits != 1) { | 381 if (oneonly && hits != 1) { |
378 return CGPT_FAILED; | 382 return CGPT_FAILED; |
379 } | 383 } |
380 | 384 |
381 if (match_partnum) { | 385 if (match_partnum) { |
382 return CGPT_OK; | 386 return CGPT_OK; |
383 } | 387 } |
384 | 388 |
385 return CGPT_FAILED; | 389 return CGPT_FAILED; |
386 } | 390 } |
OLD | NEW |