aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2012-06-29mtd-utils: Check mtdoffset is not larger than mtd.size in case of a bad block.Tomer Barletz
mtdoffset is being tested against mtd.size in the outer two loops, but the third nested one does not test against it. In case of a bad block we'll try to access an out of bounds offset in the next MEMGETBADBLOCK ioctl, which will fail with EINVAL. In case mtdoffset is indeed larger than the partition size, we need to bail, since there are not enough "good" blocks to complete the write. Signed-off-by: Tomer Barletz <barletz@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-06-29nandwrite: minor cleanupsArtem Bityutskiy
Remove extra brackets and some style changes to make it more readable for a person who deals mostly with the kernel code. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-07Release mtd-utils-1.5.0v1.5.0Artem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-05-04mtd-utils: better document --pagesize of mkfs.jffs2Shmulik Ladkani
Add a strict explanation '--pagesize' refers to target system's mm page size. Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-04-02Makefile: fixup previous 'make clean' fixBrian Norris
Apparently, Makefile comments need to be made without indentation. Otherwise, they are printed out as shell commands. This fix prevents seeing this in your shell during 'make clean': $ make clean ... # findutils v4.1.x (RHEL 4) do not have '+' syntax ... Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-03-12Makefile: fix "make clean" for old GNU findBrian Norris
findutils v4.1.x does not have the `-exec CMD {} +' syntax. We can just as easily use the `-exec CMD {} \;' syntax. However, it will launch a lot more `rm' processes, so we only use it if the first form fails with an error. This isn't a perfect solution (`find -exec +' can fail for other reasons) but it works well enough. This problem manifests itself in RHEL 4, findutils 4.1.20: $ make clean rm -f /XXX/mtd-utils/*.o /XXX/mtd-utils/ftl_format ... find: missing argument to `-exec' make: *** [clean] Error 1 Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-03-07mkfs.ubifs: do not ignore --max-leb-cnt when formatting an UBI volumeArtem Bityutskiy
When the output file is an UBI volume - mkfs.ubifs just sets --max-leb-cnt to the volume size and ignores the user-supplied --max-leb-cnt value, which is wrong. Let's set it to the volume size only if the user did not supply --max-leb-cnt. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-29libmtd_legacy: don't open device in R/WBrian Norris
On legacy kernels with ROM devices, we can get mtdinfo errors like: libmtd: error!: cannot open "/dev/mtd4" error 13 (Permission denied) mtdinfo: error!: libmtd failed get MTD device 4 information error 13 (Permission denied) We don't need O_RDRW access for informational ioctls(), so make this O_RDONLY. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-29libmtd: perform device checking firstBrian Norris
If we don't check for the MTD before calling `legacy_get_dev_info1', we may get errors like: libmtd: MTD subsystem is old and does not support sysfs, so MTD character device nodes have to exist libmtd: error!: "/dev/mtd2" is not a character device mtdinfo: error!: libmtd failed get MTD device 2 information error 22 (Invalid argument) So reverse the order of these two checks. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-14libmtd: fix mtd_write() issues for large data-only writesBrian Norris
ioctl(MEMWRITE) is implemented with memdup_user(), and so it allocates kernel memory in contiguous regions. This limits its usefulness for large amounts of data, since contiguous kernel memory can become scarce. I have experienced "out of memory" problems with ubiformat, for instance, which writes in eraseblock-sized regions: ... ubiformat: flashing eraseblock 12 -- 72 % complete ubiformat: page allocation failure. order:8, mode:0xd0 Call Trace: [<8043fa7c>] dump_stack+0x8/0x34 [<8008c940>] __alloc_pages_nodemask+0x408/0x618 [<800bd748>] cache_alloc_refill+0x400/0x730 [<800bdbbc>] __kmalloc+0x144/0x154 [<8009cae4>] memdup_user+0x24/0x94 [<802d04e4>] mtd_ioctl+0xba8/0xbd0 [<802d0544>] mtd_unlocked_ioctl+0x38/0x5c [<800d43c0>] do_vfs_ioctl+0xa4/0x6e4 [<800d4a44>] sys_ioctl+0x44/0xa0 [<8000f95c>] stack_done+0x20/0x40 ... libmtd: error!: MEMWRITE ioctl failed for eraseblock 12 (mtd0) error 12 (Cannot allocate memory) ubiformat: error!: cannot write eraseblock 12 error 12 (Cannot allocate memory) This error can be mitigated for now by only using ioctl(MEMWRITE) when we need to write OOB data, since we can only do this in small transactions anyway. Then, data-only transactions (like those originating from ubiformat) can be carried out with write() calls. This issue can also be solved within the kernel ioctl(), but either way, this patch is still useful, since write() is more straightforward (and efficient?) than ioctl() for data-only writes. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-14mtdinfo: correct grammar on error messageBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-14libmtd: fix segmentation fault on lib->mtdBrian Norris
Legacy systems do not initialize lib->mtd, so we shouldn't perform strlen(lib->mtd); this produces a segmentation fault. As this code isn't used in the legacy codepath, we can just move it down to an 'else' branch. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-14limbtd: implement mtd_dev_present for old kernelsArtem Bityutskiy
Implement the 'legacy_dev_present()' function which will check whether an MTD device is present by scanning the /proc/mtd file when the MTD subsystem does not support sysfs (the case for pre-2.6.30 kernels). This patch also moves the 'mtd_dev_present()' function to a slightly more logical position. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-02docfsdisk: minor cosmetic cleanupArtem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-02mtdinfo: fix `--all' for non-consecutive device numbersBrian Norris
When we have assigned non-consecutive device numbers to our MTD devices, then we run `mtdinfo --all', we get errors once mtdinfo tries to process the devices in the "hole". For instance, suppose that at boot time, we have one MTD (/dev/mtd0) then perform a sequence like the following: # modprobe mtdram # modprobe nandsim # rmmod mtdram Then at this point, we have should have devices 0 and 2 without 1. Then: # mtdinfo --all ... mtdinfo: error!: mtd1 does not correspond to any existing MTD device We add a check to first see if device is present, then continue to the next ID if it doesn't exist. Reported-by: Brian Foster <brian.foster@maxim-ic.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-02libmtd: add `mtd_dev_present()' library functionBrian Norris
Will be used for `mtdinfo --all' Artem: add a temporary stub for pre-2.6.30 kernels. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-01-27ubinfo: fix `--all' for non-consecutive device numbersBrian Norris
When we have assigned non-consecutive device numbers to our UBI devices, then we run `ubinfo --all', we get errors once ubinfo tries to process the devices in the "hole". For instance, suppose there are two UBI devices, /dev/ubi0 and /dev/ubi10; then, ubinfo will fail trying to open /dev/ubi1 with: ubinfo: error!: cannot get information about UBI device 1 error 2 (No such file or directory) This patch adds a check to first see if device is present, then continue to the next ID if it doesn't exist. Reported-by: Brian Foster <brian.foster@maxim-ic.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-01-27libubi: make `ubi_dev_present()' a library functionBrian Norris
We will use this function in ubinfo. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-01-13libmtd: Variable name same as function name causing compile to fail (Android)Thomas Cannon
When compiling mtd-utils against Android's bionic libc using the supplied cross compiler environment it errors: lib/libmtd.c: In function 'dev_node2num': lib/libmtd.c:444: error: called object 'major' is not a function lib/libmtd.c:445: error: called object 'minor' is not a function lib/libmtd.c: In function 'mtd_probe_node': lib/libmtd.c:1384: error: called object 'major' is not a function lib/libmtd.c:1385: error: called object 'minor' is not a function This patch updates the variable names for "major" and "minor" in two places. It then compiles cleanly. Artem: pick different names, also rename major1/minor1 variables for consistency. Signed-off-by: Thomas Cannon <mail at thomascannon.net> Cc: linux-mtd at lists.infradead.org
2011-12-19make_a_release.sh: remind about pushing the master branchArtem Bityutskiy
When we print about pushing the tag, also print about pushing the master branch - I forgot to do this when releasing 1.4.9. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2011-12-17Release mtd-utils-1.4.9v1.4.9Artem Bityutskiy
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2011-12-12libmtd: allow write operations when MEMWRITE is not supportedBrian Norris
MEMWRITE is a recently introduced write interface for MTD; however, it is only supported on NAND flash. mtd-utils should fall back to old write methods when either ENOTTY or EOPNOTSUPP are returned. This is a showstopper when, for instance, using ubiformat on NOR, which don't have a mtd->write_oob interface (and thus don't support MEMWRITE): ubiformat: formatting eraseblock 2 -- 1 % complete libmtd: error!: MEMWRITE ioctl failed for eraseblock 2 (mtd3) error 122 (Operation not supported) Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
2011-12-07Add a script to make releasesArtem Bityutskiy
Credits to Mike Frysinger <vapier.adi@gmail.com> for review and comments. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2011-12-05nandtest: seed random generator with timeBrian Norris
If a seed is not provided via --seed, we use the default rand() values, which produces the same sequence of values every run. Since this is undesirable, we should choose a random seed via the current time(). Note that this patch moves the srand() until after all the initial options processing. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-12-01nandtest: use seed argumentJan Weitzel
if a seed is provided it is actually not used. First call is "seed = rand()" killing the given seed. Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Tested-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-12-01nandtest: set oldstats.failedJan Weitzel
if new ecc failed occures oldstats.corrected is updated not oldstats.failed Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-11-22Makefile: separate man page install and compression stepsMike Frysinger
If the system doesn't have gzip installed, we should still be able to install the man pages. So install the file in one step, and then compress it in another (and ignore failures from that). Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-11-22Makefile: fix install target with out-of-tree buildsMike Frysinger
The install target always looks for the compiled binaries in the working directory which breaks when doing something like `make CHOST=... install`. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-11-191.4.8 releasev1.4.8Artem Bityutskiy
Unfortunately I forgot to update the version in Makefile and tagged v1.4.7. To fix this, I could not invent anything better than cut a new release 1.4.8. Sorry for this :-( Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-11-18Merge branch 'brian'v1.4.7Artem Bityutskiy
2011-11-18mtdinfo: provide info when used without argumentsBrian Norris
If the user specifies neither a MTD argument nor the `-a' flag, we print a cryptic message; i.e., # mtdinfo libmtd: error!: cannot get information about "(null)" error 14 (Bad address) mtdinfo: error!: cannot get information about MTD device "(null)" error 14 (Bad address) This is a regression; previously, mtdinfo would give some short info about number of devices, etc. when used without arguments. To fix this, we revert commit d53c03b0989f8354a7e4dbb947a150fc7fe3f6d1 and call print_general_info() when no device is specified. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-11-18mtd-utils: add jffs2reader to .gitignoreBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-10-14tests: checkfs: remove unused codeAndy Shevchenko
There are two variables which are not used anymore. Thos patch removes useless lines and suppresses gcc warnings. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-10-14mkfs_jffs2: fix typo for word unknownAndy Shevchenko
Signed-off-by: Alexey Dokuchaev <danfe@nsu.ru> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-21jffs2reader: use major() and minor() helpersAndy Shevchenko
There are major() and minor() helpers in the standard library. We can use them. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-21jffs2reader: print ctime only by user's requestAndy Shevchenko
Signed-off-by: Alexey Dokuchaev <danfe@nsu.ru> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-21jffs2reader: use const char * for path variablesAndy Shevchenko
This patch brings const char * type for path variables. It allows to eliminate compiler warning. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-21jffs2reader: get rid of linker errorAndy Shevchenko
There is a linker errors: undefined reference to `target_endian' This patch fixes the issue and turns on the jffs2reader build in the Makefile. Signed-off-by: Alexey Dokuchaev <danfe@nsu.ru> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-21jffs2reader: introduce ADD_BYTES macroAndy Shevchenko
This macro is dedicated to get rid of the compiler errors: lvalue required as left operand of assignment Signed-off-by: Alexey Dokuchaev <danfe@nsu.ru> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2011-09-21jffs2reader: eliminate compiler errorsAndy Shevchenko
There are many errors like "error: invalid operands to binary". This patch converts the values to the proper types. Signed-off-by: Alexey Dokuchaev <danfe@nsu.ru> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2011-09-21jffs2reader: update the header inclusion blockAndy Shevchenko
Signed-off-by: Alexey Dokuchaev <danfe@nsu.ru> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-19ubiformat: handle write errors correctlyArtem Bityutskiy
This issue was reported and analyzed by Anton Olofsson <anol.martinsson@gmail.com>: when ubiformat encounters a write error while flashing the UBI image (which may come from a file of from stdout), it correctly marks the faulty eraseblock as bad and skips it. However, it also incorrectly drops the data buffer which was supposed to be written, and reads next block of data. This patch fixes this issue - in case of a write error, we preserve the current data and write it to the next eraseblock, instead of dropping it. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11nandwrite: use common.h "errmsg" functionsBrian Norris
Convert several forms of exit(), perror(), etc. to use common.h helper functions. Also, move one of our parameter checks inside the process_options() function for consistency. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11nandwrite: re-implement `--autoplace' optionBrian Norris
The restructuring of mtd_write() has allowed us to use `--autoplace' somewhat successfully; it is supported by the new ioctl(MEMWRITE) as well as some legacy code utilizing the deprecated ioctl(MEMGETOOBSEL). Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11nandwrite: kill `--raw' optionBrian Norris
The `--raw' option has lost all usefulness as it overlapped with several other OOB modes. I cannot even figure out what it was actually intended to do, but I'm sure its functionality fits somewhere in the MTD_OPS_{AUTO_OOB,PLACE_OOB,RAW} options, which are mostly implemented in libmtd's mtd_write(). I don't think users need a warning for this one, unless someone can tell me what it actually was supposed to have done in the first place. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11mtdutils: move OOB auto-layout into libmtd's mtd_writeBrian Norris
With the addition of the the new ioctl(MEMWRITE), we can use the kernel's internal OOB autoplacement option. It's a cleaner interface and avoids too much duplication of coding effort. This patch moves any legacy code (using MEMGETOOBSEL) into a legacy function in libmtd.c. It's not exactly a "pre-2.6.30" feature, so I'm not moving it to libmtd_legacy.c. Now, autoplacement features are only activated if we call mtd_write with mode == MTD_OPS_AUTO_OOB. This should fix some discrepancies for nandwrite, where we weren't handling OOB consistently (i.e., we had different functionality when the kernel did/didn't support MEMWRITE). But that also means that we now default to using MTD_OPS_PLACE_OOB instead of AUTO layout. To re-enable autoplacement, we can re-implement the `--autoplace' option that had previously rotted. This patch also cleans up a need for an extra OOB buffer in nandwrite. This has been tested a little in nandsim as well as on SLC NAND flash. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11nandwrite: merge `mtd_write_oob' and `mtd_write' callsBrian Norris
Now that `mtd_write' can write to both OOB and data regions, we need to perform our `mtd_write' call only once. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11libmtd: support MEMWRITE ioctlBrian Norris
`mtd_write()' now will first attempt to use MEMWRITE. Then, if that doesn't exist, it will attempt to fall back to old methods for writing OOB and/or page data. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11libmtd: modify `mtd_write' to cover OOB writesBrian Norris
To support the MEMWRITE ioctl, we will need a different sort of libmtd interface for writing to flash. We will expand mtd_write to include more functionality; for now, we just change the function definition and description as we begin to add the actual functionality. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-09-11mtd-utils: update mtd-abi.hBrian Norris
Kernel ABI header added a new ioctl, killed an old one, and exposed OOB modes to user-space. Plus, it added a lot of documentation. We have some trivial name changes for some MTD mode constants as well. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>