mirror of
https://github.com/linux-sunxi/sunxi-tools.git
synced 2024-11-27 03:44:22 +08:00
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 <bernhard.nortmann@web.de>
This commit is contained in:
parent
73c20eea7b
commit
ed94fc2fd4
10
nand-part.c
10
nand-part.c
@ -50,8 +50,10 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mount.h> /* BLKRRPART */
|
||||
#ifdef __linux__
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/mount.h> /* 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);
|
||||
|
Loading…
Reference in New Issue
Block a user