20 Commits

Author SHA1 Message Date
Andre Przywara
6a9bde9d34 nandpart: fix strncpy compiler warning
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
2022-01-13 23:56:04 +00:00
Bernhard Nortmann
ed94fc2fd4 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>
2016-05-03 08:03:11 +02:00
Patrick Wood
5d0ee5037b nand-part: create one nand-part program to handle both A10 and A20
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>
2013-09-19 02:24:25 +02:00
Pat Wood
c20d395d59 set MBR_MAGIC to "softw411" and MBR_VERSION to 0x200 in nand-part-a20.h
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)
2013-07-23 14:51:35 -04:00
Pat Wood
3413153e6e check that starting offset of partition 1 is beyond MBR area 2013-07-23 01:44:23 -04:00
Pat Wood
762d32a929 print out correct number of partitions 2013-07-23 01:19:20 -04:00
Pat Wood
653ae97b0c display partition numbers starting at "1" instead of "0"; corresponds to
command usage and partition numbering in linux nand driver
2013-07-23 01:01:37 -04:00
Pat Wood
606c0688d3 added backwards compatibility with older version of nand-part: if the starting
offset of partition 1 isn't specified, switch to old argument syntax that retains
partition 1 values
2013-07-23 00:58:20 -04:00
Pat Wood
dd94a2f117 build both A10 and A20 nand-part executables
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)
2013-07-23 00:42:19 -04:00
Pat Wood
1dfa8cf006 Merge branch 'master' of git://github.com/linux-sunxi/sunxi-tools
Conflicts:
	nand-part.c
2013-06-27 23:07:42 -04:00
Michal Suchanek
c66667ff52 nand-part: Reject wrong partition version.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
2013-06-24 23:06:14 +02:00
Michal Suchanek
f1eca9d438 nand-part: Add mbr parsing diagnostics.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
2013-06-24 23:06:14 +02:00
Henrik Nordstrom
a95d7e1896 nand_part: Reduce duplicated code a bit 2013-05-15 11:08:27 +02:00
Pat Wood
5f258215b8 Merge branch 'master' of git://github.com/linux-sunxi/sunxi-tools
Conflicts:
	nand-part.c
2013-03-02 00:23:54 -05:00
Michal Suchanek
033706af8a nand-part: Tell kernel to reread partition table after writing it. 2013-03-01 19:26:11 +00:00
Pat Wood
d223f7de83 cosmetic change: got rid of "if (1 || ...)" tests and enclosing blocks 2013-02-17 16:33:33 -05:00
Pat Wood
6fd7957e17 sends the nand driver a BLKRRPART via ioctl; depends on kernel mods
that allow on-the-fly repartitioning of the nand
2013-02-17 15:10:11 -05:00
Patrick Wood
5c9e55e16d nand-part: ignore user_type in android nand MBR
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
2013-02-15 20:58:16 +00:00
Pat Wood
c058922c46 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
2013-02-04 01:21:40 -05:00
Alejandro Mery
c7ea2b6e08 nand-part: rename mbr to a more meaningful name 2012-08-06 23:56:02 +00:00