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

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

Issue 2231002: complete 'cgpt show' and refactor for incoming commands. (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 * Header file for cgpt. 5 * Header file for cgpt.
6 */ 6 */
7 #ifndef VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ 7 #ifndef VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
8 #define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ 8 #define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
9 9
10 #include <getopt.h> 10 #include <getopt.h>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const char *short_option, 82 const char *short_option,
83 const int option_count, 83 const int option_count,
84 const struct option *options, 84 const struct option *options,
85 const struct option_details *details); 85 const struct option_details *details);
86 86
87 struct drive; 87 struct drive;
88 int OpenDriveInLastArgument(const int argc, 88 int OpenDriveInLastArgument(const int argc,
89 char *const *argv, 89 char *const *argv,
90 struct drive *drive); 90 struct drive *drive);
91 91
92 /* GUID conversion functions. Accepted format:
93 *
94 * "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
95 *
96 * At least GUID_STRLEN bytes should be reserved in 'str' (included the tailing
97 * '\0').
98 */
99 #define GUID_STRLEN 37
100 void StrToGuid(const char *str, Guid *guid);
101 void GuidToStr(const Guid *guid, char *str);
102
103 /* Convert UTF16 string to UTF8. Rewritten from gpt utility.
104 * Caller must prepare enough space for UTF8. The rough estimation is:
105 *
106 * utf8 length = bytecount(utf16) * 1.5
107 */
108 void UTF16ToUTF8(const uint16_t *utf16, uint8_t *utf8);
109 /* Convert UTF8 string to UTF16. Rewritten from gpt utility.
110 * Caller must prepare enough space for UTF16. The conservative estimation is:
111 *
112 * utf16 bytecount = bytecount(utf8) / 3 * 4
113 */
114 void UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16);
115
92 /* Describes the drive storing the GPT. */ 116 /* Describes the drive storing the GPT. */
93 struct drive { 117 struct drive {
94 int inited; /* indicated if this structure is valid */ 118 int inited; /* indicated if this structure is valid */
95 int fd; /* file descriptor */ 119 int fd; /* file descriptor */
96 uint64_t size; /* total size (in bytes) */ 120 uint64_t size; /* total size (in bytes) */
97 GptData gpt; 121 GptData gpt;
98 }; 122 };
99 123
100 extern const char* progname; 124 extern const char* progname;
101 125
102 /* Given a hard drive path, this function loads GPT sectors from that drive, 126 /* Given a hard drive path, this function loads GPT sectors from that drive,
103 * and fills 'drive' structure. All memory allocated in drive_open() will be 127 * and fills 'drive' structure. All memory allocated in drive_open() will be
104 * freed at drive_close(). 128 * freed at drive_close().
105 * 129 *
106 * If 'drive_path' starts with '/', it is treated as absolute path. 130 * If 'drive_path' starts with '/', it is treated as absolute path.
107 * If 'drive_path' starts with '.', it is treated as relative path. 131 * If 'drive_path' starts with '.', it is treated as relative path.
108 * Otherwise, it will be prepended with '/dev/' to comply with gpt. 132 * Otherwise, it will be prepended with '/dev/' to comply with gpt.
109 * 133 *
110 * Returns CGPT_FAILED if any error happens. 134 * Returns CGPT_FAILED if any error happens.
111 * Returns CGPT_OK if success and information are stored in 'drive'. 135 * Returns CGPT_OK if success and information are stored in 'drive'.
112 */ 136 */
113 int DriveOpen(const char *drive_path, struct drive *drive); 137 int DriveOpen(const char *drive_path, struct drive *drive);
114 int DriveClose(struct drive *drive); 138 int DriveClose(struct drive *drive);
139 int CheckValid(const struct drive *drive);
115 140
116 /* Function declarations for commands. 141 /* Function declarations for commands.
117 * The return value of these functions is passed to main()'s exit value. */ 142 * The return value of these functions is passed to main()'s exit value. */
118 int CgptAttribute(int argc, char *argv[]); 143 int CgptAttribute(int argc, char *argv[]);
119 int CgptRepair(int argc, char *argv[]); 144 int CgptRepair(int argc, char *argv[]);
120 int CgptShow(int argc, char *argv[]); 145 int CgptShow(int argc, char *argv[]);
121 146
122 #endif /* VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ */ 147 #endif /* VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ */
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/utility/cgpt/Makefile ('k') | src/platform/vboot_reference/utility/cgpt/cgpt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698