summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* mtd-utils: remove whitespace at end of linesBrian Norris2011-06-291-7/+7
| | | | | | Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
* rewrite build system to avoid recursionMike Frysinger2011-06-271-22/+0
| | | | | | | | | | | | | | | | | | | | | | | The ubi-utils/src/ subdir is tossed as it just complicates things for no real gain. The dictionary.h header is relocated to the ubi-utils/include/ since other headers in there need it. The top level clean is replaced with a `find -delete` on objects, so it might prune more than necessary, but many projects now do this sort of thing and no one complained there. A "mkdep" helper generates the actual rule, and the variables are used with "foreach" to expand these automatically. The tests subdir is updated only to reflect the ubi-utils source move. Otherwise, it is left untouched as making that non-recursive isn't really worth the effort. While we're gutting things, also through in kbuild style output while building to make things more legible. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
* punt redundant libcrc32v1.4.5Mike Frysinger2011-06-251-3/+2
| | | | | | | | | The libcrc32.a is only used in one place: mkfs.ubifs. But this also uses libmtd.a, and the only file in libcrc32.a is also in libmtd.a. So libcrc32.a itself is completely redundant. Punt! Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: improve mtd_islocked interfaceArtem Bityutskiy2011-06-081-2/+11
| | | | | | | | | | | | | | | | | | This patch first of all, re-names 'mtd_islocked()' into 'mtd_is_locked()' since this seems to be the name Mike wanted, and it looks a bit nicer. This patch also makes 'mtd_is_locked()' print an error message if it fails. I'm not sure if it is good idea for a library to do so, but all functions do this, so it certainly _not_ a good idea to be inconsistent. However, for the special case, when the the "is locked" ioctl is not supported or is not valid for this device, we do not print an error message and return ENOTSUPP error code. Thus, the user can distinguish between real errors and non-fatal "not supported" cases. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: add helper funcs for getting regioninfo and locked infoMike Frysinger2011-06-081-0/+27
| | | | | | | | | | | | | This extends the libmtd with the helper functions: mtd_regioninfo: interface to MEMGETREGIONINFO mtd_islocked: interface to MEMISLOCKED Users of these functions will follow shortly ... Artem: do not print error message in mtd_islocked() Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: use O_CLOEXECMike Frysinger2011-06-071-5/+5
| | | | | | | | Not strictly necessary, but this is good library behavior and should carry no runtime overhead. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: use PRIu64 classifier for uint64_t printf argumentsAndy Shevchenko2011-04-211-16/+11
| | | | | | Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: fix OOB read and write interfacev1.4.4Artem Bityutskiy2011-04-011-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | When reading and writing OOB we specify the address as absolute offset from the beginning of the MTD device. This offset is basically an absolute page offset plus the OOB offset. And it does not have to be aligned to the min. I/O unit size (NAND page size). So fix the 'do_oob_op()' function and remove incorrect checking that the offset is page-aligned. This check leads to the following errors: libmtd: error!: unaligned address 2, mtd0 page size is 2048 But obviously, the intent was to write to offset 2 of the OOB area of the very first NAND page. Instead of that incorrect check, we should check that the OOB offset we write to is within the OOB size and the length is withing the OOB size. This patch adds such check. Reported-by: Kelly Anderson <kelly@silka.with-linux.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Tested-by: Kelly Anderson <kelly@silka.with-linux.com>
* libmtd: fix OOB size initialization in legacy codeKetil Froyn2010-11-291-0/+1
| | | | | | | legacy_get_dev_info() forgot to set the OOB size Signed-off-by: Ketil Froyn <ketil@froyn.name> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: make malloc failures fatalMike Frysinger2010-10-022-27/+7
| | | | | | | | | 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>
* sumtool/libfec: convert "()" to "(void)" in func defsMike Frysinger2010-10-021-3/+3
| | | | | | | | | | 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>
* libmtd: unify some error messagesMike Frysinger2010-10-011-13/+14
| | | | | | | | 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>
* libmtd: fix "fount" typoMike Frysinger2010-10-011-5/+5
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: add lock/unlock helpersMike Frysinger2010-09-251-0/+32
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libmtd: unify erase block argument checkingMike Frysinger2010-09-241-36/+32
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* libfec: fix up pointer warnings in fec magic computationMike Frysinger2010-09-231-3/+4
| | | | | | | | | | 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>
* lib: fix libcrc32 generationArtem Bityutskiy2010-09-011-0/+1
| | | | | | | | | 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>
* rename crc32 to mtd_crc32Artem Bityutskiy2010-09-011-1/+1
| | | | | | | | | | | 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>
* mtd-utils: fix compiler warningsBrian Norris2010-08-301-2/+2
| | | | | | | | | 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>
* mtd-utils: clean up compile warningsKevin Cernekee2010-07-302-4/+4
| | | | | | | | | | | | | | | | | | | | 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>
* libmtd: add OOB read and write interfacesArtem Bityutskiy2010-07-261-0/+95
| | | | | | | | | | | | 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>
* libmtd: support MEMERASE64Artem Bityutskiy2010-07-262-6/+70
| | | | | | | | | | | | | | | | | | | | | 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>
* libs: make crc32 and fec to be librariesArtem Bityutskiy2010-07-173-4/+13
| | | | Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* Add forgotten MakefileArtem Bityutskiy2010-07-171-0/+22
| | | | | | My fault, forgot to run git add. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
* mtd-utils: move libmtd source files to lib/ subdirectoryKevin Cernekee2010-07-135-0/+2603
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>