Commit ed94fc2f authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

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: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent 73c20eea
...@@ -50,8 +50,10 @@ ...@@ -50,8 +50,10 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #ifdef __linux__
#include <sys/mount.h> /* BLKRRPART */ # include <sys/ioctl.h>
# include <sys/mount.h> /* BLKRRPART */
#endif
#include "nand-common.h" #include "nand-common.h"
// so far, only known formats are for A10 and A20 // 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 ...@@ -249,8 +251,10 @@ static int writembrs(int fd, char names[][MAX_NAME], __u32 start, __u32 *lens, u
write(fd,mbr,MBR_SIZE); write(fd,mbr,MBR_SIZE);
} }
#ifdef __linux__
if (ioctl(fd, BLKRRPART, NULL)) if (ioctl(fd, BLKRRPART, NULL))
perror("Failed rereading partition table"); perror("Failed rereading partition table");
#endif
return 1; return 1;
} }
...@@ -312,7 +316,9 @@ int nand_part (int argc, char **argv, const char *cmd, int fd, int force) ...@@ -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)) { if (writembrs(fd, names, start, lens, user_types, argc, partoffset, force)) {
printf("\nverifying new partition tables:\n"); printf("\nverifying new partition tables:\n");
checkmbrs(fd); checkmbrs(fd);
#ifdef __linux__
printf("rereading partition table... returned %d\n", ioctl(fd, BLKRRPART, 0)); printf("rereading partition table... returned %d\n", ioctl(fd, BLKRRPART, 0));
#endif
} }
} }
close(fd); close(fd);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment