Age | Commit message (Collapse) | Author |
|
Check the first block even when start_addr is not eraseblock aligned.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
When dumping oob data of a bad block, initialize oobbuf with 0xff, instead of
readbuf. This avoids bogus oob data on output.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
This converts libmtd to the common xalloc helpers and in doing so, makes
memory allocation failures fatal rather than returning an error to the
caller. I think this is acceptable behavior.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Since these functions take no parameters, declare them as such. The
subtle difference here is that gcc allows (without warning) people to
accidentally call funcs declared with "()" with arguments. Using void
makes sure that gcc will reject such typos at compile time.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
By using the same error message string, we only need one copy of it
in memory at runtime.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
I'm not sure that if we actually are out of memory that declaring the
failing allocation size is useful in the output. So use the same
simple string in every error message to cut down on size (there will
only be one copy of this at runtime). Size is a much more common
concern than handling OOM issues which most likely aren't the fault
of mtd-utils in the first place.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Some C library headers will define MIN(), so add an #ifndef check.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Rather than do a for loop and output 1 space at a time, let the printf
code take care of indenting the string based on the constant length.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
On my default build, this cumulatively shaves off ~100KiB of unused
code and data from the mtd-utils programs.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The mkfs.jffs2 program has local wrappers for memory related functions
that are useful beyond mkfs.jffs2, so break them out into a common header.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The utilities are unmaintained for long time, and many of them
do not even work, just compile, and no on complains about this.
This suggests they are unused and we can now safely kill them.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
$(PWD) comes from the shell and may cause unexpected side effects when
using "make -C".
$(CURDIR) is defined internally by GNU make.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
These have overlapping functionality, and while flash_eraseall supports
newer 64bit ioctls, flash_erase does not. So rather than graft support
onto flash_erase, merge the functionality of two into flash_erase so we
only have to support one util from now on.
A simple wrapper is provided to ease old flash_eraseall users into the
new combined flash_erase util.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Simply usage of converting strings to numbers by adding some wrappers
around the standard strtoX functions. These helpers simplify the api
of these functions a bit by providing an optional "error" pointer and
automatic error message.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Make PROGRAM_NAME required in order to include common.h so we can rely
on it existing.
Further, stop embedding PROGRAM_NAME in every error message so that we
can save string space with it being declare only once.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The __USE_GNU define is an internal define that source code should never
be touching. So switch it to the proper exported _BSD_SOURCE define.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Shrink the data size a little by declaring addresses of constant strings
instead of pointers to it.
Also slip in static & const on long_options missing them.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The rtime logic causes gcc to emit an unused warning about srclen, so
mark it with an unused attribute to shut it up.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Make sure all the utils define PROGRAM_NAME and do so at the start of
the file so that sub-headers may assume it exists.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
We're already in 'if (autoplace) { }' block at ths moment.
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Add a new helper that lets people do simple verbose output without any
implicit strings added around it. Good for progress bars and such.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Looks like someone copied & pasted it twice by accident.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Kill off duplicated min() defines and convert to the common.h one.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
Sometimes dumping bad blocks is useful, like when the block isn't actually
bad but the OOB layout isn't what the kernel is expecting or is otherwise
screwed up. The --skipbad option allows just that.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This addresses a couple of issues:
1) Code was only allowing these options if --root was NOT specified (the
opposite of the documented usage)
2) -q / -Q short options did not work
3) Spacing fixes in the error/warning strings
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The current fec code casts a pointer to an int which causes warnings on
64bit systems. So create a macro for the duplicate/complicated magic
computation, and add an unsigned long cast in it to fix the original
problem.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The jffs2 compression framework provides a "model" argument when
compressing and decompressing, but the caller always passes in NULL
and the callees never use it. So punt this useless overhead.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
The verbose flag isn't actually checked anywhere, so punt it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Hide zlib's crc32 in compr_zlib.c and mkfs.ubifs/compr.c.
jffs2reader.c and mkfs.jffs2.c don't actually use zlib, so punt the
include from the file.
mkfs.jffs2.c is implicitly using crc32 from zlib.h instead of the
local mtd_crc32, so fix the local usage. otherwise we get warnings
about undefined crc32 because the file was redirecting the prototype.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Newer versions of gcc will define & export offsetof, so we don't
want to unconditionally define it. Otherwise we hit:
In file included from mkfs.jffs2.c:76:0:
rbtree.h:134:0: warning: "offsetof" redefined
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.1/include/stddef.h:411:0: note:
this is the location of the previous definition
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
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>
|