mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-16 21:07:26 +00:00
Changes to compile signing tools on darwin
The following works from a Mac with these changes: make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility Only vbutil_keyblock and vbutil_kernel have been exercised. BUG=none TEST='make Q= ARCH=arm HAVE_MACOS=1 `pwd`/build/futility/futility' BRANCH=none Signed-off-by: David Riley <davidriley@chromium.org> Change-Id: Ie69cfee0c650d4ff96be6322083a2fea1543ee39 Reviewed-on: https://chromium-review.googlesource.com/246773 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Commit-Queue: David Riley <davidriley@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
2b0dc16745
commit
05987b159a
4
Makefile
4
Makefile
@@ -179,6 +179,10 @@ ifneq (${COV},)
|
||||
COV_INFO = ${BUILD}/coverage.info
|
||||
endif
|
||||
|
||||
ifdef HAVE_MACOS
|
||||
CFLAGS += -DHAVE_MACOS -Wno-deprecated-declarations
|
||||
endif
|
||||
|
||||
# And a few more default utilities
|
||||
LD = ${CC}
|
||||
CXX ?= g++
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
|
||||
|
||||
#include <fcntl.h>
|
||||
#ifndef HAVE_MACOS
|
||||
#include <features.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#ifndef HAVE_MACOS
|
||||
#include <linux/major.h>
|
||||
#include <mtd/mtd-user.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -265,6 +267,7 @@ static int ObtainDriveSize(int fd, uint64_t* size, uint32_t* sector_bytes) {
|
||||
if (fstat(fd, &stat) == -1) {
|
||||
return -1;
|
||||
}
|
||||
#ifndef HAVE_MACOS
|
||||
if ((stat.st_mode & S_IFMT) != S_IFREG) {
|
||||
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
|
||||
return -1;
|
||||
@@ -276,6 +279,10 @@ static int ObtainDriveSize(int fd, uint64_t* size, uint32_t* sector_bytes) {
|
||||
*sector_bytes = 512; /* bytes */
|
||||
*size = stat.st_size;
|
||||
}
|
||||
#else
|
||||
*sector_bytes = 512; /* bytes */
|
||||
*size = stat.st_size;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -289,7 +296,11 @@ int DriveOpen(const char *drive_path, struct drive *drive, int mode,
|
||||
// Clear struct for proper error handling.
|
||||
memset(drive, 0, sizeof(struct drive));
|
||||
|
||||
drive->fd = open(drive_path, mode | O_LARGEFILE | O_NOFOLLOW);
|
||||
drive->fd = open(drive_path, mode |
|
||||
#ifndef HAVE_MACOS
|
||||
O_LARGEFILE |
|
||||
#endif
|
||||
O_NOFOLLOW);
|
||||
if (drive->fd == -1) {
|
||||
Error("Can't open %s: %s\n", drive_path, strerror(errno));
|
||||
return CGPT_FAILED;
|
||||
@@ -1010,4 +1021,6 @@ void PMBRToStr(struct pmbr *pmbr, char *str, unsigned int buflen) {
|
||||
|
||||
/* Optional */
|
||||
int __GenerateGuid(Guid *newguid) { return CGPT_FAILED; };
|
||||
#ifndef HAVE_MACOS
|
||||
int GenerateGuid(Guid *newguid) __attribute__((weak, alias("__GenerateGuid")));
|
||||
#endif
|
||||
|
||||
@@ -7,11 +7,15 @@
|
||||
#define VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_
|
||||
|
||||
// Newer distros already have this. For those that don't, we add it here.
|
||||
#ifndef HAVE_MACOS
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#ifndef le16toh
|
||||
|
||||
#ifndef HAVE_MACOS
|
||||
# include <byteswap.h>
|
||||
#endif
|
||||
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define htobe16(x) __bswap_16 (x)
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <inttypes.h> /* For PRIu64 */
|
||||
#ifndef HAVE_MACOS
|
||||
#include <linux/fs.h> /* For BLKGETSIZE64 */
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -176,11 +178,13 @@ static uint8_t *ReadOldKPartFromFileOrDie(const char *filename,
|
||||
Fatal("Unable to stat %s: %s\n", filename, strerror(errno));
|
||||
|
||||
if (S_ISBLK(statbuf.st_mode)) {
|
||||
#ifndef HAVE_MACOS
|
||||
int fd = open(filename, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
ioctl(fd, BLKGETSIZE64, &file_size);
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
file_size = statbuf.st_size;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ BUILD_ASSERT(ARRAY_SIZE(type_strings) == NUM_FILE_TYPES);
|
||||
|
||||
const char * const futil_file_type_str(enum futil_file_type type)
|
||||
{
|
||||
if (type < 0 || type >= NUM_FILE_TYPES)
|
||||
if ((int) type < 0 || type >= NUM_FILE_TYPES)
|
||||
type = FILE_TYPE_UNKNOWN;
|
||||
|
||||
return type_strings[type];
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef HAVE_MACOS
|
||||
#include <linux/fs.h> /* For BLKGETSIZE64 */
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -241,8 +243,10 @@ enum futil_file_err futil_map_file(int fd, int writeable,
|
||||
return FILE_ERR_STAT;
|
||||
}
|
||||
|
||||
#ifndef HAVE_MACOS
|
||||
if (S_ISBLK(sb.st_mode))
|
||||
ioctl(fd, BLKGETSIZE64, &sb.st_size);
|
||||
#endif
|
||||
|
||||
/* If the image is larger than 2^32 bytes, it's wrong. */
|
||||
if (sb.st_size < 0 || sb.st_size > UINT32_MAX) {
|
||||
|
||||
@@ -164,7 +164,7 @@ static int invoke_callback(struct futil_traverse_state_s *state,
|
||||
__func__, name, state->op, futil_cb_component_str[c],
|
||||
offset, len, buf);
|
||||
|
||||
if (c < 0 || c >= NUM_CB_COMPONENTS) {
|
||||
if ((int) c < 0 || c >= NUM_CB_COMPONENTS) {
|
||||
fprintf(stderr, "Invalid component %d\n", c);
|
||||
return 1;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ int futil_traverse(uint8_t *buf, uint32_t len,
|
||||
const struct bios_area_s *area;
|
||||
int retval = 0;
|
||||
|
||||
if (state->op < 0 || state->op >= NUM_FUTIL_OPS) {
|
||||
if ((int) state->op < 0 || state->op >= NUM_FUTIL_OPS) {
|
||||
fprintf(stderr, "Invalid op %d\n", state->op);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef HAVE_MACOS
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
@@ -456,6 +458,7 @@ static int VbWriteNvStorage_disk(VbNvContext* vnc) {
|
||||
__FUNCTION__, nvctx_path);
|
||||
break;
|
||||
}
|
||||
#ifndef HAVE_MACOS
|
||||
/* Must flush buffer cache here to make sure it goes to disk */
|
||||
rv = ioctl(nvctx_fd, BLKFLSBUF, 0);
|
||||
if (rv < 0) {
|
||||
@@ -463,6 +466,7 @@ static int VbWriteNvStorage_disk(VbNvContext* vnc) {
|
||||
__FUNCTION__, nvctx_path);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
rv = 0;
|
||||
} while (0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user