aboutsummaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)AuthorFilesLines
2021-11-05fs: yaffs2: Finish Kconfig migrationTom Rini2-4/+12
For the symbols which are both hard-coded as enabled and used, move to Kconfig. The rest of the CONFIG_YAFFS namespace is unselected anywhere, so we leave it as is. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-10-23Merge https://source.denx.de/u-boot/custodians/u-boot-spiWIP/23Oct2021Tom Rini1-1/+0
- Fix mtd erase with mtdpart (Marek Behún) - NXP fspi driver fixes (Kuldeep Singh)
2021-10-23mtd: Remove mtd_erase_callback() entirelyMarek Behún1-1/+0
The original purpose of mtd_erase_callback() in Linux at the time it was imported to U-Boot, was to inform the caller that erasing is done (since it was an asynchronous operation). All supplied callback methods in U-Boot do nothing, but the mtd_erase_callback() function was (until previous patch) grossly abused in U-Boot's mtdpart implementation for completely different purpose. Since we got rid of the abusement, remove the mtd_erase_callback() function and the .callback member from struct erase_info entirely, in order to avoid such problems in the future. Signed-off-by: Marek Behún <marek.behun@nic.cz>
2021-10-12fs: fat: check for buffer size before reading blocksRicardo Salveti1-13/+10
This patch optimizes the commit mentioned below by avoiding running a set of commands which are useless in the case when size < mydata->sect_size and sect_count would be 0. Fixes: 5b3ddb17ba ("fs/fat/fat.c: Do not perform zero block reads if there are no blocks left") Signed-off-by: Ricardo Salveti <ricardo@foundries.io> Co-developed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
2021-10-08btrfs: Use U-Boot API for decompressionSimon Glass1-46/+5
Use the common function to avoid code duplication. Acked-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-10-06nand.h: Cleanup linux/mtd/rawnand.h usageTom Rini1-0/+1
We only include <linux/mtd/rawnand.h> in <nand.h> for the forward declaration of struct nand_chip, so do that directly. Then, include <linux/mtd/rawnand.h> where required directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-09-30WS cleanup: remove SPACE(s) followed by TABWolfgang Denk3-11/+11
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-30WS cleanup: remove excessive empty linesWolfgang Denk1-1/+0
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-27Merge tag 'v2021.10-rc5' into nextTom Rini1-1/+1
Prepare v2021.10-rc5
2021-09-24fs: avoid superfluous messagesHeinrich Schuchardt1-1/+1
Output like the following is quite irritating: => bootefi hello Scanning disk mmc2.blk... No valid Btrfs found Bad magic number for SquashFS image. ** Unrecognized filesystem type ** Scanning disk mmc1.blk... No valid Btrfs found Bad magic number for SquashFS image. ** Unrecognized filesystem type ** Scanning disk mmc0.blk... No valid Btrfs found Bad magic number for SquashFS image. ** Unrecognized filesystem type ** Albeit a whole disk may be formatted with a filesystem in most cases a partition table is used and the whole disk (partition number 0) doesn't contain a filesytem. Some partitions may only contain a blob. Not seeing a filesytem on the whole disk or on any partition is only worth a debug message. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-09-16sqfs: Suppress the message about missing filesystemSimon Glass1-1/+1
This message comes up a lot when scanning filesystems. It suggests to the user that there is some sort of error, but in fact there is no reason to expect that a particular partition has a sqfs filesystem. Other filesystems don't print this error. Turn it into a debug message. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
2021-09-16btrfs: Suppress the message about missing filesystemSimon Glass1-2/+6
This message comes up a lot when scanning filesystems. It suggests to the user that there is some sort of error, but in fact there is no reason to expect that a particular partition has a btrfs filesystem. Other filesystems don't print this error. Turn it into a debug message. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Qu Wenruo <wqu@suse.com>
2021-09-01btrfs: Use default subvolume as filesystem rootMatwey V. Kornilov1-3/+35
BTRFS volume consists of a number of subvolumes which can be mounted separately from each other. The top-level subvolume always exists even if no subvolumes were created manually. A subvolume can be denoted as the default subvolume i.e. the subvolume which is mounted by default. The default "default subvolume" is the top-level one, but this is far from the common practices used in the wild. For instance, openSUSE provides an OS snapshot/rollback feature based on BTRFS. To achieve this, the actual OS root filesystem is located into a separate subvolume which is "default" but not "top-level". That means that the /boot/dtb/ directory is also located inside this default subvolume instead of top-level one. However, the existing btrfs u-boot driver always uses the top-level subvolume as the filesystem root. This behaviour 1) is inconsistent with mount /dev/sda1 /target command, which mount the default subvolume 2) leads to the issues when /boot/dtb cannot be found properly (see the reference). This patch uses the default subvolume as the filesystem root to overcome mentioned issues. Reference: https://bugzilla.suse.com/show_bug.cgi?id=1185656 Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com> Fixes: f06bfcf54d0e ("fs: btrfs: Crossport open_ctree_fs_info() from btrfs-progs") Reviewed-by: Qu Wenruo <wqu@suse.com>
2021-08-04fs/squashfs: Fix some hardlinks reading the wrong inodeCampbell Suter1-1/+1
In SquashFS, the contents of a directory is stored by squashfs_directory_entry structures which contain the file's name, inode and position within the filesystem. The inode number is not stored directly; instead each directory has one or more headers which set a base inode number, and files store the offset from that to the file's inode number. In mksquashfs, each inode is allocated a number in the same order as they are written to the directory table; thus the offset from the header's base inode number to the file's inode number is usually positive. Hardlinks are simply stored with two directory entries referencing the same file. This means the second entry will thus have an inode number much lower than the surrounding files. Since the header's base inode number comes from the first entry that uses the header, this delta will usually be negative. Previously, U-Boot's squashfs_directory_entry.inode_offset field was declared as an unsigned value. Thus when a negative value was found, it would either resolve to an invalid inode number or to that of an unrelated file. A squashfs image to test this can be created like so: echo hi > sqfs_test_files/001-root-file mkdir sqfs_test_files/002-subdir touch sqfs_test_files/002-subdir/003-file ln sqfs_test_files/{001-root-file,002-subdir/004-link} mksquashfs sqfs_test_files/ test.sqfs -noappend Note that squashfs sorts the files ASCIIbetacally, so we can use the names to control the order they appear in. The ordering is important - the first reference to the file must have a lower inode number than the directory in which the second reference resides, and the second reference cannot be the first file in the directory. Listing this sample image in U-Boot results in: => sqfsls virtio 2 002-subdir 0 003-file Inode not found. 0 004-link Signed-off-by: Campbell Suter <campbell@snapit.group> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
2021-08-02global: Convert simple_strtoul() with hex to hextoul()Simon Glass1-7/+7
It is a pain to have to specify the value 16 in each call. Add a new hextoul() function and update the code to use it. Add a proper comment to simple_strtoul() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-28Use LIB_UUID with ACPIGEN and FS_BTRFSSimon Glass1-0/+1
Since the ACPI-generation code makes use of UUIDs we typically need to enabled UUID support for it to build. Add a new Kconfig condition. Use it for BTRFS also. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-15cbfs: Check offset range when reading a fileSimon Glass1-0/+2
Add a check that the offset is within the allowed range. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Coverity (CID: 331155)
2021-07-12fs: fat: add file attributes to struct fs_direntHeinrich Schuchardt1-1/+31
When reading a directory in the UEFI file system we have to return file attributes and timestamps. Copy this data to the directory entry structure. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-09fs/squashfs: fix reading of fragmented filesJoao Marcos Costa1-10/+6
The fragmented files were not correctly read because of two issues: - The squashfs_file_info struct has a field named 'comp', which tells if the file's fragment is compressed or not. This field was always set to 'true' in sqfs_get_regfile_info and sqfs_get_lregfile_info. It should actually take sqfs_frag_lookup's return value. This patch addresses these two assignments. - In sqfs_read, the fragments (compressed or not) were copied to the output buffer through a for loop which was reading data at the wrong offset. Replace these loops by equivalent calls to memcpy, with the right parameters. I tested this patch by comparing the MD5 checksum of a few fragmented files with the respective md5sum output in sandbox, considering both compressed and uncompressed fragments. Signed-off-by: Joao Marcos Costa <jmcosta944@gmail.com> Tested-by: Richard Genoud <richard.genoud@posteo.net> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
2021-05-26fs: btrfs: Add missing cache aligned allocationMarek Vasut1-1/+1
The superblock buffer must be cache aligned, since it might be used in DMA context, allocate it using ALLOC_CACHE_ALIGN_BUFFER() just like it was done in btrfs_read_superblock() and read_tree_node(). This fixes this output on boot and non-working btrfs on iMX53: CACHE: Misaligned operation at range [ced299d0, ced2a9d0] Signed-off-by: Marek Vasut <marex@denx.de> Cc: Marek Behún <marek.behun@nic.cz> Cc: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2021-05-26fs/squashfs: zero out unused fields in fs_direntHeinrich Schuchardt1-1/+1
When reading directories the UEFI sub-system must supply file attributes and timestamps. These fields will have to be added to struct fs_dirent. SquashFS should not fill these fields with random data. Ensure that they are zeroed out. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
2021-04-27fs: btrfs: fix the false alert of decompression failureQu Wenruo1-2/+14
There are some cases where decompressed sectors can have padding zeros. In kernel code, we have lines to address such situation: /* * btrfs_getblock is doing a zero on the tail of the page too, * but this will cover anything missing from the decompressed * data. */ if (bytes < destlen) memset(kaddr+bytes, 0, destlen-bytes); kunmap_local(kaddr); But not in U-boot code, thus we have some reports of U-boot failed to read compressed files in btrfs. Fix it by doing the same thing of the kernel, for both inline and regular compressed extents. Reported-by: Matwey Kornilov <matwey.kornilov@gmail.com> Link: https://bugzilla.suse.com/show_bug.cgi?id=1183717 Fixes: a26a6bedafcf ("fs: btrfs: Introduce btrfs_read_extent_inline() and btrfs_read_extent_reg()") Signed-off-by: Qu Wenruo <wqu@suse.com>
2021-04-22cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitionsSean Anderson1-2/+2
This allows using dev#partlabel syntax. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2021-04-10fs: fat: fix file_fat_detectfs()Heinrich Schuchardt1-34/+4
Up to now file_fat_detectfs() did not detect some interface types like EFI, HOST, VIRTIO. Avoid duplicate code by calling blk_get_if_type_name(). The interface type now will be shown in lower case to match all other use cases. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
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>
2021-03-27cbfs: Drop unnecessary cast in file_cbfs_fill_cache()Simon Glass1-2/+1
The results of malloc() are a void * and so this cast is unnecessary. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Support reading compression informationSimon Glass1-0/+22
CBFS now supports compressed filed. Add support for reading this information so that the correct decompression can be applied. The decompression itself is not implemented in CBFS. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Simplify file iterationSimon Glass1-6/+1
In file_cbfs_next_file() there is a lot of complicated code to move to the next file. Use the ALIGN() macros to simplify this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Factor out filling a cache node into a new functionSimon Glass1-12/+33
The file_cbfs_next_file() function is already fairly long. Before expanding it further, move the core part into a separate function. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Allow file traversal with any CBFSSimon Glass1-0/+11
The file traversal functions currently use a single global CBFS. In some cases we need to access multiple CBFSs to obtain different files. Add new functions to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Allow access to CBFS without a headerSimon Glass1-5/+13
In some cases CBFS does not start with a header but is just a collection of files. It is possible to support this so long as the size of the CBFS is provided. Update the cbfs_init_mem() function to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Rename new_node to nodeSimon Glass1-16/+16
Rename this variable since there is no need to distinguish it from an old node. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27cbfs: Add support for attributesSimon Glass1-1/+1
CBFS now supports attributes for things that cannot fit in the header as originally conceived. Add the structures for these. Also rename attributes_offset to something shorter, to ease code readability. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-04fs/squashfs: Fix compilation errorPali Rohár1-0/+1
Commit 401d1c4f5d2d29c4bc4beaec95402ca23eb63295 ("common: Drop asm/global_data.h from common header") broke compilation of squashfs filesystem when CONFIG_CMD_SQUASHFS=y is enabled. Compilation is failing on error: aarch64-linux-gnu-ld.bfd: u-boot/fs/squashfs/sqfs_inode.c:121: undefined reference to `le32_to_cpu' Fixes: 401d1c4f5d2d29c4bc4beaec95402ca23eb63295 ("common: Drop asm/global_data.h from common header") Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2021-03-01fs: btrfs: do not fail when offset of a ROOT_ITEM is not -1Marek Behún1-2/+1
When the btrfs_read_fs_root() function is searching a ROOT_ITEM with location key offset other than -1, it currently fails via BUG_ON. The offset can have other value than -1, though. This can happen for example if a subvolume is renamed: $ btrfs subvolume create X && sync Create subvolume './X' $ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: X$ location key (270 ROOT_ITEM 18446744073709551615) type DIR transid 283 data_len 0 name_len 1 name: X $ mv X Y && sync $ btrfs inspect-internal dump-tree /dev/root | grep -B 2 'name: Y$ location key (270 ROOT_ITEM 0) type DIR transid 285 data_len 0 name_len 1 name: Y As can be seen the offset changed from -1ULL to 0. Do not fail in this case. Signed-off-by: Marek Behún <marek.behun@nic.cz> Cc: David Sterba <dsterba@suse.com> Cc: Qu Wenruo <wqu@suse.com> Cc: Tom Rini <trini@konsulko.com>
2021-02-24fs: btrfs: change directory list output to be aligned as beforeMarek Behún1-7/+7
Since commit 325dd1f642dd ("fs: btrfs: Use btrfs_iter_dir() to ...") when btrfs is listing a directory, the output is not aligned: <SYMLINK> 15 Wed Sep 09 13:20:03 2020 boot.scr -> @/boot/boot.scr <DIR> 0 Tue Feb 02 12:42:09 2021 @ <FILE> 108 Tue Feb 02 12:54:04 2021 1.info Return back to how it was displayed previously, i.e.: <SYM> 15 Wed Sep 09 13:20:03 2020 boot.scr -> @/boot/boot.scr <DIR> 0 Tue Feb 02 12:42:09 2021 @ < > 108 Tue Feb 02 12:54:04 2021 1.info Instead of '<FILE>', print '< >', as ext4 driver. If an unknown directory item type is encountered, we will print the type number left padded with spaces, enclosed by '?', instead of '<' and '>', i.e.: ? 30? ............................. name Signed-off-by: Marek Behún <marek.behun@nic.cz> Fixes: 325dd1f642dd ("fs: btrfs: Use btrfs_iter_dir() to replace ...") Cc: David Sterba <dsterba@suse.com> Cc: Qu Wenruo <wqu@suse.com> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Qu Wenruo <wqu@suse.com>
2021-02-24fs: btrfs: skip xattrs in directory listingMarek Behún1-1/+4
Skip xattrs in directory listing. U-Boot filesystem drivers do not list xattrs. Signed-off-by: Marek Behún <marek.behun@nic.cz> Cc: David Sterba <dsterba@suse.com> Cc: Qu Wenruo <wqu@suse.com> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Qu Wenruo <wqu@suse.com>
2021-02-24fs/squashfs: NULL dereference in sqfs_closedir()Heinrich Schuchardt1-0/+3
sqfs_opendir() called in sqfs_size(), sqfs_read(), sqfs_exists() may fail leading to sqfs_closedir(NULL) being called. Do not dereference NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-15Merge branch '2021-02-02-drop-asm_global_data-when-unused'Tom Rini3-0/+4
- Merge the patch to take <asm/global_data.h> out of <common.h>
2021-02-03fs: fat: remove trailing periods from long nameHeinrich Schuchardt1-2/+28
The FAT32 File System Specification [1] requires leading and trailing spaces as well as trailing periods of long names to be ignored. [1] Microsoft Extensible Firmware Initiative FAT32 File System Specification Version 1.03, December 6, 2000 Microsoft Corporation https://www.win.tue.nl/~aeb/linux/fs/fat/fatgen103.pdf Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-03fs: fat: must not write directory '.' and '..'Heinrich Schuchardt1-10/+3
Directories or files called '.' or '..' cannot be created or written to in any directory. Move the test to normalize_longname() to check this early. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-03fs: fat: usage basename in file_fat_write_at, fat_mkdirHeinrich Schuchardt1-14/+13
This patch involves no functional change. It is just about code readability. Both in file_fat_write_at() and fat_mkdir() the incoming file or directory path are split into two parts: the parent directory and the base name. In file_fat_write_at() the value of the variable basename is assigned to the filename parameter and afterwards the variable filename is used instead of basename. It is more readable to use the variable basename and leave filename unchanged. In fat_mkdir() the base name variable is called directory. This is confusing. Call it basename like in file_fat_write_at(). This allows to rename parameter new_directory to directory in the implementation of fat_mkdir() to match the function declaration. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass3-0/+4
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-02-01cmd: load, emit error message for invalid block deviceHeinrich Schuchardt1-1/+3
The load command should not silently return to the console prompt if an invalid block device is specified and no file is loaded. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-01-29fs: btrfs: Select SHA256 in KconfigMatthias Brugger1-0/+1
Since commit 565a4147d17a ("fs: btrfs: Add more checksum algorithms") btrfs uses the sha256 checksum algorithm. But Kconfig lacks to select it. This leads to compilation errors: fs/built-in.o: In function `hash_sha256': fs/btrfs/crypto/hash.c:25: undefined reference to `sha256_starts' fs/btrfs/crypto/hash.c:26: undefined reference to `sha256_update' fs/btrfs/crypto/hash.c:27: undefined reference to `sha256_finish' Signed-off-by: Matthias Brugger <mbrugger@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com>
2021-01-29fs: fat: remove superfluous assignmentsHeinrich Schuchardt2-4/+5
Do not assign a value to a variable if it is not used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-29fs: fat: avoid out of bounds access warningHeinrich Schuchardt1-5/+2
When copying short name plus extension refer to the encapsulating structure and not to the short name element. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-23fs: fat: structure for name and extensionHeinrich Schuchardt2-27/+25
The short name and extension of FAT files are stored in adjacent fields of the directory entry. For some operations like calculating a checksum or copying both fields it is preferable to treat both as one structure. Change the definition of the directory entry structure to include a structure comprising the name and the extension field. This resolves Coverity CID 316357, CID 316350, CID 316348. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-23fs: fat: consistent error handling for flush_dir()Heinrich Schuchardt1-27/+31
Provide function description for flush_dir(). Move all error messages for flush_dir() from the callers to the function. Move mapping of errors to -EIO to the function. Always check return value of flush_dir() (Coverity CID 316362). In fat_unlink() return -EIO if flush_dirty_fat_buffer() fails. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>