More recent versions of GCC warns about the usage of strncpy in
nandpart.c: we actually only (need to) copy the stub string part of the
magic string, without the terminating NUL character. This is fine in
our particular case, but raises the compiler's eyebrows:
===================
nand-part.c: In function '_get_mbr':
nand-part.c:93:4: warning: 'strncpy' output truncated before terminating
nul copying 8 bytes from a string of the same length
[-Wstringop-truncation]
93 | strncpy((char *)mbr->magic, MBR_MAGIC, 8);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
===================
Switch to the more fitting memcpy() here to avoid the warning.
Signed-off-by: Andre Przywara <osp@andrep.de>
Reported-by: slange-dev
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>
Build one nand-part program to handle both A10 and A20 mbr header formats.
Changed -f option to take an "a10" or "a20" argument to specify which mbr
format to force.
Signed-off-by: Patrick Wood <patrickhwood@gmail.com>
A20 boot1 checks the MBR magic string but not the version, but let's
check it anyway (can always force now with the -f option if the version
isn't 0x200 on the system)
allow setting of partition 1 size/offset
if -f option is used, force writing of MBR header, even if CRC or
header magic/version are incorrect (for recovery only)
ignore user_type in android nand MBR; these can be other than 0 or 2
contrary to Allwinner's expectations
allow the user to set the user_type from the command line
(optional -- backwards compatible with existing usage