From 05987b159acb9737707b9ef92b818ac434ef8c3d Mon Sep 17 00:00:00 2001 From: David Riley Date: Thu, 5 Feb 2015 19:22:49 -0800 Subject: 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 Change-Id: Ie69cfee0c650d4ff96be6322083a2fea1543ee39 Reviewed-on: https://chromium-review.googlesource.com/246773 Reviewed-by: Bill Richardson Tested-by: David Riley Commit-Queue: David Riley --- cgpt/cgpt.h | 2 ++ cgpt/cgpt_common.c | 15 ++++++++++++++- cgpt/cgpt_endian.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'cgpt') diff --git a/cgpt/cgpt.h b/cgpt/cgpt.h index ff9e1064..b8b7e8d5 100644 --- a/cgpt/cgpt.h +++ b/cgpt/cgpt.h @@ -6,7 +6,9 @@ #define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ #include +#ifndef HAVE_MACOS #include +#endif #include #include #include diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index ffaa3090..5bb44f7a 100644 --- a/cgpt/cgpt_common.c +++ b/cgpt/cgpt_common.c @@ -9,8 +9,10 @@ #include #include #include +#ifndef HAVE_MACOS #include #include +#endif #include #include #include @@ -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 diff --git a/cgpt/cgpt_endian.h b/cgpt/cgpt_endian.h index 04204e74..49439ccf 100644 --- a/cgpt/cgpt_endian.h +++ b/cgpt/cgpt_endian.h @@ -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 +#endif #ifndef le16toh +#ifndef HAVE_MACOS # include +#endif # if __BYTE_ORDER == __LITTLE_ENDIAN # define htobe16(x) __bswap_16 (x) -- cgit v1.2.1