aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2010-10-01mtd-utils: dont redefine MIN()Mike Frysinger
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>
2010-10-01mkfs.jffs2: convert to common.h helpersMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-01libmtd: fix "fount" typoMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-01mtd-utils: sys_errmsg: optimize indentationMike Frysinger
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>
2010-10-01mtd-utils: introduce xzalloc() helperMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-01mtd-utils: enable garbage collection of unused function/data sectionsMike Frysinger
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>
2010-09-30mkfs.jffs2: use new xasprintf() helperMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-30mtd-utils: add xasprintf() helperMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-30mtd-utils: new memory wrappersMike Frysinger
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>
2010-09-28ubi-utils: remove old ubi-utilsArtem Bityutskiy
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>
2010-09-28mtd-utils: Use $(CURDIR) in place of $(PWD)Kevin Cernekee
$(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>
2010-09-27mtd-utils: unify flash_erase and flash_eraseallMike Frysinger
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>
2010-09-27mtd-utils: new strtoX helpersMike Frysinger
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>
2010-09-27mtd-utils: common.h: clean up PROGRAM_NAME usageMike Frysinger
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>
2010-09-27recv_image: fix __USE_GNU hackMike Frysinger
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>
2010-09-27ubi-utils: tweak const strings declsMike Frysinger
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>
2010-09-27compr_rtime: fix unused warningMike Frysinger
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>
2010-09-27mtd-utils: standardize PROGRAM_NAMEMike Frysinger
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>
2010-09-25nandwrite: Remove redundant 'autoplace' checkShinya Kuribayashi
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>
2010-09-25mtd-utils: new bareverbose() helperMike Frysinger
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>
2010-09-25libmtd: add lock/unlock helpersMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-24mkfs.ubifs: use common ARRAY_SIZEMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-24mtd-utils: punt duplicate normsg_cont defineMike Frysinger
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>
2010-09-24mtd-utils: convert to common.h/minMike Frysinger
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>
2010-09-24libmtd: unify erase block argument checkingMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-24nandwrite: add --skipbad to write bad blocksMike Frysinger
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>
2010-09-24mkfs.ubifs: Fix --squash-rino-perm / --nosquash-rino-permKevin Cernekee
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>
2010-09-23libfec: fix up pointer warnings in fec magic computationMike Frysinger
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>
2010-09-23mtd-utils: compr: drop unused model argumentMike Frysinger
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>
2010-09-23compr_zlib: mark local functions as staticMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-23ftl_check: drop unused verbose flagMike Frysinger
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>
2010-09-23mtd-utils: clean up zlib.h usage a bitMike Frysinger
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>
2010-09-23rbtree: avoid redefining offsetofMike Frysinger
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>
2010-09-23mkfs.ubifs: Fix heap corruption on LEB overrunKevin Cernekee
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>
2010-09-23mkfs.ubifs: do not override root inode permissionsArtem Bityutskiy
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>
2010-09-18nanddump: rename --nobad to --noskipbadv1.4.0Wolfram Sang
"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>
2010-09-12nanddump: add --nobad to read bad blocksMike Frysinger
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>
2010-09-12nanddump: drop unused --ignoreerrors optionMike Frysinger
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>
2010-09-12ubi-utils: drop -Werror in old utilsMike Frysinger
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>
2010-09-02ubi-utils: reformat help text to fit in 80 columnsJon Povey
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>
2010-09-02ubi-utils: provide default value for /dev/ubi_ctrlJon Povey
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>
2010-09-01lib: fix libcrc32 generationArtem Bityutskiy
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>
2010-09-01rename crc32 to mtd_crc32Artem Bityutskiy
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>
2010-08-30flash_eraseall: tweaks to make binary size smallerLadislav Michl
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>
2010-08-30nanddump: Fix hexdump nybble orderingJon Povey
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>
2010-08-30mtd-utils: fix compiler warningsBrian Norris
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>
2010-08-30mtd-utils: fix spelling errorBrian Norris
"fileds" is "fields" Signed-off-by: Brian Norris <norris@broadcom.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-30mtd-utils: clean up compile warningsKevin Cernekee
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>
2010-07-26mtd: change flash_eraseall to use libmtd-wrapped ioctlsKevin Cernekee
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>
2010-07-26libmtd: add OOB read and write interfacesArtem Bityutskiy
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>