summaryrefslogtreecommitdiff
path: root/fs/jffs2/jffs2_1pass.c
AgeCommit message (Collapse)AuthorFilesLines
2021-04-07JFFS2: fix jffs2 summary datacrc status uninitializedWagner Popov dos Santos1-0/+2
The function jffs2_1pass_read_inode() was discarding the summary inodes and dirent because the value in datacrc flag wasn't initialized in function jffs2_sum_process_sum_data(). This fix initializes the status of all summary records to indicate that the CRC needs to be verified when they are loaded. Before this fix, the behaviors produced by the undefined value of datacrc was: - Summary's registries were discarded when 'b->datacrc' is equal as 'CRC_BAD'. - Summary's registries were not checked when b->datacrc differs of 'CRC_BAD' and 'CRC_UNKNOWN' So, almost all of the time the crc just isn't checked, and in some cases the registries are discarded. Signed-off-by: Wagner Popov dos Santos <wpopov@gmail.com>
2021-04-07JFFS2: fix the reading address over nand's limitWagner Popov dos Santos1-10/+27
Fixes address violation in functions read_nand_cached() and read_onenand_cached(). This happens because these functions try to read a fixed amount of data even when the offset+length is above the nand's limit. Signed-off-by: Wagner Popov dos Santos <wpopov@gmail.com>
2020-05-18common: Drop flash.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Fix up some style problems in flash.h while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-15JFFS2: Add useful fields into listsPetr Borsodi1-78/+76
The inode list uses version and ino, the dirent list uses version and pino. This information is collected during scanning, reducing accesses to flash and significantly speeding up ls and read. Signed-off-by: Petr Borsodi <petr.borsodi@i.cz>
2020-05-15JFFS2: Process obsolete nodes as well as accurate onesPetr Borsodi1-26/+47
Obsolete nodes (ie. without the JFFS2_NODE_ACCURATE flag) were ignored because they had seemingly invalid crc. This could lead to finding the phantom node header in obsolete node data. Signed-off-by: Petr Borsodi <petr.borsodi@i.cz>
2019-12-03crc32: Use the crc.h header for crc functionsSimon Glass1-0/+1
Drop inclusion of crc.h in common.h and use the correct header directly instead. With this we can drop the conflicting definition in fw_env.h and rely on the crc.h header, which is already included. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-10-16jffs2: ECC corrected nand data is ignoredEngling, Uwe1-2/+2
Hello, I ran into a problem with the JFFS2 filesystem driver implemented in U-Boot. I've got a NAND device that has correctable ECC errors (corrected somewhere in mtd/nand/nand_base.c). The NAND driver tells the filesystem layer (jffs2_1pass.c) above that there occurred correctable ECC errors and returns with a "value > 0". The JFFS2 driver recognizes the corrected ECC errors as real error and skips this block because the only accepts a "return value == 0" as correct. This problem exists for over 8 years (I checked version 2010.09) so I'm a little bit worried that I interpreted something wrong or didn't get the whole context. Can someone confirm this bug (and the bugfix) in the u-boot jffs2 driver? There was a mail in 2012 that mentioned the same problem, but there was no patch: http://u-boot.10912.n7.nabble.com/JFFS2-seems-to-drop-nand-data-with-ECC-corrections-td142008.html Sometime after this discussion the return value of nand_read() changed from -EUCLEAN as correctable ECC error to a positive value with the count of ECC corrected errors. With kind reguards, Uwe Engling
2017-07-12fs: use get_nand_dev_by_index()Grygorii Strashko1-2/+7
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
2016-09-24treewide: replace #include <asm/errno.h> with <linux/errno.h>Masahiro Yamada1-1/+1
Now, arch/${ARCH}/include/asm/errno.h and include/linux/errno.h have the same content. (both just wrap <asm-generic/errno.h>) Replace all include directives for <asm/errno.h> with <linux/errno.h>. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> [trini: Fixup include/clk.] Signed-off-by: Tom Rini <trini@konsulko.com>
2016-06-04nand: Embed mtd_info in struct nand_chipScott Wood1-1/+1
nand_info[] is now an array of pointers, with the actual mtd_info instance embedded in struct nand_chip. This is in preparation for syncing the NAND code with Linux 4.6, which makes the same change to struct nand_chip. It's in a separate commit due to the large amount of changes required to accommodate the change to nand_info[]. Signed-off-by: Scott Wood <oss@buserror.net>
2016-04-02jffs2: Fix set but not used warningTom Rini1-1/+2
We only use 'ofs' in jffs2_sum_scan_sumnode when debugging as it's part of a dbg_summary call. Mark this as __maybe_unused. Signed-off-by: Tom Rini <trini@konsulko.com>
2015-08-13JFFS2: Use merge sort when parsing filesystemMark Tomlinson1-35/+12
When building the file system the existing code does an insertion into a linked list. It attempts to speed this up by keeping a pointer to where the last entry was inserted but it's still slow. Now the nodes are just inserted into the list without searching through for the correct place. This unsorted list is then sorted once using mergesort after all the entries have been added to the list. This speeds up the scanning of the flash file system considerably. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Use CLEANMARKER to reduce scanning timeMark Tomlinson1-0/+25
If a sector has a CLEANMARKER at the beginning, it indicates that the entire sector has been erased. Therefore, if this is found, we can skip the entire block. This was not being done before this patch. The code now does the same as the kernel does when encountering a CLEANMARKER. It still checks that the next few words are FFFFFFFF, and if so, the block is assumed to be empty, and so is skipped. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Change scansize to match linux kernelMark Tomlinson1-1/+1
The scan code is similar to the linux kernel, but the kernel defines a much smaller size to scan through before deciding a sector is blank. Assuming that what is in the kernel is OK, make these two match. On its own, this change makes no difference to scanning of any sectors which have a clean marker at the beginning, since the entire sector is not blank. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Optimize building lists during scanMark Tomlinson1-4/+21
If the flash is slow, reading less from the flash into buffers makes the process faster. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Improve speed reading flash filesMark Tomlinson1-6/+21
jffs2_1pass_read_inode() would read the entire data for each node in the filesystem, regardless of whether it was part of the file to be loaded or not. By only reading the header data for an inode, and then reading the data only when it is found to be part of the file to be loaded, much copying of data is saved. jffs2_1pass_list_inodes() read each inode for every file in the directory into a buffer. By using NULL as a buffer pointer, NOR flash simply returns a pointer, and therefore avoids a memory copy. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Only list each directory entry onceMark Tomlinson1-5/+33
If multiple versions of a file exist, only the most recent version should be used. The scheme to write 0 for the inode in older versions did not work, since this would have required writing to flash. The only time this caused an issue was listing a directory, where older versions of the file would still be seen. Since the directory entries are sorted, just look at the next entry in the list, and if it's the same move to that entry instead. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Speed up and fix comparison functionsMark Tomlinson1-40/+47
Copying complete nodes from flash can be slow if the flash is slow to read. By only reading the data needed, the sorting operation can be made much faster. The directory entry comparison function also had a two bugs. First, it did not ensure the name was copied, so the name comparison may have been faulty (although it would have worked with NOR flash). Second, setting the ino to zero to ignore the entry did not work, since this was either writing to a temporary buffer, or (for NOR flash) directly to flash. Either way, the change was not remembered. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2015-08-13JFFS2: Return early when file read not necessaryMark Tomlinson1-0/+6
If a destination is not provided, jffs2_1pass_read_inode() only returns the length of the file. In this case, avoid reading all the data nodes, and return as soon as the length of the file is known. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
2014-06-12jffs2:jffs2_1pass.c: remove double bracesJeroen Hofstee1-1/+1
Clang interpretes an if condition like  "if ((a = b) == NULL) as it tries to assign a value in a statement. Hence if you do "if ((something)) it warns you that you might be confused. Hence drop the double braces for plane if statements. Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
2013-12-13JFFS2: Correct jffs2_1pass_build_lists to use lldivTom Rini1-1/+3
Since part_info size became 64bit we need to use lldiv here. Signed-off-by: Tom Rini <trini@ti.com>
2012-04-30linux/compat.h: rename from linux/mtd/compat.hMike Frysinger1-1/+1
This lets us use it in more places than just mtd code. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-10-10fs/jffs2/jffs2_1pass.c: fix warning: variable ... set but not usedWolfgang Denk1-10/+4
Fix: jffs2_1pass.c: In function 'jffs2_1pass_read_inode': jffs2_1pass.c:699:7: warning: variable 'ret' set but not used [-Wunused-but-set-variable] jffs2_1pass.c: In function 'jffs2_1pass_build_lists': jffs2_1pass.c:1578:14: warning: variable 'empty_start' set but not used [-Wunused-but-set-variable] Signed-off-by: Wolfgang Denk <wd@denx.de>
2011-04-13Fix misc spelling errors found by lintianLoïc Minier1-1/+1
Signed-off-by: Loïc Minier <loic.minier@linaro.org>
2010-03-31jffs2, suen3: Fix compiler warningHeiko Schocher1-15/+22
$ ./MAKEALL suen3 jffs2_1pass.c: In function 'get_fl_mem': jffs2_1pass.c:399: warning: unused variable 'id' jffs2_1pass.c: In function 'get_node_mem': jffs2_1pass.c:423: warning: unused variable 'id' Signed-off-by: Heiko Schocher <hs@denx.de> Tested-by: Tom <Tom.Rix@windriver.com>
2010-01-15JFFS2: drop support for LZARI compression modeWolfgang Denk1-6/+2
Support for LZARI compression mode was added based on a MTD CVS snapshot of March 13, 2005. However, fs/jffs2/compr_lzari.c contains contradictory licensing terms: the original copyright clause says "All rights reserved. Permission granted for non-commercial use.", but later reference to the file 'LICENCE' in the jffs2 directory was added which says GPL v2 or later. As no boards ever used LZARI compression, and this file is also not present in recent MTD code, we resolve this conflict by removing the conflicting file and references to it. Also copy the referenced but missing file 'LICENCE' from the current MTD source tree. Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-08-22jffs2: some fixes to summary supportIlya Yanok1-41/+81
This patch fixes some issues with JFFS2 summary support in U-Boot. 1/ Summary support made compilation configurable (as summary support considered expiremental even in Linux). 2/ Summary code can do unaligned 16-bit and 32-bit memory accesses. We need to get data byte by byte to exclude data aborts. 3/ Make summary scan in two passes so we can safely fall back to full scan if we found unsupported entry in the summary. Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2009-08-18jffs2: clean the cache in case of malloc fails in build_listsIlya Yanok1-3/+14
We should call jffs2_clean_cache() if we return from jffs2_build_lists() with an error to prevent usage of incomplete lists. Also we should free() a local buffer to prevent memory leaks. Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2009-07-17Remove legacy NAND and disk on chip code.Scott Wood1-20/+0
Legacy NAND had been scheduled for removal. Any boards that use this were already not building in the previous release due to an #error. The disk on chip code in common/cmd_doc.c relies on legacy NAND, and it has also been removed. There is newer disk on chip code in drivers/mtd/nand; someone with access to hardware and sufficient time and motivation can try to get that working, but for now disk on chip is not supported. Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-12-16jffs2: include <linux/mtd/compat.h> instead of defining own min_tIlya Yanok1-5/+1
Include <linux/mtd/compat.h> header for min_t definition instead of providing our own one. Removes warnings in case of OneNAND support enabled. Although I thinks it's a bit silly to include <linux/mtd/compat.h> just for min_t... Signed-off-by: Ilya Yanok <yanok@emcraft.com> Acked-by: Stefan Roese <sr@denx.de>
2008-12-10jffs2: cache data_crc resultsIlya Yanok1-1/+4
As we moved data_crc() invocation from jffs2_1pass_build_lists() to jffs2_1pass_read_inode() data_crc is going to be calculated on each inode access. This patch adds caching of data_crc() results. There is no significant improvement in speed (because of flash access caching added in previous patch I think, crc in RAM is really fast) but this patch impacts memory usage -- every b_node structure uses 12 bytes instead of 8. Signed-off-by: Alexey Neyman <avn@emcraft.com> Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2008-12-10jffs2: summary supportIlya Yanok1-1/+186
This patch adds support for reading fs information from summary node instead of scanning full eraseblock. Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2008-12-10jffs2: add buffer to cache flash accessesIlya Yanok1-44/+72
With this patch JFFS2 code allocates memory buffer of max_totlen size (size of the largest node, calculated during scan time) and uses it to store entire node. Speeds up loading. If malloc fails we use old ways to do things. Signed-off-by: Alexey Neyman <avn@emcraft.com> Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2008-12-10jffs2: rewrite jffs2 scanning code based on Linux oneIlya Yanok1-56/+171
Rewrites jffs2_1pass_build_lists() function in style of Linux's jffs2_scan_medium() and jffs2_scan_eraseblock(). This includes: - Caching flash acceses - Smart dealing with free space Signed-off-by: Alexey Neyman <avn@emcraft.com> Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2008-12-10jffs2: fix searching for latest version in jffs2_1pass_list_inodes()Ilya Yanok1-3/+2
We need to update i_version inside cycle to find really latest version inside jffs2_1pass_list_inodes(). With that fixed we can use isize inside dump_inode() instead of calling expensive jffs2_1pass_read_inode(). Signed-off-by: Alexey Neyman <avn@emcraft.com> Signed-off-by: Ilya Yanok <yanok@emcraft.com>
2008-10-31JFFS2: Eliminate compiler error when both NAND and OneNAND are enabled.Scott Wood1-7/+5
Reported-by: Alessandro Rubini <rubini-list@gnudd.com> Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-10-18rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD1-7/+7
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-09-07Add JFFS2 command support on OneNANDKyungmin Park1-0/+118
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-08-31fs: Move conditional compilation to MakefileJean-Christophe PLAGNIOL-VILLARD1-5/+0
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-13drivers/mtd/nand: Move conditional compilation to MakefileJean-Christophe PLAGNIOL-VILLARD1-3/+3
rename CFG_NAND_LEGACY to CONFIG_NAND_LEGACY Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-07-14Fix printf() format issues with sizeof_t types by using %zuWolfgang Denk1-4/+6
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-07-13Fix some more printf() format problems.Wolfgang Denk1-2/+2
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-07-13Fix some more printf() format issues.Jean-Christophe PLAGNIOL-VILLARD1-2/+2
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-06-29jffs2_1pass.c: add watchdog supportStuart Wood1-0/+3
Signed-off-by: Stuart Wood <stuart.wood@labxtechnologies.com>
2008-05-28Cleanup nand_info[] declaration.Stelian Pop1-3/+0
The nand_info array is declared as extern in several .c files. Those days, nand.h contains a reference to the array, so there is no need to declare it elsewhere. Signed-off-by: Stelian Pop <stelian@popies.net> Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-05-21Big white-space cleanup.Wolfgang Denk1-9/+9
This commit gets rid of a huge amount of silly white-space issues. Especially, all sequences of SPACEs followed by TAB characters get removed (unless they appear in print statements). Also remove all embedded "vim:" and "vi:" statements which hide indentation problems. Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-04-29jffs2_1pass.c: fix incompatible pointer type warningWolfgang Denk1-4/+0
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-01-09fix comments with new drivers organizationMarcel Ziswiler1-1/+1
Signed-off-by: Marcel Ziswiler <marcel@ziswiler.com>
2007-07-10fs/: Remove lingering references to CFG_CMD_* symbols.Jon Loeliger1-1/+1
Fixed some broken instances of "#ifdef CMD_CFG_IDE" too. Those always evaluated TRUE, and thus were always compiled even when IDE really wasn't defined/wanted. Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-07-10fs/: Remove obsolete references to CONFIG_COMMANDSJon Loeliger1-10/+10
Signed-off-by: Jon Loeliger <jdl@freescale.com>