summaryrefslogtreecommitdiff
path: root/cgpt
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-03-29 11:09:30 -0700
committerChromeBot <chrome-bot@google.com>2013-04-02 14:12:52 -0700
commit0c3ba249abb1dc60f5ebabccf84ff13206440b83 (patch)
tree81cd2ada3845b8bb4b83fde6e27050483d5b941e /cgpt
parent28b65ca99f4042fcc1218a4c18297f7ffb32ea15 (diff)
downloadvboot-0c3ba249abb1dc60f5ebabccf84ff13206440b83.tar.gz
Massive refactoring of external header files.
This reduces the number of exported header files to the minimum needed by the existing userspace utilities and firmware implementations. BUG=chromium:221544 BRANCH=none TEST=manual, trybots CQ-DEPEND=CL:47019,CL:47022,CL:47023 sudo FEATURES=test emerge vboot_reference FEATURES=test emerge-$BOARD \ vboot_reference \ chromeos-cryptohome \ chromeos-installer \ chromeos-u-boot \ peach-u-boot \ depthcharge Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47021 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'cgpt')
-rw-r--r--cgpt/cgpt.c5
-rw-r--r--cgpt/cgpt.h25
-rw-r--r--cgpt/cgpt_add.c9
-rw-r--r--cgpt/cgpt_boot.c2
-rw-r--r--cgpt/cgpt_common.c4
-rw-r--r--cgpt/cgpt_create.c4
-rw-r--r--cgpt/cgpt_find.c2
-rw-r--r--cgpt/cgpt_legacy.c5
-rw-r--r--cgpt/cgpt_params.h128
-rw-r--r--cgpt/cgpt_prioritize.c5
-rw-r--r--cgpt/cgpt_repair.c4
-rw-r--r--cgpt/cgpt_show.c5
-rw-r--r--cgpt/cmd_add.c5
-rw-r--r--cgpt/cmd_boot.c5
-rw-r--r--cgpt/cmd_create.c5
-rw-r--r--cgpt/cmd_find.c5
-rw-r--r--cgpt/cmd_legacy.c5
-rw-r--r--cgpt/cmd_prioritize.c3
-rw-r--r--cgpt/cmd_repair.c5
-rw-r--r--cgpt/cmd_show.c6
20 files changed, 39 insertions, 198 deletions
diff --git a/cgpt/cgpt.c b/cgpt/cgpt.c
index ac7aecdd..a3b20d99 100644
--- a/cgpt/cgpt.c
+++ b/cgpt/cgpt.c
@@ -6,13 +6,14 @@
* files for more details.
*/
-#include "cgpt.h"
-
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <uuid/uuid.h>
+#include "cgpt.h"
+#include "vboot_host.h"
+
const char* progname;
const char* command;
void (*uuid_generator)(uint8_t* buffer);
diff --git a/cgpt/cgpt.h b/cgpt/cgpt.h
index 47630928..3d09fb97 100644
--- a/cgpt/cgpt.h
+++ b/cgpt/cgpt.h
@@ -5,11 +5,6 @@
#ifndef VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
#define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#define _FILE_OFFSET_BITS 64
#include <fcntl.h>
#include <features.h>
#include <stdint.h>
@@ -20,13 +15,6 @@
#include "cgptlib.h"
-// Just for clarity
-enum {
- CGPT_OK = 0,
- CGPT_FAILED,
-};
-
-
struct legacy_partition {
uint8_t status;
uint8_t f_head;
@@ -67,19 +55,6 @@ int DriveOpen(const char *drive_path, struct drive *drive, int mode);
int DriveClose(struct drive *drive, int update_as_needed);
int CheckValid(const struct drive *drive);
-/* GUID conversion functions. Accepted format:
- *
- * "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
- *
- * At least GUID_STRLEN bytes should be reserved in 'str' (included the tailing
- * '\0').
- */
-#define GUID_STRLEN 37
-int StrToGuid(const char *str, Guid *guid);
-void GuidToStr(const Guid *guid, char *str, unsigned int buflen);
-int GuidEqual(const Guid *guid1, const Guid *guid2);
-int GuidIsZero(const Guid *guid);
-
/* Constant global type values to compare against */
extern const Guid guid_chromeos_firmware;
extern const Guid guid_chromeos_kernel;
diff --git a/cgpt/cgpt_add.c b/cgpt/cgpt_add.c
index 684d4d2f..eaf0b73e 100644
--- a/cgpt/cgpt_add.c
+++ b/cgpt/cgpt_add.c
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <string.h>
-#include "cgptlib_internal.h"
-#include "cgpt_params.h"
#define _STUB_IMPLEMENTATION_
+
+#include "cgpt.h"
+#include "cgpt_params.h"
+#include "cgptlib_internal.h"
#include "utility.h"
+#include "vboot_host.h"
static const char* DumpCgptAddParams(const CgptAddParams *params) {
static char buf[256];
diff --git a/cgpt/cgpt_boot.c b/cgpt/cgpt_boot.c
index 4de9c4c5..00b783f4 100644
--- a/cgpt/cgpt_boot.c
+++ b/cgpt/cgpt_boot.c
@@ -11,7 +11,7 @@
#include "cgpt_params.h"
#include "cgptlib_internal.h"
#include "endian.h"
-
+#include "vboot_host.h"
int CgptGetBootPartitionNumber(CgptBootParams *params) {
struct drive drive;
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c
index dc42d41f..dec26d12 100644
--- a/cgpt/cgpt_common.c
+++ b/cgpt/cgpt_common.c
@@ -6,8 +6,6 @@
* files for more details.
*/
-#include "cgpt.h"
-
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -22,8 +20,10 @@
#include <sys/types.h>
#include <unistd.h>
+#include "cgpt.h"
#include "cgptlib_internal.h"
#include "crc32.h"
+#include "vboot_host.h"
void Error(const char *format, ...) {
va_list ap;
diff --git a/cgpt/cgpt_create.c b/cgpt/cgpt_create.c
index f4d67d58..b0256c51 100644
--- a/cgpt/cgpt_create.c
+++ b/cgpt/cgpt_create.c
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
#include <string.h>
+#include "cgpt.h"
#include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
int CgptCreate(CgptCreateParams *params) {
struct drive drive;
diff --git a/cgpt/cgpt_find.c b/cgpt/cgpt_find.c
index 795eab62..c7c77b0c 100644
--- a/cgpt/cgpt_find.c
+++ b/cgpt/cgpt_find.c
@@ -8,8 +8,8 @@
#include <unistd.h>
#include "cgpt.h"
-#include "cgpt_params.h"
#include "cgptlib_internal.h"
+#include "vboot_host.h"
#define BUFSIZE 1024
// FIXME: currently we only support 512-byte sectors.
diff --git a/cgpt/cgpt_legacy.c b/cgpt/cgpt_legacy.c
index ac2d4f04..932fbb92 100644
--- a/cgpt/cgpt_legacy.c
+++ b/cgpt/cgpt_legacy.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <string.h>
+#include "cgpt.h"
#include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
int CgptLegacy(CgptLegacyParams *params) {
struct drive drive;
diff --git a/cgpt/cgpt_params.h b/cgpt/cgpt_params.h
deleted file mode 100644
index 470e0ffb..00000000
--- a/cgpt/cgpt_params.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
-#define VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
-
-#include "cgpt.h"
-
-// This file defines the internal methods that use the user-mode cgpt programatically.
-// This is the interface for the callers such as the cgpt tool or the C++ post installer
-// executable.
-
-typedef struct CgptCreateParams {
- char *drive_name;
- int zap;
-} CgptCreateParams;
-
-typedef struct CgptAddParams {
- char *drive_name;
- uint32_t partition;
- uint64_t begin;
- uint64_t size;
- Guid type_guid;
- Guid unique_guid;
- char *label;
- int successful;
- int tries;
- int priority;
- uint16_t raw_value;
- int set_begin;
- int set_size;
- int set_type;
- int set_unique;
- int set_successful;
- int set_tries;
- int set_priority;
- int set_raw;
-} CgptAddParams;
-
-typedef struct CgptShowParams {
- char *drive_name;
- int numeric;
- int verbose;
- int quick;
- uint32_t partition;
- int single_item;
- int debug;
-
- // This is filled in by the relevant methods in CgptShow.c
- int num_partitions;
-} CgptShowParams;
-
-typedef struct CgptRepairParams {
- char *drive_name;
- int verbose;
-} CgptRepairParams;
-
-typedef struct CgptBootParams {
- char *drive_name;
- uint32_t partition;
- char *bootfile;
- int create_pmbr;
-} CgptBootParams;
-
-typedef struct CgptPrioritizeParams {
- char *drive_name;
-
- uint32_t set_partition;
- int set_friends;
- int max_priority;
- int orig_priority;
-} CgptPrioritizeParams;
-
-typedef struct CgptFindParams {
- char *drive_name;
-
- int verbose;
- int set_unique;
- int set_type;
- int set_label;
- int oneonly;
- int numeric;
- uint8_t *matchbuf;
- uint64_t matchlen;
- uint64_t matchoffset;
- uint8_t *comparebuf;
- Guid unique_guid;
- Guid type_guid;
- char *label;
- int hits;
- int match_partnum; // 0 for no match, 1-N for match
-} CgptFindParams;
-
-typedef struct CgptLegacyParams {
- char *drive_name;
- int efipart;
-} CgptLegacyParams;
-
-// create related methods.
-int CgptCreate(CgptCreateParams *params);
-
-// add/attribute/details related methods
-int CgptAdd(CgptAddParams *params);
-int CgptSetAttributes(CgptAddParams *params);
-int CgptGetPartitionDetails(CgptAddParams *params);
-
-// boot related methods.
-int CgptBoot(CgptBootParams *params);
-int CgptGetBootPartitionNumber(CgptBootParams *params);
-
-// show/get related methods.
-int CgptShow(CgptShowParams *params);
-int CgptGetNumNonEmptyPartitions(CgptShowParams *params);
-
-// repair related methods.
-int CgptRepair(CgptRepairParams *params);
-
-// priority related methods.
-int CgptPrioritize(CgptPrioritizeParams *params);
-
-// find related methods.
-void CgptFind(CgptFindParams *params);
-
-// legacy related methods.
-int CgptLegacy(CgptLegacyParams *params);
-
-#endif // VBOOT_REFERENCE_CGPT_CGPT_PARAMS_H_
diff --git a/cgpt/cgpt_prioritize.c b/cgpt/cgpt_prioritize.c
index dd74ccf3..7cd73c0a 100644
--- a/cgpt/cgpt_prioritize.c
+++ b/cgpt/cgpt_prioritize.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <string.h>
+#include "cgpt.h"
#include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
//////////////////////////////////////////////////////////////////////////////
// We need a sorted list of priority groups, where each element in the list
diff --git a/cgpt/cgpt_repair.c b/cgpt/cgpt_repair.c
index aeac0b93..e591c75b 100644
--- a/cgpt/cgpt_repair.c
+++ b/cgpt/cgpt_repair.c
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
#include <string.h>
+#include "cgpt.h"
#include "cgptlib_internal.h"
-#include "cgpt_params.h"
+#include "vboot_host.h"
int CgptRepair(CgptRepairParams *params) {
struct drive drive;
diff --git a/cgpt/cgpt_show.c b/cgpt/cgpt_show.c
index 6c2160ca..cb5e2759 100644
--- a/cgpt/cgpt_show.c
+++ b/cgpt/cgpt_show.c
@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#define __STDC_FORMAT_MACROS
#include <string.h>
+#include "cgpt.h"
#include "cgptlib_internal.h"
-#include "cgpt_params.h"
#include "crc32.h"
+#include "vboot_host.h"
/* Generate output like:
*
diff --git a/cgpt/cmd_add.c b/cgpt/cmd_add.c
index 500633b0..a48ab336 100644
--- a/cgpt/cmd_add.c
+++ b/cgpt/cmd_add.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <getopt.h>
#include <string.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_boot.c b/cgpt/cmd_boot.c
index d2e63b7f..caa94bc7 100644
--- a/cgpt/cmd_boot.c
+++ b/cgpt/cmd_boot.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <getopt.h>
#include <string.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_create.c b/cgpt/cmd_create.c
index c2b8adfc..0d91b08a 100644
--- a/cgpt/cmd_create.c
+++ b/cgpt/cmd_create.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <getopt.h>
#include <string.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_find.c b/cgpt/cmd_find.c
index 4b2964d4..1a3dc696 100644
--- a/cgpt/cmd_find.c
+++ b/cgpt/cmd_find.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <getopt.h>
#include <string.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_legacy.c b/cgpt/cmd_legacy.c
index 593d2ece..a1269493 100644
--- a/cgpt/cmd_legacy.c
+++ b/cgpt/cmd_legacy.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <getopt.h>
#include <string.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_prioritize.c b/cgpt/cmd_prioritize.c
index 05e7e0e6..3a692b8d 100644
--- a/cgpt/cmd_prioritize.c
+++ b/cgpt/cmd_prioritize.c
@@ -8,7 +8,8 @@
#include <string.h>
#include <uuid/uuid.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_repair.c b/cgpt/cmd_repair.c
index 3c313303..ac5578af 100644
--- a/cgpt/cmd_repair.c
+++ b/cgpt/cmd_repair.c
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#include <getopt.h>
#include <string.h>
-#include "cgpt_params.h"
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{
diff --git a/cgpt/cmd_show.c b/cgpt/cmd_show.c
index 2df199d3..1b31f392 100644
--- a/cgpt/cmd_show.c
+++ b/cgpt/cmd_show.c
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cgpt.h"
-
#define __STDC_FORMAT_MACROS
#include <getopt.h>
#include <inttypes.h>
#include <string.h>
-#include "cgpt_params.h"
+
+#include "cgpt.h"
+#include "vboot_host.h"
static void Usage(void)
{