aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2014-04-15include/common.h: fix build against current uClibcBaruch Siach
Commit dbe0fd17f2 (mtd-utils: new prompt() helper for talking to the user) introduced a rpmatch() call. However, uClibc versions older than (not yet released) 0.9.34 don't have rpmatch() implementation. Add one. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
2014-04-07make_a_release.sh: suggest announcement e-mailArtem Bityutskiy
The 'make_a_release.sh' script appears to be extremely useful - I do not forget things as I used to anymore (amending Makefile, signing, uploading to the FTP server, etc). It is very useful that it suggest me exact commands which I may just copy-past to my command line. This patch improves the script and makes it suggest the e-mail announcement which I may just copy-paste to my command line and the announcement will be sent using 'git send-email' command. It will include all the interested parties in CC. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-04-07Release mtd-utils-1.5.1v1.5.1Artem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-04-07ubiformat: correct "non-ubifs" warning messageBrian Norris
UBI's raw flash scan actually scans for UBI data, not UBIFS data (there *are* UBI users that are not UBIFS!), so correct the warning message. This also matches the comment in libscan.h. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-03-31ubi-utils: Fix file descriptor leaks in libubiDaniel van Gerpen
Amended by Artem. Signed-off-by: Daniel van Gerpen <daniel@vangerpen.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-03-31mkfs.ubifs: correct and improve LEB size error printsBrian Norris
The error message is incorrect for "too small LEB size" -- we were printing the minimum I/O size instead of the LEB size. At the same time, let's print the max LEB size along with the message for "too large LEB size", to be consistent and more helpful. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2014-03-25ubi-utils: Add ubiblock toolEzequiel Garcia
With the addition of block device access to UBI volumes, we now add a simple userspace tool to access the new ioctls. Usage of this tool is as simple as it gets: $ ubiblock --create /dev/ubi0_0 will create a new block device /dev/ubiblock0_0, and $ ubiblock --remove /dev/ubi0_0 will remove the device. Artem: slightly changed the header comment. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-10-26mtd-utils: Makefile: add LDFLAGS_mkfs.ubifsAaron Sierra
The build rule for mkfs.ubifs was missing an LDFLAGS_* variable like mkfs.jffs2 had. This prevented mkfs.ubifs from being built against explicit external libraries which is needed when cross-compiling. This also adds UUIDCPPFLAGS and UUIDLDFLAGS variables to support the mkfs.ubifs build. Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
2013-10-24flash_erase: check the nand typeHuang Shijie
Now, the MTD_NANDFLASH stands for SLC nand, and the MTD_MLCNANDFLASH stands for the MLC nand. This patch includes the stdbool.h, and changes the "isNAND" to boolean type, and checks the right nand type for the MLC and SLC nand. If the user wants to format a MLC nand for JFFS2, we will print out a message to warn him, and exit right now. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-10-22check the MLC nand typeHuang Shijie
In the current code, the MTD_NANDFLASH stands for both the SLC and MLC. In the kernel, the MTD_NANDFLASH only stands for the SLC now, so in order to keep the logic unchanged, we should also check the MLC NAND by MTD_MLCNANDFLASH. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-10-22flash_otp_write: use helper to check the nandHuang Shijie
Use the mtd_type_is_nand_user() helper to check if it is a NAND (including SLC/MLC). Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-10-22mtd: mtd-abi: add a helper to detect the nand typeHuang Shijie
The helper is for user applications, and it is just a copy of the kernel helper: mtd_type_is_nand(); Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-10-22add the MTD_MLCNANDFLASH caseHuang Shijie
The MTD_MLCNANDFLASH case is missed in the current code. This patch adds it. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-07-01ubiupdatevol: add a --skip optionMike Frysinger
This already has a --size option for controlling how many bytes to read from the input. Add a --skip option to control the offset into the input too. This way people don't have to do `dd | ubiupdatevol`. While we're here, I've fixed the types used with args.size and the read loop so that they can hold the right sizes (like setting a 32bit+ size). Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01nandwrite: amendment to Mike's --input-* seriesArtem Bityutskiy
This is a delta between v1 and v2 of the patches. I pushed v1 instead of picking v2, and this is a fixup. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01nandwrite: add --input-{skip,size} optionsMike Frysinger
If you have a file image and want to copy sub-portions out and into NAND, there's no easy way to do that. You can use dd to extract it to a temp file, or pipe it to nandwrite 1 page at a time. Both suck. Add two new flags to explicitly set the size and offset of the input file. Seeking stdin isn't currently supported as I'm not sure it's necessary. It wouldn't be hard to add though... Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01nandwrite: clean up length typesMike Frysinger
We use 'int' in many places to represent offsets/sizes. That obviously does not play well with larger NAND devices on 32bit systems. Instead, use the right type as needed: - long long to represent the length of the image - use fstat() rather than lseek();lseek(); to get the length of the image - use size_t/ssize_t when working with read() - tweak the printf formats as needed Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01nand{dump, test, write}: clean up --help handlingMike Frysinger
We should send the output to stdout when the user passes -h/--help and then exit(0), but otherwise the output should go to stderr and then exit(1). Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01use xstrdup in a few more placesMike Frysinger
These call sites either assume there is no failure (they deref the pointer right away), or the exit themselves. Use xstrdup() instead. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01mkfs.ubifs: allow reformatting of devicesMike Frysinger
Sometimes I want to re-initialize an existing ubifs, but the tool currently bails out if the volume is already formatted. Prompt the user instead so they can decide. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01mtd-utils: new prompt() helper for talking to the userMike Frysinger
We've got a few tools that prompt the user for "yes/no" questions. Add a common helper to simplify the various implementations. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01move _GNU_SOURCE to the main makefileMike Frysinger
A bunch of utils are relying on _GNU_SOURCE already. The new prompt code uses getline() which is now part of POSIX, but in older versions of glibc, it was behind _GNU_SOURCE as it was a GNU extension. This change doesn't actually tie us to glibc. Only code that uses GNU extensions does that. It just kills warning when using older versions of glibc. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01fix build errors w/newer kernel headers & glibcMike Frysinger
Building with linux-headers-3.9 and glibc-2.17 fails like so: In file included from summary.h:15:0, from jffs2dump.c:37: /usr/include/linux/uio.h:16:8: error: redefinition of 'struct iovec' struct iovec ^ In file included from /usr/include/bits/fcntl-linux.h:38:0, from /usr/include/bits/fcntl.h:61, from /usr/include/fcntl.h:35, from jffs2dump.c:25: /usr/include/bits/uio.h:43:8: note: originally defined here struct iovec ^ Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-07-01ftl_check/ftl_format/nftldump: use existing mtd_swab.h headerMike Frysinger
We already have a helper header for swapping bytes as needed, so cut the ftl tools over to that rather than re-implement things. I don't actually have any devices with this kind of flash, so I can't runtime test it. But things *look* ok to me :). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-07-01ubinize: fix usage textMike Frysinger
Drop duplicate "and the", and tweak grammar slightly. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-05-29flash_erase: use pwrite() rather than lseek() && write()Mike Frysinger
Saves a syscall. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck: fix identation a bitArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11Typo fixes: avaiable -> available and priortiry -> priorityElie De Brauwer
Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck.c: Fix buffer overflow in save_fileElie De Brauwer
In the problem above I've spend several hours waiting for the issue to appear, only to had the 'luck' that it was found in a file whose name was 256 bytes in length, resulting in the write to fail. Closer examination showed that the buffer to store the path was 256 bytes in length, but this buffer also includes /tmp and the read/write suffix and should be able to contain a filename which is up to 255 bytes (NAME_MAX in linux/limits.h) in size which is a bad fit. So that array is modified to FILENAME_MAX (stdio_lim.h) and some checking is added to truncate the filename should it cause an overflow. The following log shows the first patch in action (see the correct seed), and shows why this third patch is needed: <quote> integck:     File Data: integck:         Offset: 0  Size: 1  Seed: 5008310  R.Off: 0 integck:     1 writes integck:     ============================================ integck:     Write Info: integck:         Offset: 0  Size: 1  Seed: 5008310  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 8246352  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 5078796  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 2267087  R.Off: 0 integck:         Offset: 0  Size: 1  Seed: 3602680  R.Off: 0 integck:     5 writes or truncations integck:     ============================================ integck: Saving /tmp/yqcnfygfitaatyeyvffrguegcdttamcnyhowhgieljfuxfipiljsjcbluaeaghwyinkggommsbwnmvekihgnwgiibccpbwfrpxuxwkmnyghnutrudienngxwgorudbskedaaekiuiyqksfazrwzfwbfhzjjqoiulebtlpbfiuffmsnguqkjzqjqizimsmhbqqagaebjdhqwmzdxghiavtcxubegawlgtvstuqurkurpnrckjfkgostdtpg.integ.sav.readn integck: error!: condition 'w_fd != -1' failed in save_file() at integck.c:1445 integck: error 36 (File name too long) </quote> Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck.c: rework file_check_data to immediately dump the buffer containing ↵Elie De Brauwer
the errors See my problem description int the previous commit, the point is that integck in file_check_data reads a buffer, and then checks if the data is correct,  it will do a seek(0), and reread from the same fd. The point is that in the scenario I observed integck failed (due to a buffer mismatch) but the it saved (and what was in flash) was actually correct. So I modified this function to dump the buffers to stderr at the moment an error is found. Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11integck.c: Only verify the operation after all datastructures have been updatedElie De Brauwer
<quote> integck: File Data: integck: Offset: 0 Size: 196 Seed: 5999877 R.Off: 0 integck: Offset: 196 Size: 33 Seed: 4160795 R.Off: 0 integck: Offset: 229 Size: 1252 Seed: 8070052 R.Off: 0 integck: Offset: 1481 Size: 612 Seed: 4160795 R.Off: 1285 integck: Offset: 2093 Size: 6 Seed: 6946586 R.Off: 0 integck: Offset: 2099 Size: 536 Seed: 4160795 R.Off: 1903 integck: Offset: 2635 Size: 1562 Seed: 9845455 R.Off: 0 integck: Offset: 4197 Size: 80 Seed: 702818 R.Off: 0 integck: Offset: 4277 Size: 115 Seed: 9845455 R.Off: 1642 integck: 9 writes integck: ============================================ integck: Write Info: integck: Offset: 826 Size: 357 Seed: 5908448 R.Off: 0 integck: Offset: 4197 Size: 80 Seed: 702818 R.Off: 0 ... </quote> And I would expect the file data listing to include at offset 826 something with a size of 357 and a seed of 5908448. Clearly it is not there (which is already extremely confusing). The point is that file_write_info first updates the raw_write, then verifies the data (passing the new write) and only after that updates the write structure. But in file_check_data only the newly written data is verified (passed as an argument) whilst the save_file() function to dump the file uses the raw_writes to recreate the written data (while raw_writes is only updated after after this check would have succeeded). Several lines to say that in this patch the verify only gets called _after_ the datastructures are updated. Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11flash_otp_write: fix a buffer overflow on NAND with write size > 2048Uwe Kleine-König
I'm not aware of any chip having a write size bigger than 2048 today. Still checking for that instead of a sleeping problem to bite us maybe in a few years is easy. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-11flash_otp_write: fix writing to NAND in presence of partial readsUwe Kleine-König
When doing something like: { printf "\xff"; printf "\xfe"; } | flash_otp_write -u /dev/mtd0 0 flash_otp_write might see only a single byte when reading from stdin for the first tim. In this case (and without this patch) it pads to $writesize with '\xff's and writes that out. In the next iteration it reads the 2nd byte, pads and writes again. So the 2nd byte is written to offset $writesize instead of 1. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-03-06Makefile: also build and install flash_otp_lock and flash_otp_writeUwe Kleine-König
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-01-15ubiformat: fix error pathWolfram Sang
A few error paths were closing the device, although it was not opened yet. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-01-15ubiformat: clean up synopsis of command-line parametersWolfram Sang
Add -Q and --image-seq, remove double -v Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-12-03ubi-tests: fix pthreads linkingBrian Norris
Technically, '-l' linker options should be included only after the objects which must link to the library. So when we include '-lpthread' in the LDFLAGS variable, it gets placed too early (i.e., before the io_paral.o object), and so the pthread linkage never occurs. The following error probably only shows up with linkers that don't link pthreads by default. $ make tests V=1 ... gcc -I../../ubi-utils//include -I ../../include -lpthread -Wall -Wextra -Wwrite-strings -Wno-sign-compare -ffunction-sections -fdata-sections -Wl,--gc-sections -g -o /home/norris/git/mtd-utils/tests/ubi-tests/io_paral /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.o /home/norris/git/mtd-utils/tests/ubi-tests/helpers.o libubi.a /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.o: In function `main': /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:287: undefined reference to `pthread_create' /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:295: undefined reference to `pthread_create' /home/norris/git/mtd-utils/tests/ubi-tests/io_paral.c:303: undefined reference to `pthread_join' collect2: ld returned 1 exit status make[2]: *** [/home/norris/git/mtd-utils/tests/ubi-tests/io_paral] Error 1 ... $ ld --version GNU ld (GNU Binutils for Ubuntu) 2.22 ... $ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 ... Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-16ubi-tests: switch to using common.h from the top levelArtem Bityutskiy
Sorry, the commit is huge, I just did not have time to split it. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-16ubi-tests: rename common.[ch] to helpers.[ch]Artem Bityutskiy
... to avoid confusion when the local common.h shadows the top-level common.h. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-16ubi-tests: ubi_leb_change_start() no longer uses 'dtype'.Bill Pringlemeir
This will not compile for me (due to bit rot?). Maybe the program is never used? Signed-off-by: Bill Pringlemeir <bpringlemeir@nbsps.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-11-12ubiformat: really skip some messages when quietWolfram Sang
Both logic (only print when not quiet) and the indentation suggest that the braces around the block have been forgotten. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-10-26mkfs.ubifs: Improve error handling of is_contained()Marcus Prebble
The is_contained() function returns -1 if an error occurs when canonicalizing the output file path/root directory. This resulted in the confusing error message 'Error: The output file cannot be in the UBIFS root' when specifying a non-existent directory for the output. This patch changes the error handling to display a different error message for the case when is_contained() returns -1. Additionally it frees all memory allocated by is_contained(). Signed-off-by: Marcus Prebble <marcus.prebble@axis.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-10-11mkfs.ubifs: rewrite path checkingArtem Bityutskiy
We use the 'in_path()' function to check whether the output image is withing the mkfs.ubifs root directory or not. However, this function is not correct and it fails for the following situation, as Marcus Prebble <marcus.prebble@axis.com> reports: 1. We have our root file-system mounted at / and want to build an image out of it. 2. We have tmpfs mounted at /tmp 3. We mount the root file-system under /tmp/newroot 4. We run mkfs.ubifs with -r /tmp/newroot -o /tmp/image And this fails. It fails because 'in_path()' misses this use-case. This patch re-implements the check completely. Now we use 'realpath()' to find canonical paths and just check that the output file is not under the root mkfs.ubifs directory. Reported-by: Marcus Prebble <marcus.prebble@axis.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Tested-by: Marcus Prebble <marcus.prebble@axis.com>
2012-09-25mkfs.jffs2: correct some warnings using PRIdoff_tRichard Genoud
When compiled with WITHOUT_LARGEFILE, there was warnings like that: warning: format '%9llu' expects type 'long long unsigned int', but argument 3 has type '__off_t' Using PRIdoff_t corrects that. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-25consistency between u_int32_t / off_t / off64_tRichard Genoud
We should use the off_t type instead of off64_t or u_int32_t as its length is controlled by the WITHOUT_LARGEFILE flag. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-25introduce PRIxoff_t and PRIdoff_t printf helpersRichard Genoud
They will be usefull when printing offsets. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-25tests: io_update correct lseek parameters orderRichard Genoud
There's a typo in lseek parameters order. But, due to the value of SEEK_SET, this commit doesn't introduce a change. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-25ubiformat: fix failure on big partitions (>4Gio)Richard Genoud
The offset (which is 64bits when mtd-utils are not compile with WITHOUT_LARGEFILE) is calculated like that: offset = nb * size; But nb and size are int, so on 32bits platforms, there's a possible overflow. So, it should be replace with: offset = (off_t)nb * size; If WITHOUT_LARGEFILE is defined, there still be an overflow, but it's what we want, right ? Cheney Chen tested an ubiformat on a NAND (5.9 GiB mtd part). Reported-by: Cheney Chen <cheneychencl2012@gmail.com> Tested-by: Cheney Chen <cheneychencl2012@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-09-03ubirmvol: correct missing space on usageRichard Genoud
Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-08-23ubiattach: fail if kernel ignores max_beb_per1024Richard Genoud
If the kernel doesn't know the max_beb_per1024 parameter in the attach ioctl, but the call still succeeded ubi_attach and ubi_attach_mtd will return 1 instead of 0. In this case, the ubiattach command will detach the device and fail with an error message. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>