From ed94fc2fd4a954415f007d725950a29b1f900267 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Tue, 12 Apr 2016 13:25:48 +0200 Subject: [PATCH] nand-part: Avoid Linux-only ioctl() on other platforms The nand-part.c code tries to re-read the partition tables by issuing an ioctl(fd, BLKRRPART, NULL). This isn't available on non-Linux platforms, e.g. Mac OS X. Add preprocessor conditionals to prevent this from breaking the build. Signed-off-by: Bernhard Nortmann --- nand-part.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nand-part.c b/nand-part.c index e1640dc..a0d46c5 100644 --- a/nand-part.c +++ b/nand-part.c @@ -50,8 +50,10 @@ #include #include #include -#include -#include /* BLKRRPART */ +#ifdef __linux__ +# include +# include /* BLKRRPART */ +#endif #include "nand-common.h" // so far, only known formats are for A10 and A20 @@ -249,8 +251,10 @@ static int writembrs(int fd, char names[][MAX_NAME], __u32 start, __u32 *lens, u write(fd,mbr,MBR_SIZE); } +#ifdef __linux__ if (ioctl(fd, BLKRRPART, NULL)) perror("Failed rereading partition table"); +#endif return 1; } @@ -312,7 +316,9 @@ int nand_part (int argc, char **argv, const char *cmd, int fd, int force) if (writembrs(fd, names, start, lens, user_types, argc, partoffset, force)) { printf("\nverifying new partition tables:\n"); checkmbrs(fd); +#ifdef __linux__ printf("rereading partition table... returned %d\n", ioctl(fd, BLKRRPART, 0)); +#endif } } close(fd);