summaryrefslogtreecommitdiffstats
path: root/fs/ext4
Commit message (Collapse)AuthorAgeFilesLines
* fs: ext4: initialize variable to silence GCC false-positiveAhmad Fatoum2023-09-121-1/+1
| | | | | | | | | | GCC complains about ino not being defined in some cases, which appears to be a false positive. Nevertheless, initialize it to the same fallback value used in ext4fs_get_ino, which is called below. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230911122504.2720431-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct fs_driver_d to fs_driverSascha Hauer2023-01-101-1/+1
| | | | | | | | | Remove the meaningless '_d' suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-6-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct fs_device_d to fs_deviceSascha Hauer2023-01-101-3/+3
| | | | | | | | | Remove the meaningless '_d' suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-102-4/+4
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: ext_barebox: handle ext_get_inode() errorsAhmad Fatoum2022-09-121-6/+12
| | | | | | | | | Static analyzer laments ext_get_inode, which can fail not having its failure condition checked. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-28-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for Kbuild/KconfigAhmad Fatoum2022-01-052-0/+4
| | | | | | | | | | | | | | | To verify only Kconfig/Makefile is touched: git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile' will print only arch/powerpc/Kbuild. To verify nothing unexpected is added: git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: fix bogus behavior on failure to read ext4 blockAhmad Fatoum2021-03-291-4/+4
| | | | | | | | | | | | | | The conversion of blknr from a signed 32-bit to an unsigned 64-type resulted in the check for error to never return true. Fix this. Affected configuration would behave incorrectly when served with invalid blocks. Instead of aborting and having the filesystem bubble up an error code, it would return invalid data. As there is no ext4 write support, this wouldn't lead to ext4 data corruption however. Reported-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: support files exceeding 4GAhmad Fatoum2021-02-183-2/+11
| | | | | | | | | | | | | ext4 redefines directory ACL to hold the most-significant 32-bit of the inode size for regular files. For directories, it can either be ACL or, when using largedir, the most-significant 32-bit of the directory size. Adapt the code take these upper 32-bit into consideration for determining regular file size. For directories, behavior remains unchanged as we neither support ACLs nor >= 4G directories Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: use sector_t and loff_t where appropriateAhmad Fatoum2021-02-185-31/+38
| | | | | | | | While the block API now supports 64-bit LBAs, file systems like ext4 still use 31- and 32-bit integers at a couple of places. Fix them up. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: ext4fs.h: remove unused struct members of ext_filesystemAhmad Fatoum2021-02-181-29/+0
| | | | | | | | struct ext_filesystem is for in-memory bookkeeping but most of it is unused by barebox and just takes up space. Drop the unused members. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: ext_common.h: drop declaration of never-defined part_offsetAhmad Fatoum2021-02-181-1/+0
| | | | | | | | part_offset is a left-over from the U-Boot port and unused anywhere. Drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: return NULL instead of 0Sascha Hauer2019-10-291-2/+2
| | | | | | | ext4fs_get_extent_block() returns a pointer, so return NULL instead of integer 0. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: Fix handling of sparse filesSascha Hauer2019-10-291-14/+14
| | | | | | | | | | | | | | | | | | Adoption of U-Boot commit: | commit f81db56f2fd6dc16efeaec2961121244765a1f11 | Author: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Date: Sat Nov 5 22:17:14 2016 +0100 | | ext4: Fix handling of sparse files | | A sparse file may have regions not mapped by any extents, at the start | or at the end of the file, or anywhere between, thus not finding a | matching extent region is never an error. | | Found by python filesystem tests. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: remove unnecessarily clever file readSascha Hauer2019-10-291-53/+6
| | | | | | | | | ext4fs_read_file() tries to tries to bundle contiguous block reads into longer reads from the device. In barebox we cache in the block layer already, so this is unnecessary. Simplify the code by removing the bundled reads. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: Fix out of bounds memsetSascha Hauer2019-10-291-1/+1
| | | | | | | | | When a block we read is a sparse block, we memset the corresponding output buffer to zero. If that block is the last block we read, we may not memset the whole block, but only up to the length of the output buffer, which may be shorter than a full block. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* trivial: fix typo lenght -> lengthUwe Kleine-König2019-10-141-1/+1
| | | | | | | | | | | | Generated by perl -p -i -e 's/lenghte?/length/' arch/arm/boards/chumby_falconwing/falconwing.c arch/arm/mach-samsung/mem-s3c64xx.c fs/ext4/ext_common.h lib/gui/lodepng.c include/jtag.h There is another instance in dts/Bindings/usb/s3c2410-usb.txt, this is fixed in Linux v5.3-rc1 so supposed to be fixed soon in barebox, too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Drop trivial .lseek() implementaitons in FS driversAndrey Smirnov2019-01-291-6/+0
| | | | | | | | | | | | | | | There are no FS drivers that do not implement .lseek callback in the codebase, so there doesn't seem to exist a use-case where lseek() would return -ENOSYS due to fsdrv->lseek being NULL. At the same time a large number of FS drivers implement only the most basic "always succeeds" custom .lseek() hook. Change the code of lseek() to treat absense of .lseek() to mean that no special actions needs to be taken by FS driver and seek is always successful and drop all of the trivial .lseek() implementations. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Update FILE position in lseek()Andrey Smirnov2019-01-291-3/+1
| | | | | | | | | | Instead on relying on driver callbacks to update 'pos' in FILE, do it as a part of lseek() code. This allows us to drop a bit of repeating code as well as making lseek() implementation consistent with write() and read(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: Switch to dentry cache implementationSascha Hauer2018-07-113-123/+160
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: dentry cache implementationSascha Hauer2018-07-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This adds the Linux dentry cache implementation to barebox. Until now every filesystem driver resolves the full path to a file for itself. This leads to code duplication and is error prone since resolving paths is a complicated task. Also it can narrow down the lookup performance since barebox only knows ASCII paths and has no way of caching lookups. With this patch we get the Linux dcache implementation. The path resolving code from fs/namei.c is nearly taken as-is, minus the RCU and locking code. Dcaching is made simple as of now: We simply cache everything and never release any dentries. Although we do reference counting for inodes and dentries it is effectively not used yet. We never free anything until a fs is unmounted in which case we free everything no matter if references are taken or not. This patch also contains a wrapper in fs/legacy.c to support filesystems with the old API. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: Use correct descriptor size when reading the block group descriptorAntony Pavlov2017-03-301-4/+4
| | | | | | | | | | | | | | | | | | This is an adoption of the U-Boot commit | commit f798b1dda1c5de818b806189e523d1b75db7e72d | Author: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Date: Sat Sep 17 02:10:09 2016 +0200 | | ext4: Use correct descriptor size when reading the block group descriptor | | The correct descriptor size must be used when calculating offsets, and | also to read the correct amount of data. | | Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: determine group descriptor size for 64bit featureAntony Pavlov2017-03-302-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an adoption of the U-Boot commits | commit fc214ef90910159f33fbe92a6cb77839a27fa8a6 | Author: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Date: Sat Sep 17 02:10:07 2016 +0200 | | ext4: determine group descriptor size for 64bit feature | | If EXT4_FEATURE_INCOMPAT_64BIT is set, the descriptor can be read from | the superblocks, otherwise it defaults to 32. | | Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> | commit 3cc5bbb8e68dc67b7c3d2fdebef69408e5271469 | Author: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Date: Tue Dec 27 02:35:08 2016 +0100 | | fs/ext4: Initialize group descriptor size for revision level 0 filesystems | | genext2fs creates revision level 0 filesystems, which are not readable | by u-boot due to the initialized group descriptor size field. | f798b1dda1c5de818b806189e523d1b75db7e72d | | Reported-by: Kever Yang <kever.yang@rock-chips.com> | Reported-by: FrostyBytes@protonmail.com | Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Tested-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: Update ext2/3/4 superblock, group descriptor and inode structuresAntony Pavlov2017-03-301-4/+46
| | | | | | | | | | | | | | | | | | This is an adoption of the U-Boot commit | commit 3ee2f977f3649bcc1d0de86356145e8e6999575a | Author: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Date: Sat Sep 17 02:10:06 2016 +0200 | | ext4: Update ext2/3/4 superblock, group descriptor and inode structures | | Most importantly, the superblock provides the used group descriptor size, | which is required for the EXT4_FEATURE_INCOMPAT_64BIT. | | Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: fix wrong usage of le32_to_cpu()Antony Pavlov2017-03-301-1/+1
| | | | | | | | | | | | | | | | | | This is an adoption of the U-Boot commit | commit 011bc3342a485345f7136eed20e0477b8cd5580f | Author: Michael Walle <michael@walle.cc> | Date: Mon Aug 29 10:46:46 2016 +0200 | | ext4: fix wrong usage of le32_to_cpu() | | le32_to_cpu() must only convert the revision_level and not the boolean | result. | | Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: drop unused and misdefined INODE_SIZE_FILESYSTEM macroAntony Pavlov2017-03-301-2/+0
| | | | | | | Nota bene sblock.inode_size actually has __le16 type. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: use kernel names for byte swapsAntony Pavlov2017-03-304-39/+39
| | | | | | | | | | | | | | | | | This is an adoption of the U-Boot commit | commit 7f101be314da1f6f612a1b84822f791d6569946b | Author: Michael Walle <michael@walle.cc> | Date: Mon Aug 29 10:46:44 2016 +0200 | | ext4: use kernel names for byte swaps | | Instead of __{be,le}{16,32}_to_cpu use {be,le}{16,32}_to_cpu. | | Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: change structure fields to __le/__be typesAntony Pavlov2017-03-301-68/+68
| | | | | | | | | | | | | | | | | | | This is an adoption of the U-Boot commit | commit 2a0b7a971aac682112cf676c6583196faafcb2b0 | Author: Michael Walle <michael@walle.cc> | Date: Mon Aug 29 10:46:43 2016 +0200 | | ext4: change structure fields to __le/__be types | | Change all the types of ext2/4 fields to little endian types and all the | JBD fields to big endian types. Now we can use sparse (make C=1) to check | for statements where we need byteswaps. | | Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: fix symlink read functionRonald Zachariah2016-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | | From U-Boot commit: | commit 37f23885e4905ff500a8524328aa3084ac11cdb4 | Author: Ronald Zachariah <rozachar@cisco.com> | Date: Thu Apr 28 07:08:34 2016 +0200 | | fs: ext4: fix symlink read function | | The function ext4fs_read_symlink was unable to handle a symlink | which had target name of exactly 60 characters. | | Signed-off-by: Ronald Zachariah <rozachar@cisco.com> | Signed-off-by: Stefan Roese <sr@denx.de> | Reviewed-by: Stephen Warren <swarren@nvidia.com> | Cc: Tom Rini <trini@konsulko.com> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: make locally used ext4fs_get_indir_block() staticAntony Pavlov2016-02-171-1/+2
| | | | | | | | | | | | | | The patch fixes this compiler's warning: CC fs/ext4/ext4_common.o fs/ext4/ext4_common.c:130:5: warning: no previous prototype for 'ext4fs_get_indir_block' [-Wmissing-prototypes] int ext4fs_get_indir_block(struct ext2fs_node *node, struct ext4fs_indir_block *indir, int blkno) ^ Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: import magic.h from Linux kernelYegor Yefremov2016-02-032-3/+2
| | | | | | | | include/linux/magic.h provides MAGIC numbers for various file systems. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drop <stddef.h> includesSascha Hauer2015-07-231-1/+0
| | | | | | | The compilers stddef.h should not be included. We declare all types ourselves. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: rename inode member of struct filep to privSascha Hauer2015-03-091-3/+3
| | | | | | | Because that's what it is. 'inode' will become confusing once we support real inodes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: le32_to_cpu() used on a 16-bit fieldSascha Hauer2014-07-251-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | From U-Boot commit: | commit 8b415f703f88d1d3b0466830047affbbf7f24913 | Author: Rommel Custodio <sessyargc+uboot@gmail.com> | Date: Sun Jul 21 10:53:25 2013 +0200 | | ext4fs: le32_to_cpu() used on a 16-bit field | | 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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: use EXT2_BLOCK_SIZE instead of fs->blkszSascha Hauer2014-07-251-1/+2
| | | | | | | | | | | | | | | | | | | | From U-Boot commit: | commit 470173274d9ceb18a7140ef93e20be6c2236e7d9 | Author: Ionut Nicu <ioan.nicu.ext@nsn.com> | Date: Mon Jan 13 11:59:24 2014 +0100 | | ext4fs: use EXT2_BLOCK_SIZE instead of fs->blksz | | 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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ext4: fix "invalid extent block" errorSascha Hauer2014-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From U-Boot commit: | commit b5bbac1a9b07016602559ff483df265fef6c1f83 | Author: Ionut Nicu <ioan.nicu.ext@nsn.com> | Date: Mon Jan 13 12:00:08 2014 +0100 | | ext4fs: fix "invalid extent block" error | | 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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: cleanup backingstore handlingSascha Hauer2013-09-291-10/+4
| | | | | | | | | | | All filesystem drivers which need a backingstore device do the same ignoring of '/dev/' in the backingstore followed by a cdev_open. Add a helper function for it and let the core handle the cdev. As a side effect this makes sure that fsdev->cdev is also set when a device is mounted without the leading '/dev/' which was previously ignored by the mount code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ext4: switch debug and printf to dev_xxxJean-Christophe PLAGNIOL-VILLARD2013-03-091-6/+6
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: implement initial ext4 support from U-BootSascha Hauer2012-12-038-0/+1381
The ext4 implementation has been taken from U-Boot with some changes: - No global variables to allow for multiple filesystems to be mounted and multiple files to be open. - remove fs internal link following and use the barebox link implementation. - remove write support. This is incomplete in U-Boot, so I decided to skip this for now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>