aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2016-04-18fix build warnings w/newer glibc & _BSD_SOURCEMike Frysinger
The _BSD_SOURCE define has been deprecated for a while now. Instead, code should be defining _DEFAULT_SOURCE. By defining both, it'll work with both new & old versions warning-free. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-04-18include sys/sysmacros.h for major/minor/makedevMike Frysinger
These functions have always been defined in sys/sysmacros.h under Linux C libraries. For some, including sys/types.h implicitly includes that as well, but glibc wants to deprecate that, and some others already have. Include the header explicitly for the funcs. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-01-26Makefile: install: don't look for scripts in BUILDDIRBrian Norris
Our ${SCRIPTS} (e.g., flash_eraseall) are not found in the build directory; they should be found in their original location. This fixes a typo in the Makefile refactoring, which caused 'make install' to fail with messages like: make: *** No rule to make target '[...my source-build directory...]/armv7a-cros-linux-gnueabi/misc-utils/flash_eraseall'. Stop. because the install target is looking in the wrong place for flash_eraseall. Fixes: 7d81790ced34 ("mtd-utils: Restructure the mtd-utils source.") Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
2016-01-24mkfs.ubifs: <sys/xattr.h>, not <attr/xattr.h>Brian Norris
To be consistent with mkfs.jffs2, and to get this to build on my machine, it looks like we should use <sys/xattr.h>, not <attr/xattr.h>. Fixes this error, seen on an Ubuntu 14.04 build system: ubifs-utils/mkfs.ubifs/mkfs.ubifs.c:30:24: fatal error: attr/xattr.h: No such file or directory #include <attr/xattr.h> ^ Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Reviewed-by: Richard Weinberger <richard@nod.at>
2015-12-09mkfs.ubifs: use gid from table instead 2x uidSebastian Andrzej Siewior
If the devtable is used then the tool uses uid twice and doesn't consider gid at all. This changes it to use gid & uid. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-17libmtd: mtd_read: Take the buffer offset into account when readingMarcus Prebble
Assuming the read() call does not return zero and the result is less than len, the current implementation will overwrite the data already read in buf which doesn't seem correct. With this patch, subsequent calls to read() within the loop will now no longer overwrite the existing contents of buf. Signed-off-by: Marcus Prebble <marcus.prebble@axis.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12flashcp: Use %llu to print filestat.st_sizeFabien Proriol
filestat.st_size type is off_t. For some paltforms, off_t can be 32 or 64bit but there is no C99 format specifier for off_t. The best way to print it with printf is to cast it to long long and print with %llu Signed-off-by: Fabien Proriol <fabien.proriol@jdsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12mkfs.ubifs: fix compiler warning for WITHOUT_LZODaniel Walter
Fix compiler warning about an unused variable. ubifs-utils/mkfs.ubifs/compr.c:41:27: warning: ‘c’ defined but not used [-Wunused-variable] static struct ubifs_info *c = &info_; Signed-off-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-12Fix scanf() formatstring for modern C versionDaniel Walter
mkfs.jffs2 is using an old assignment-allocation modifier for scanf(). Add a check so this modifier does not get confused with a float formatstring on newer C standard (C99 onwards). Signed-off-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12fix build when WITHOUT_LZO is setRolf Eike Beer
Make mkfs.ubifs honor the WITHOUT_LZO flag, too. Fixes this build error: mkfs.ubifs/compr.c:27:23: lzo/lzo1x.h: No such file or directory mkfs.ubifs/compr.c: In function `lzo_compress': mkfs.ubifs/compr.c:92: error: `lzo_uint' undeclared (first use in this function) mkfs.ubifs/compr.c:92: error: (Each undeclared identifier is reported only once mkfs.ubifs/compr.c:92: error: for each function it appears in.) mkfs.ubifs/compr.c:92: error: syntax error before "len" mkfs.ubifs/compr.c:95: error: `len' undeclared (first use in this function) mkfs.ubifs/compr.c:96: warning: implicit declaration of function `lzo1x_999_compress' mkfs.ubifs/compr.c:99: error: `LZO_E_OK' undeclared (first use in this function) mkfs.ubifs/compr.c: In function `init_compression': mkfs.ubifs/compr.c:201: error: `LZO1X_999_MEM_COMPRESS' undeclared (first use in this function) Signed-off-by: Rolf Eike Beer <eb@emlix.com> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: Optionally create extended attribute with inode numberSascha Hauer
This is done to allow creating images suitable for IMA directory appraisal. IMA creates a hash for directories and attaches this hash to the directory itself as an extended attribute. Among other things the inode numbers of the files are hashed. So, to create a valid hash in the UBIFS image the evmctl tool needs to know the inode numbers which the files in the UBIFS image will have. evmctl will read the inode numbers from the user.image-inode-number extended attribute. Since extended attributes are inodes themselves the inode numbers for the generated image will change when the extended attributes change, so to generate a correctly hashed UBIFS image, both evmctl and mkfs.ubifs must be run twice: 1) execute evmctl to iterate over the directory tree. This will create the security.ima and security.evm extended attributes. The existence of the attributes makes sure that subsequent calls to mkfs.ubifs will use the same inode numbers. evmctl will use the inode numbers from the host filesystem in this step which makes the resulting image unusable 2) execute mkfs.ubifs -a. This will create the user.image-inode-number extended attributes on files/directories added to the image. 3) execture evmctl again. This time evmctl will pick the inode numbers from the user.image-inode-number extended attribute instead of the ones from the host filesystem 4) execute mkfs.ubifs again. This will create the correct image. The now existing user.image-inode-number extended attributes are ignored and not added to the image. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: Add extended attribute supportSascha Hauer
This adds extended attribute support to mkfs.ubifs. When creating an image from a directory tree the existing extended attributes are added to the UBIFS image. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: simplify make_path with xasprintfSascha Hauer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: use xmalloc/xzalloc for allocating memorySascha Hauer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-12mkfs.ubifs: change add_directory argument to 'existing'Sascha Hauer
A 'non_existing' argument which is only used with !non_existing is just too confusing. Change this to positive logic. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
2015-11-11mtd-utils: Restructure the mtd-utils source.Dongsheng Yang
* There is no code modification in this commit, only moving * the files to proper place. The user tools looks a little messy as we place almost the all tools in the root directory of mtd-utils. To make it more clear, I propose to introduce the following structure for our source code. mtd-utils/ |-- lib |-- include |-- misc-utils |-- jffsX-utils |-- nand-utils |-- nor-utils |-- ubi-utils |-- ubifs-utils `-- tests Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: document block count == -1Brian Norris
These utilities have accepted -1 as a block count to mean "all blocks." Let's document that. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: don't allow "last byte + 1"Brian Norris
A lock/unlock/islocked ioctl() should be prevented from anything past the last byte, inclusive. But we were doing an exclusive check. This isn't a big deal, as the kernel MTD APIs would be guarding this anyway, but let's do this for completeness. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: improve strtol() error handlingBrian Norris
Use the simple_* helpers to improve error checking. Also fixup brace style at the same time. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: add MEMISLOCKED supportBrian Norris
With the -i / --islocked flags. Sample output: # flash_lock --islocked /dev/mtd0 Device: /dev/mtd0 Start: 0 Len: 0x400000 Lock status: unlocked Return code: 0 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: support both lock/unlock in the same binaryBrian Norris
Add new --lock/--unlock flags, so we can do either with the same binary. This will prepare for the addition of other features, so we don't have to keep duplicating the same binary via #include "flash_unlock.c". The defaults still work as expected: flash_unlock will default to REQUEST_UNLOCK, and flash_lock will default to REQUEST_LOCK. Eventually, we might deprecate one of the two (flash_unlock, probably), so we only have to ship one flash_{un,}lock binary. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: move args processing to its own functionBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: abstract the argument positionsBrian Norris
Previously, there were no options (besides stand-alone --help and --version), so we just used fixed-position argv indexes. Let's change that. Also clean up the sanity checks a bit to make them more verbose and specific. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: document option flagsBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: support --version flagBrian Norris
Just use the common helper macro. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: switch to getopt libraryBrian Norris
We will be adding some more flags, so the getopt library can help. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11flash_{un,}lock: nest optional parameters in help messageBrian Norris
block count should be nested within the optional offset listing. That is, we require offset before we accept a block count. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-11-11nandtest: support hex/dec/oct for --offset and --lengthBrian Norris
These two options are handled inconsistently, which caused an unnecessary amount of head scratching. Let's just use the simple helpers too, so we get the error handling right. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-10-01mtd-utils: serve_image: use proper POSIX_C_SOURCE valueKirill Smirnov
struct addrinfo and friends conform to POSIX.1-2001, not earlier. This patch fixes linking against latest glibc 2.22 Signed-off-by: Kirill Smirnov <kirill.k.smirnov@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-09-29mtd: tests: Fix endian issue with CRC generation algorithmPaul McGougan
The calculation of the CRC in /tests/checkfs/makefiles.c was writing the CRC Into the produced files in host byte-order which would cause CRC validation to fail on big-endian systems as the validation is performed bytewise. Signed-off-by: Paul McGougan <pmcgougan AT topcon.com> [Brian: add endian.h] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-09-29mtd-utils: ubinize: Always return error code (at least -1) in case of an errorEnrico Jorns
ubinize should not fail silenty, this can be very annoying when using it from other tools that rely on the exit code for determining the success of their operation. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-08-31don't include system headers in dependency filesBrian Norris
System library headers are not strictly part of our build. If they are changing beneath our feet, then we probably have bigger problems. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Suggested-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-08-28autogenerated dependency files are not being utilized properlyBrian Norris
TL;DR Acked-by: Mike Frysinger <vapier@gentoo.org> ===== Auto-generated dependency rules are not being written correctly, so changes to dependent files (e.g., headers) do not actually trigger rebuilds. The problem =========== It appears that when a dependency generation flag is passed directly to the preprocessor (with '-Wp,...'), it loses information about the output path. So, it just makes up the output name as $(basename).o, with no path information. This yields .*.c.dep files that look like this: flash_lock.o: flash_lock.c /usr/include/stdc-predef.h flash_unlock.c \ (...) and nanddump.o: nanddump.c /usr/include/stdc-predef.h /usr/include/ctype.h \ (...) include/libmtd.h This is the case for both in-tree *and* out-of-tree builds. Naturally, this is a problem for out-of-tree builds. But it is also a problem for in-tree builds, because we use rules like this for builds: $(BUILDDIR)/%.o: %.c and make doesn't recognize $(BUILDDIR)/%.o as the same as %.o even when $(BUILDDIR) == $(PWD). Example failures ================ ## Rebuilding after touching common header doesn't recompile anything $ make (...) $ touch include/libmtd.h $ make CHK include/version.h ## Same for out-of-tree builds $ BUILDDIR=test make (...) $ touch include/libmtd.h $ BUILDDIR=test make CHK include/version.h I noticed this when seeing that flash_lock would not get rebuilt when modifying flash_unlock.c (where 99% of the source code lies): $ make (...) $ touch flash_unlock.c $ make CHK include/version.h CC flash_unlock.o LD flash_unlock The fix ======= Just pass -MD straight to the compiler, and make sure to specify the output file for the dependency info with -MF. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-08-19ubifs: correct the size of nnode in memsetDongsheng Yang
There is a typo in lpt to memset nnode by the size in sizeof(stuct ubifs_pnode). Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-08-03make_a_release.sh: fix MTD spellingBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-24Release mtd-utils-1.5.2v1.5.2Brian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-24.gitignore: add new mtdpart utilityBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fix 'new blank line at EOF' problemsDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fix 'space before tab in indent' problemDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fix the trailing whitespace problemsDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: ubi-tests: fix a some overflowsDongsheng Yang
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Reviewed-by: Richard Weinberger <richard@nod.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-07-06mtd-utils: fs-tests: pass TEST_DIR to integck in run_all.shDongsheng Yang
Test integck requires a parameter but run_all.sh did no pass any to it. Then: integck: error!: test file-system was not specified (use -h for help) Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Reviewed-by: Richard Weinberger <richard@nod.at> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28mtd-utils: Add mtdpart to add/delete partitionNam T. Nguyen
Add a simple utility to exercise BLKPG ioctl. Signed-off-by: Nam T. Nguyen <namnguyen@chromium.org> Acked-by: Mike Frysinger <vapier@chromium.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28include/common.h: fix build against muslJörg Krause
Like uClibc version older than (not yet released) 0.9.34 musl does not have a rpmatch() implementation. uClibc defines both __UCLIBC__ and __GLIBC__. So first check for uCibc and its version and then for a non glibc implementation (like musl). Note, musl does not define __MUSL__. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28recv_image: do not include error.hJörg Krause
recv_image does not use anything from it and it is not available with all C libraries, e.g. musl. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28serve_image: do not include error.hJörg Krause
serve_image does not use anything from it and it is not available with all C libraries, e.g. musl. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28libmtd: fix comment typoBaruch Siach
Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28mtd-utils: libfec: use standard C type instead of u_longImre Kaloz
Fixes compilation on hosts with the musl C library. Also drops the unused u_short typedef. Signed-off-by: Imre Kaloz <kaloz@openwrt.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-05-28mkfs.ubifs: Fix build with gcc 5.1Bernhard Walle
In gcc 5.1, the default C standard which is used to compile a C file, has changed from gnu89 to gnu11. This changed the meaning of 'extern inline'. See https://gcc.gnu.org/gcc-5/porting_to.html. In mkfs.ubifs, this leads to multiple definitions of hashtable_iterator_key and -hashtable_iterator_value. I think the most pragmatic way to fix the issue is to replace 'extern inline' with 'static inline' here. Signed-off-by: Bernhard Walle <bernhard@bwalle.de> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-11-05mtd-utils: jffs2dump: XATTR and XREF support for endianess conversionTimo Warns
Add support for XATTR and XREF nodes to "convert image endianness" action of jffs2dump. Signed-off-by: Timo Warns <timo.warns@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>