summaryrefslogtreecommitdiff
path: root/cgpt/cgpt_common.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-06-20 14:33:00 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-09 01:30:48 +0000
commit782990277ac7d6730db4c43c2b5632de93396921 (patch)
treea7c6c3d332e4e89d4ccdbb6ced0b269dda13022d /cgpt/cgpt_common.c
parentf8f807a5ef00e8d5360fc2c9093bd0b5da8c0507 (diff)
downloadvboot-782990277ac7d6730db4c43c2b5632de93396921.tar.gz
Split libvboot_host.a into external and local libraries.
We've been creating and linking against a library called "libvboot_host.a" for two different reasons. The main purpose is to build the vboot_reference tools found in the utility/ directory. But there are some external userspace programs that would also like to use some functions in this library. This change establishes libvboot_host.a as the library for use by external userspace programs only, and creates a new libvboot_util.a library that's only used inside this source tree to build the vboot utilities. BUG=chromium:231567 BRANCH=ToT TEST=manual Build and run the local tests: make runalltests make clean Build Link firmware and all the utilities: emerge-link chromeos-base/vboot_reference \ sys-boot/depthcharge \ sys-boot/coreboot \ chromeos-base/chromeos-ec \ chromeos-base/chromeos-firmware-link \ chromeos-base/chromeos-cryptohome \ chromeos-base/update_engine \ chromeos-base/chromeos-installer \ chromeos-base/chromeos-login \ chromeos-base/verity Build Lumpy utilities, which include the 32-bit cros_installer: emerge-lumpy chromeos-base/vboot_reference \ chromeos-base/chromeos-login \ chromeos-base/verity \ chromeos-base/update_engine \ chromeos-base/chromeos-installer \ chromeos-base/chromeos-cryptohome Change-Id: Ie81ff1f74a6356cb8fab7d98471139d7758c4f19 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207016 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'cgpt/cgpt_common.c')
-rw-r--r--cgpt/cgpt_common.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c
index c8a069a4..ff3ae696 100644
--- a/cgpt/cgpt_common.c
+++ b/cgpt/cgpt_common.c
@@ -1162,6 +1162,42 @@ uint8_t RepairHeader(GptData *gpt, const uint32_t valid_headers) {
return 0;
}
+int CgptGetNumNonEmptyPartitions(CgptShowParams *params) {
+ struct drive drive;
+ int gpt_retval;
+ int retval;
+
+ if (params == NULL)
+ return CGPT_FAILED;
+
+ if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDONLY))
+ return CGPT_FAILED;
+
+ if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) {
+ Error("GptSanityCheck() returned %d: %s\n",
+ gpt_retval, GptError(gpt_retval));
+ retval = CGPT_FAILED;
+ goto done;
+ }
+
+ params->num_partitions = 0;
+ int numEntries = GetNumberOfEntries(&drive);
+ int i;
+ for(i = 0; i < numEntries; i++) {
+ GptEntry *entry = GetEntry(&drive.gpt, ANY_VALID, i);
+ if (GuidIsZero(&entry->type))
+ continue;
+
+ params->num_partitions++;
+ }
+
+ retval = CGPT_OK;
+
+done:
+ DriveClose(&drive, 0);
+ return retval;
+}
+
int GuidEqual(const Guid *guid1, const Guid *guid2) {
return (0 == memcmp(guid1, guid2, sizeof(Guid)));
}