summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4_common.c
Commit message (Collapse)AuthorAgeFilesLines
* fs: ext4: fix symlink read functionGary Bisson2015-09-111-1/+1
| | | | | | | Since last API changes for files >2GB, the read of symlink is broken as ext4fs_read_file now returns 0 instead of the length of the actual read. Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
* ext4: fix leak in check_filename()Stephen Warren2015-09-111-2/+3
| | | | | | | | | root_first_block_buffer should be free()d in all cases, not just when an error occurs. Fix the success exit path of the function to do this. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4: free allocations by parse_path()Stephen Warren2015-09-111-2/+6
| | | | | | | | | | | | | | parse_path() malloc()s the entries in the array it's passed. Those allocations must be free()d by the caller, ext4fs_get_parent_inode_num(). Add code to do this. For this to work, all the array entries must be dynamically allocated, rather than a mix of dynamic and static allocations. Fix parse_path() not to over-write arr[0] with a pointer to statically allocated data. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com>
* Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h headerSimon Glass2015-09-111-0/+1
| | | | | | | Now that we have a new header file for cache-aligned allocation, we should move the stack-based allocation macro there also. Signed-off-by: Simon Glass <sjg@chromium.org>
* ext4: Prepare API change for files greater than 2GBSuriyan Ramasami2014-11-231-11/+13
| | | | | | | | | Change the internal EXT4 functions to use loff_t for offsets. Signed-off-by: Suriyan Ramasami <suriyan.r@gmail.com> Acked-by: Simon Glass <sjg@chromium.org> [trini: Update common/spl/spl_ext.c] Signed-off-by: Tom Rini <trini@ti.com>
* ext4: Use inttypes for printf() stringSimon Glass2014-10-271-1/+2
| | | | | | | On 64-bit platforms (like sandbox) 64-bit integers may be 'long' rather than 'long long'. Use the inttypes header to avoid compiler warnings. Signed-off-by: Simon Glass <sjg@chromium.org>
* fs: ext4: fix writing zero-length filesStephen Warren2014-06-191-3/+1
| | | | | | | | | | | | | ext4fs_allocate_blocks() always allocates at least one block for a file. If the file size is zero, this causes total_remaining_blocks to underflow, which then causes an apparent hang while 2^32 blocks are allocated. To solve this, check that total_remaining_blocks is non-zero as part of the loop condition (i.e. before each loop) rather than at the end of the loop. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* fs:ext4:write:fix: Reinitialize global variables after updating a fileŁukasz Majewski2014-05-121-9/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug shows up when file stored on the ext4 file system is updated. The ext4fs_delete_file() is responsible for deleting file's (e.g. uImage) data. However some global data (especially ext4fs_indir2_block), which is used during file deletion are left unchanged. The ext4fs_indir2_block pointer stores reference to old ext4 double indirect allocated blocks. When it is unchanged, after file deletion, ext4fs_write_file() uses the same pointer (since it is already initialized - i.e. not NULL) to return number of blocks to write. This trunks larger file when previous one was smaller. Lets consider following scenario: 1. Flash target with ext4 formatted boot.img (which has uImage [*] on itself) 2. Developer wants to upload their custom uImage [**] - When new uImage [**] is smaller than the [*] - everything works correctly - we are able to store the whole smaller file with corrupted ext4fs_indir2_block pointer - When new uImage [**] is larger than the [*] - theCRC is corrupted, since truncation on data stored at eMMC was done. 3. When uImage CRC error appears, then reboot and LTHOR/DFU reflashing causes proper setting of ext4fs_indir2_block() and after that uImage[**] is successfully stored (correct uImage [*] metadata is stored at an eMMC on the first flashing). Due to above the bug was very difficult to reproduce. This patch sets default values for all ext4fs_indir* pointers/variables. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* fs:ext4:cleanup: Remove superfluous codeŁukasz Majewski2014-05-121-4/+2
| | | | | | | | | Code responsible for handling situation when ext4 has block size of 1024B can be ordered to take less space. This patch does that for ext4 common and write files. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* ext4fs: fix "invalid extent block" errorIonut Nicu2014-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | For files where we actually have extent indexes following an extent header (ext_block->eh_depth != 0), the do/while loop from ext4fs_get_extent_block() does not select the proper extent index structure. For example, if we have: ext_block->eh_depth = 1 ext_block->eh_entries = 1 fileblock = 0 index[0].ei_block = 0 the do/while loop will exit with i set to 0 and the ext4fs_get_extent_block() function will return 0, even if there was a valid extent index structure following the header. Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com> Signed-off-by: Mathias Rulf <mathias.rulf@nsn.com>
* ext4fs: use EXT2_BLOCK_SIZE instead of fs->blkszIonut Nicu2014-01-201-2/+2
| | | | | | | | | | Using fs->blksz in ext4fs_get_extent_block() is not correct since fs->blksz is not initialized on the read path. Use EXT2_BLOCK_SIZE() instead which will produce the desired output. Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com> Signed-off-by: Mathias Rulf <mathias.rulf@nsn.com>
* fs/ext4: fix calling put_ext4 with truncated offsetMa Haijun2014-01-201-17/+17
| | | | | | | | | | | | Curently, we are using 32 bit multiplication to calculate the offset, so the result will always be 32 bit. This can silently cause file system corruption when performing a write operation on partition larger than 4 GiB. This patch address the issue by simply promoting the terms to 64 bit, and let compilers decide how to do the multiplication efficiently. Signed-off-by: Ma Haijun <mahaijuns@gmail.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-13/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* ext4fs: le32_to_cpu() used on a 16-bit fieldRommel Custodio2013-07-221-6/+6
| | | | | | | | | | | | | | Fix reading ext4_extent_header struture on BE machines. Some 16 bit fields where converted to 32 bit fields, due to the byte swap on BE machines the containing value was corrupted. Therefore reading ext4 filesystems on BE machines where broken before. Signed-off-by: Rommel Custodio <sessyargc+uboot@gmail.com> [sent via git-send-email; rework commit message] Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Tested-by: Lukasz Majewski <l.majewski@samsung.com>
* Fix ext2/ext4 filesystem accesses beyond 2TiBFrederic Leroy2013-07-151-21/+27
| | | | | | | | | | | | | | | | | With CONFIG_SYS_64BIT_LBA, lbaint_t gets defined as a 64-bit type, which is required to represent block numbers for storage devices that exceed 2TiB (the block size usually is 512B), e.g. recent hard drives We now use lbaint_t for partition offset to reflect the lbaint_t change, and access partitions beyond or crossing the 2.1TiB limit. This required changes to signature of ext4fs_devread(), and type of all variables relatives to block sector. ext2/ext4 fs uses logical block represented by a 32 bit value. Logical block is a multiple of device block sector. To avoid overflow problem when calling ext4fs_devread(), we need to cast the sector parameter. Signed-off-by: Frédéric Leroy <fredo@starox.org>
* fs/ext4: Support device block sizes != 512 bytesEgbert Eich2013-05-101-19/+23
| | | | | | | | | The 512 byte block size was hard coded in the ext4 file systems. Large harddisks today support bigger block sizes typically 4096 bytes. This patch removes this limitation. Signed-off-by: Egbert Eich <eich@suse.com>
* fs:ext4:fix: Code refactoring to suppress compiler warningsŁukasz Majewski2012-12-071-4/+10
| | | | | | | | Several fixes to suppress compiler's (eldk-5.[12].x gcc 4.6) warning [-Wunused-but-set-variable] Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
* fs: separate CONFIG_FS_{FAT, EXT4} from CONFIG_CMD_{FAT, EXT*}Stephen Warren2012-10-291-1/+1
| | | | | | | | | | | | | | | | | | This makes the FAT and ext4 filesystem implementations build if CONFIG_FS_{FAT,EXT4} are defined, rather than basing the build on whether CONFIG_CMD_{FAT,EXT*} are defined. This will allow the filesystems to be built separately from the filesystem-specific commands that use them. This paves the way for the creation of filesystem-generic commands that used the filesystems, without requiring the filesystem- specific commands. Minor documentation changes are made for this change. The new config options are automatically selected by the old config options to retain backwards-compatibility. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
* ext4: Rename block group descriptor table from gd to bgdSimon Glass2012-10-031-41/+44
| | | | | | | | | | | On x86 machines gd is unfortunately a #define, so we should avoid using gd for anything. This patch changes uses of gd to bgd so that ext4fs can be used on x86. A better fix would be to remove the #define in x86, but I'm not sure how to do that. Signed-off-by: Simon Glass <sjg@chromium.org>
* ext4: cache-align buffers so the invalidation worksStephen Warren2012-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | DMA buffer cache invalidation requires that buffers have cache-aligned buffer locations and sizes. Use memalign() and ALLOC_CACHE_ALIGN_BUFFER() to ensure this. On Tegra at least, without this fix, the following fail commands fail in u-boot-master/ext4, but succeeded at the branch's branch point in u-boot/master. With this fix, the commands work again: ext2ls mmc 0:1 / ext2load mmc 0:1 /boot/zImage Cc: Uma Shankar <uma.shankar@samsung.com> Cc: Manjunatha C Achar <a.manjunatha@samsung.com> Cc: Iqbal Shareef <iqbal.ams@samsung.com> Cc: Hakgoo Lee <goodguy.lee@samsung.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Tom Rini <trini@ti.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
* ext4fs write supportUma Shankar2012-08-091-0/+1353
| | | | | | | Signed-off-by: Uma Shankar <uma.shankar@samsung.com> Signed-off-by: Manjunatha C Achar <a.manjunatha@samsung.com> Signed-off-by: Iqbal Shareef <iqbal.ams@samsung.com> Signed-off-by: Hakgoo Lee <goodguy.lee@samsung.com>
* ext4fs ls load supportUma Shankar2012-08-091-0/+875
Signed-off-by: Uma Shankar <uma.shankar@samsung.com> Signed-off-by: Manjunatha C Achar <a.manjunatha@samsung.com> Signed-off-by: Iqbal Shareef <iqbal.ams@samsung.com> Signed-off-by: Hakgoo Lee <goodguy.lee@samsung.com>
OpenPOWER on IntegriCloud