Age | Commit message (Collapse) | Author |
|
If max_leb_cnt (-c option) is set too low, set_lprops() will corrupt
the heap and may result in a scary looking crash:
$ bin/mkfs.ubifs -U -r romfs -o ubifs.img -m 512 -e 15360 -c 39
Error: max_leb_cnt too low (241 needed)
*** glibc detected *** bin/mkfs.ubifs: double free or corruption (!prev): 0x088fe070 ***
======= Backtrace: =========
/lib32/libc.so.6(+0x6c231)[0xf75fb231]
/lib32/libc.so.6(+0x6dab8)[0xf75fcab8]
/lib32/libc.so.6(cfree+0x6d)[0xf75ffb9d]
bin/mkfs.ubifs[0x804e801]
bin/mkfs.ubifs[0x804e94b]
bin/mkfs.ubifs[0x804e99d]
/lib32/libc.so.6(__libc_start_main+0xe6)[0xf75a5bd6]
bin/mkfs.ubifs(__fxstat64+0x55)[0x80491e1]
======= Memory map: ========
08048000-0805d000 r-xp 00000000 08:08 10012045 /work/bin/mkfs.ubifs
0805d000-0805e000 rwxp 00015000 08:08 10012045 /work/bin/mkfs.ubifs
088fe000-08945000 rwxp 00000000 00:00 0 [heap]
f73e1000-f73fe000 r-xp 00000000 08:05 2228842 /usr/lib32/libgcc_s.so.1
f73fe000-f73ff000 r-xp 0001c000 08:05 2228842 /usr/lib32/libgcc_s.so.1
f73ff000-f7400000 rwxp 0001d000 08:05 2228842 /usr/lib32/libgcc_s.so.1
f7400000-f7421000 rwxp 00000000 00:00 0
f7421000-f7500000 ---p 00000000 00:00 0
f751c000-f758f000 rwxp 00000000 00:00 0
f758f000-f76e2000 r-xp 00000000 08:05 426288 /lib32/libc-2.11.1.so
f76e2000-f76e3000 ---p 00153000 08:05 426288 /lib32/libc-2.11.1.so
f76e3000-f76e5000 r-xp 00153000 08:05 426288 /lib32/libc-2.11.1.so
f76e5000-f76e6000 rwxp 00155000 08:05 426288 /lib32/libc-2.11.1.so
f76e6000-f76e9000 rwxp 00000000 00:00 0
f76e9000-f770d000 r-xp 00000000 08:05 426296 /lib32/libm-2.11.1.so
f770d000-f770e000 r-xp 00023000 08:05 426296 /lib32/libm-2.11.1.so
f770e000-f770f000 rwxp 00024000 08:05 426296 /lib32/libm-2.11.1.so
f772a000-f772c000 rwxp 00000000 00:00 0
f772c000-f772d000 r-xp 00000000 00:00 0 [vdso]
f772d000-f7749000 r-xp 00000000 08:05 6062081 /lib32/ld-2.11.1.so
f7749000-f774a000 r-xp 0001b000 08:05 6062081 /lib32/ld-2.11.1.so
f774a000-f774b000 rwxp 0001c000 08:05 6062081 /lib32/ld-2.11.1.so
ffb58000-ffb6d000 rwxp 00000000 00:00 0 [stack]
Aborted
New code aborts cleanly, and still calculates the number of LEBs
required:
$ bin/mkfs.ubifs -U -r romfs -o tmp/ubifs.img -m 512 -e 15360 -c 39
Error: max_leb_cnt too low (241 needed)
$ echo $?
255
$ bin/mkfs.ubifs -U -r romfs -o tmp/ubifs.img -m 512 -e 15360 -c 240
Error: max_leb_cnt too low (241 needed)
$ bin/mkfs.ubifs -U -r romfs -o tmp/ubifs.img -m 512 -e 15360 -c 241
$
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
When mkfs.ubifs is used with -r dir, it does not make the root UBIFS
inode uid/gid/permissions to be equivalent to dir's permissions, but
it makes root inode permissions to be equivalent to uid = git = 0
(root) and permissions = u+rwx go+rx.
Unfortunately, we cannot simply fix this bug, because mkfs.ubifs is
already used in production. Thus, we have introduce --squash-rino-perm
option which is the default and it preserves the old mkfs.ubifs
behavior. We also introduce --nosquash-rino-perm option which fixes
mkfs.ubifs behavior. If none of these options is used, we print a
warning. The plan is to make everyone use one of these options, then
make --nosquash-rino-perm to be the default and remove the warning,
and then eventually deprecate and remove both options.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
"nobad" might lead to the assumption that bad blocks are skipped, but this
option does exactly the opposite. Use a more descriptive name.
Reported-by: Jon Povey <Jon.Povey@racelogic.co.uk>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Sometimes dumping bad blocks is useful, like when the data isn't actually
bad but the OOB layout isn't what the kernel is expecting or is otherwise
screwed up. The --nobad option allows just that.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Nowhere in the nanddump code is the "ignoreerrors" variable used. So
drop the option completely.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Considering this is marked as "old" which is synonymous with "dead",
having the dir cause build failures because of warnings makes no
sense. So drop the -Werror usage.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Reformat the help text of ubiattach and ubidetach to display nicely on
80 column terminals, also fix a couple of bits that did not make sense.
Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Modify ubiattach and ubidetach to default to /dev/ubi_ctrl if not supplied
rather than requiring the user to type it in every time.
Also bump version from 1.0 to 1.1
Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
libcrc32.a was generated without external symbols: nm -g libcrc32.a shoed
nothing. This patch fixes it to make libcrc32.a build to be the same as
libmtd.a. Frankly, I do not know why this happened and why this patch fixes
the issue, sorry for my ignorance. But this works.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Because of namespace collisions mkfs.ubifs uses crc32() implementation from
/lib/libz.so.1, which generates incompatible CRC and later on the kernel reports
many CRC errors.
Fix this by re-naming mtd-utils' crc32 function to mtd_crc32.
Reported-by: Jon Povey <Jon.Povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Returning from main() instead of using exit() makes code more readable
and smaller (ARM EABI binary sizes)
text data bss dec hex filename
28882 436 44 29362 72b2 flash_eraseall
28827 432 44 29303 7277 flash_eraseall.noexit
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Hex dumps were being printed with the nybbles reversed since
commit 6ff458433ba15b8a7cb258ce64e64e98982df26e
Fix.
Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
CC: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Fixed several compiler warnings, mainly when compiling on 64-bit
architectures (where "size_t"-related types are not necessarily
32-bit).
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
"fileds" is "fields"
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
gcc 4.4.3 on x86_64:
libcrc32.c:42: warning: ‘static’ is not at beginning of declaration
libfec.c:120: warning: initialization discards qualifiers from pointer target type
libfec.c:121: warning: initialization discards qualifiers from pointer target type
libfec.c:417: warning: passing argument 2 of ‘my_malloc’ discards qualifiers from pointer target type
recv_image.c:164: warning: comparison of unsigned expression < 0 is always false
recv_image.c:170: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’
recv_image.c:170: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long unsigned int’
And many more along the same lines.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
ERASE/ERASE64 were tested on 2.6.18 and 2.6.31. OOB is untested.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This patch is based on Kevin Cernekee's patch posted to the MTD mailing
list. It adds 'mtd_read_oob()' and 'mtd_write_oob()' interfaces support.
The interfaces use MEMREADOOB64/MEMWRITEOOB64 MTD ioctls if possible, and
fall-back to MEMREADOOB/MEMWRITEOOB if the 64-bit versions are not supported.
The information about ioctls support is then cashed in 'offs64_ioctls'
libmtd flag.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This patch is base on Kevin Cernekee's patch posted to the MTD mailing
list. It adds MEMERASE64 support to the 'mtd_erase()' call. Now it
first tries to use MEMERASE64, and if that is not supported, falls
back to the old MEMERASE ioctl.
This patch also introduces an 'offs64_ioctl' flag to the libmtd
descriptor. However, we cannot initialize it in 'libmtd_open()',
because we need an MTD device node, which we do not have in
'libmtd_open()'. Thus, we firs mark this flag as "uninitialized",
and at the first invocation of 'mtd_erase()' we initialize it.
This also means that we have to pass the limbtd descriptor to
'mtd_erase()', to save the flag value. This, in turn, requires
tweaking 'mtd_erase()' users.
This is not very nice, but good enough so far.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Restrict binary dumping so that by default, binary garbage is not
printed directly to a terminal. Output redicted to files or piped to
other commands should not be affected (as judged by "isatty(ofd)").
A new flag "-a" or "--forcebinary" is included so that users can
override this behavior if necessary.
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Added the "-c" or "--canonicalprint" flag (modelled off 'hexdump -C')
so that users can choose to print ASCII output next to the prettyprint
output. This is really an extension to the prettyprint option, so the two
options do not conflict if they are both included in the same execution.
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Adapted code from the linux kernel hex_dump_to_buffer() (lib/hexdump.c)
to provide a more robust hexdump for the pretty option. Now, nanddump
can print out any size of OOB (or page for that matter...) without
having to worry about non-multiples of 16.
This also provides ability to dump ASCII format next to the hex output
once additional command-line flags are added.
Tested with Samsung K9GAG08U0D
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Replaced tabs with spaces in the help message for nandtest to
fix problems with varying indentation and to provide consistency
with other utils in the set.
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Changed "char*" to "const char*" in certain function argument lists
to prevent compiler warnings for passing a hard-coded string.
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Supported OOB and page sizes can now be changed more easily by a
macro constant. NAND_MAX_OOBSIZE needed increased to support 218
and 224 byte OOB.
Signed-off-by: Brian Norris <norris@broadcom.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
When '*dstlen' is 0 or 1, comparison will return wrong result. Reported
by valgrind as
==5919== Invalid write of size 1
==5919== at 0x40564E: jffs2_rtime_compress (compr_rtime.c:51)
==5919== by 0x40676B: jffs2_compress (compr.c:246)
==5919== by 0x403EE4: recursive_populate_directory (mkfs.jffs2.c:884)
==5919== Address 0x4e1bdb1 is 0 bytes after a block of size 1 alloc'd
==5919== at 0x4A0515D: malloc (vg_replace_malloc.c:195)
==5919== by 0x40671C: jffs2_compress (compr.c:229)
==5919== by 0x403EE4: recursive_populate_directory (mkfs.jffs2.c:884)
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Now include/common.h contains things that really everyone can use.
And all the stuff specific to ubi-utils is in ubi-utils/include/ubiutils-common.h
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Fix the following warning:
mkfs.ubifs.c: In function ‘add_dent_node’:
mkfs.ubifs.c:1172: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘ino_t’
mkfs.ubifs.c:1172: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 6 has type ‘ino_t’
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
My fault, forgot to run git add.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Source files for libmtd, crc32, and fec are scattered throughout the
tree. Move them to a central location so they can be built into a
common "libmtd.a" library used by all mtd-utils programs.
This patch only renames/deletes files and does not change the content.
Also modify the build system and source code so that libmtd.a can be built
from a "common" location (lib/). Statically link all utilities at the top
level with libmtd.a . Minor changes to mkfs.ubifs to allow using the common
crc32 implementation.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
... to make it clear that this is EC header, not VID header.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Add a common seed_random_generator() and make tests use it
for seeding the random generator.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Consistently use 'mtd_dev_node' to name variables consining
MTD device node path.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Let's consistently use 'mtd_num' name for MTD device number. At the
moment some code uses 'mtd_num', other 'dev_num'. Harmonize that.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
ubi-tests need it.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
To be consistent with other ubi libraries, move header comments
to the .h file.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Stop creating 128KiB and larger arrays on stack - allocate RAM
using malloc() instead.
This patch also teaches libubigen to always set errno.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Add another helper interface which can be used to write an image
to an mtd device.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Just like we have in ubi-utils.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Just like we do in ubi-utils.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
For consistency with ubi-utils.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Add an 'mtd_num' field to the UBI device information structure.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Remove the 'dev_major' and 'dev_minor' fields from the volume
information structure, because these fields should be provided
by the device information structure.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Add support for oobsize 64 and writesize 4096 in nanddump & nandwrite.
Artem: some more info from further e-mail exchange:
> Are there flashes with the 4096 page / 64 spare combination? Could you
> refer to one? May be any URL? I thought 4096 comes with 128.
Much to my regret I can't provide a URL because is not public. IGEP v2
board has a Onenand with two dice of 2048/64 spare combination but mtd
views 4096/64. The minimal write page is 4K (2K from first dice and 2K
from second dice).
Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Only page-aligned address is permitted in NAND subsystem.
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The tool mkyaffs2image doesn't know the oob layout of a NAND flash, so it
puts the yaffs2 tags at the offset 0 of oob area, as a result, the image
generated by mkyaffs2image is different with the image dumped by nanddump.
Now adding a parameter "-r" for nandwrite to differentiate these images.
Write a image generated by mkyaffs2image:
$> nandwrite -a -o /dev/mtd3 yaffs2.bin
Write a image dumped by nanddump:
$> nandwrite -a -r /dev/mtd3 image.bin
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|