aboutsummaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)AuthorFilesLines
2020-09-21Merge branch 'master' into nextTom Rini3-10/+18
Merge in v2020.10-rc5
2020-09-18fs/squashfs: Fix Coverity Scan defectsJoao Marcos Costa3-10/+18
Fix control flow issues and null pointer dereferences. Signed-off-by: Joao Marcos Costa <jmcosta944@gmail.com>
2020-09-07fs: btrfs: Cleanup the old implementationQu Wenruo14-1366/+3
This cleans up the now unneeded code from the old btrfs implementation. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Imeplement btrfs_list_subvols() using new infrastructureQu Wenruo1-5/+73
Reimplement btrfs_list_subvols() to use new code. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Introduce function to resolve the path of one subvolumeQu Wenruo1-0/+81
This patch introduces a new function, list_one_subvol(), which will resolve the path to FS_TREE of one subvolume. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Introduce function to resolve path in one subvolumeQu Wenruo2-1/+68
This patch introduces a new function, get_path_in_subvolume(), which resolves inode number into path inside a subvolume. This function will be later used for btrfs subvolume list functionality. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Implement btrfs_file_read()Qu Wenruo3-20/+176
This version of btrfs_file_read() has the following new features: - Tries all mirrors - More handling on unaligned size - Better compressed extent handling The old implementation doesn't handle compressed extent with offset properly: we need to read out the whole compressed extent, then decompress the whole extent, and only then copy the requested part. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Introduce lookup_data_extent() for later useQu Wenruo1-0/+101
This implements lookup_data_extent() function for the incoming new implementation of btrfs_file_read(). Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Introduce btrfs_read_extent_inline() and btrfs_read_extent_reg()Qu Wenruo4-0/+205
These two functions are used to do sector aligned read, which will be later used to implement btrfs_file_read(). Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Rename btrfs_file_read() and its callees to avoid name conflictsQu Wenruo4-9/+9
Rename btrfs_file_read() and its callees to avoid name conflicts with the incoming new code. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Use btrfs_lookup_path() to implement btrfs_exists() and btrfs_size()Qu Wenruo1-17/+48
After this the only remaining function that still utilizes __btrfs_lookup_path() is btrfs_read(). Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Use btrfs_iter_dir() to replace btrfs_readdir()Qu Wenruo4-91/+144
Use extent buffer based infrastructure to re-implement btrfs_readdir(). Along this rework, some small corner cases fixed: - Subvolume tree mtime Mtime of a subvolume tree is recorded in its root item, since there is no INODE_ITEM for it. This needs extra search from tree root. - Output the unknown type If the DIR_ITEM is corrupted, at least don't try to access the memory out of boundary. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Implement btrfs_lookup_path()Qu Wenruo3-0/+360
This is the extent buffer based path lookup routine. To implement this, btrfs_lookup_dir_item() is crossported from btrfs-progs, and implements btrfs_lookup_path() from scratch. Unlike the existing __btrfs_lookup_path(), since btrfs_read_fs_root() will check whether a root is a orphan at read time, there is no need to check root backref, this makes the code a little easier to read. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: inode: Allow next_length() to return value > BTRFS_NAME_LENQu Wenruo1-2/+6
All existing next_length() caller handles return value > BTRFS_NAME_LEN, so there is no need to do BTRFS_NAME_LEN check in next_length(). But still, we want to exit early if we're beyond BTRFS_NAME_LEN, so this patch makes next_length() exit as soon as we're beyond BTRFS_NAME_LEN. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Use btrfs_readlink() to implement __btrfs_readlink()Qu Wenruo2-37/+65
The existing __btrfs_readlink() can be easily re-implemented using the extent buffer based btrfs_readlink(). This is the first step to re-implement U-Boot's btrfs code. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Rename path resolve related functions to avoid name conflictsQu Wenruo7-33/+43
Since the old code is using __btrfs_path/__btrfs_root which is different from the regular extent buffer based one, we add "__" prefix for the old implementation to avoid name conflicts for the incoming crossport. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport open_ctree_fs_info() from btrfs-progsQu Wenruo8-20/+579
open_ctree_fs_info() is the main entry point to open btrfs. This version is a simplfied version of __open_ctree_fd() of btrfs-progs, the main differences are: - Parameters on how to specify a block device Instead of @fd and @path, U-Boot uses blk_desc and disk_partition_t. - Remove open_ctree flags There won't be multiple open ctree modes in U-Boot. Otherwise functions structures are all kept the same. With open_ctree_fs_info() implemented, also introduce the global current_fs_info pointer to show the current opened btrfs. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport btrfs_read_sys_array() and btrfs_read_chunk_tree()Qu Wenruo5-3/+306
These two functions play a big role in btrfs bootstrap. The following function is removed: - Seed device support Although in theory we can still support multiple devices, we don't have a facility in U-Boot to do device scan without opening them. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport btrfs_search_slot() from btrfs-progsQu Wenruo2-7/+591
This patch copies the core function, btrfs_search_slot(), from btrfs-progs. This version has the following functionality removed: - The ability to COW tree block Related code is commented out, and can be enabled in the future. - The readahead functionality This is abused in kernel. Remove it completely. With the core function in place, btrfs developers should feel at home now. This also crossports supporting code like btrfs_previous_item() to ctree.[ch]. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport struct btrfs_root to ctree.hQu Wenruo1-0/+17
Crossport struct btrfs_root to ctree.h from btrfs-progs, with write related members deleted. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Rename btrfs_root to __btrfs_rootQu Wenruo8-34/+34
This is to avoid naming conflicts between extent buffer based btrfs_root. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Rename struct btrfs_path to struct __btrfs_pathQu Wenruo9-44/+44
To avoid name conflicting between the extent buffer based btrfs_path from btrfs-progs, rename struct btrfs_path to struct __btrfs_path. Also rename btrfs_free_path() to __btrfs_free_path() to avoid conflicts. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport read_tree_block() from btrfs-progsQu Wenruo5-8/+602
This is the one of the basic stone function for btrfs, which: - Resolves the chunk mappings - Reads data from disk - Does various sanity check With read_tree_block(), we can finally crossport needed btrfs btree operations to U-Boot. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport volumes.[ch] from btrfs-progsQu Wenruo5-1/+1081
This patch crossports volumes.[ch] from btrfs-progs, including: - btrfs_map_block() The core mechanism to map btrfs logical address to physical address. This version includes multi-device support, along with RAID56 support. - btrfs_scan_one_device() This is the function to register one btrfs device to the list. This is the main part of the multi-device btrfs assembling process. Although we're not going to support multiple devices until U-Boot allows us to scan one device without actually opening it. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz> [trini: Use %zu in a debug print to avoid warning] Signed-off-by: Tom Rini <trini@konsulko.com>
2020-09-07fs: btrfs: Crossport structure accessor into ctree.hQu Wenruo3-95/+1064
This brings all structure accessors from btrfs-progs/ctree.h, as in kernel's ctree.h. All these accessors handle the endian convert at runtime, and since all of them are defined as static inline functions, those which aren't used won't take space in resulting binary. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport extent-io.[ch] from btrfs-progsQu Wenruo3-1/+1019
This brings the extent_io_tree infrastructure, with which we can finally bring in proper btrfs_fs_info structure to ctree.h. With read/write_extent_buffer() implemented we also backport read/write_eb_member() to ctree.h. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport extent-cache.[ch] from btrfs-progsQu Wenruo2-0/+422
This patch implements an infrastructure to insert/search/merge an extent range (with variable length). This provides the basis for later extent buffer cache used in btrfs. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport rbtree-utils from btrfs-progsQu Wenruo3-1/+138
This is needed for incoming extent-cache infrastructure. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Crossport btrfs_read_dev_super() from btrfs-progsQu Wenruo8-259/+378
This patch uses generic code from btrfs-progs to read one super block from block device. To support the btrfs-progs coding style, the following is also crossported: - BTRFS_SETGET_FUNC for btrfs_super_block - btrfs_check_super() function - Move btrfs_read_superblock() to disk-io.[ch] Since super.c only contains pretty small amount of code, and the extra check will be covered in later root read patches. Differences between this implementation and btrfs-progs: - No sbflags/sb_bytenr support Since we only need to read the primary super block (like kernel), sbflags/sb_bytenr used by super block recovery is not needed. This also changes the following behavior of U-Boot btrfs: - Only reads the primary super block The old implementation reads all 3 super blocks, and also one non-existing backup. This is not correct, especially if there is another filesystem created on the device but old superblocks are not rewritten. Just like kernel, we only check the primary super block. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz> [trini: Change error to be a define in compat.h] Signed-off-by: Tom Rini <trini@konsulko.com>
2020-09-07fs: btrfs: Add more checksum algorithmsQu Wenruo10-62/+130
This mostly crossports crypto/hash.[ch] from btrfs-progs. The differences are: - No blake2 support No blake2 related library in U-Boot yet. - Use uboot xxhash/sha256 directly No need to implement the code as U-Boot has already provided the interface. This adds the support for the following csums: - SHA256 - XXHASH Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-07fs: btrfs: Sync btrfs_btree.h from kernelQu Wenruo7-982/+1343
This version includes all needed on-disk format from kernel. Only need to modify the include headers for U-Boot, everything else is untouched. Also, since U-Boot btrfs is using a different endian convert timing (at tree block read time), it needs some forced type conversion before proper crossport. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2020-09-06fs: convert error and debug messages to logHeinrich Schuchardt2-14/+18
Use log functions for error and debug messages of the file-system. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-24fs/squashfs: Fix Coverity Scan defectsJoao Marcos Costa3-12/+36
Fix defects such as uninitialized variables and untrusted pointer operations. Most part of the tainted variables and the related defects actually comes from Linux's macro get_unaligned_le**, extensively used in SquashFS code. Add sanity checks for those variables. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-24fs/squashfs: add support for LZO decompressionJoao Marcos Costa1-0/+25
Add call to lzo's lzo1x_decompress_safe() into sqfs_decompress(). U-Boot's LZO sources may still have some unsolved issues that could make the decompression crash when dealing with fragmented files, so those should be avoided. The "-no-fragments" option can be passed to mksquashfs. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-24fs/squashfs: add support for ZSTD decompressionJoao Marcos Costa2-0/+45
Add call to ZSTD's ZSTD_decompressDCtx(). In this use case, the caller can upper bound the decompressed size, which will be the SquashFS data block (or metadata block) size, so there is no need to use streaming API. Add ZSTD's worskpace to squashfs_ctxt structure. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-24fs/squashfs: replace sqfs_decompress() parameterJoao Marcos Costa3-20/+14
Replace 'u16 comp_type' by a reference to squashfs_ctxt structure. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-24fs/squashfs: Add init and clean-up functions to decompressionJoao Marcos Costa4-10/+51
Add sqfs_decompressor_init() and sqfs_decompressor_cleanup(). These functions are called respectively in sqfs_probe() and sqfs_close(). For now, only ZSTD requires an initialization logic. ZSTD support will be added in a follow-up commit. Move squashfs_ctxt definition to sqfs_filesystem.h. This structure is passed to sqfs_decompressor_init() and sqfs_decompressor_cleanup(), so it can no longer be local to sqfs.c. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-07fs/fs.c: add symbolic link case to fs_ls_generic()Joao Marcos Costa1-0/+3
Adds an 'else if' statement inside the loop to check for symbolic links. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-07fs/squashfs: add support for zlib decompressionJoao Marcos Costa1-0/+30
Add call to zlib's 'uncompress' function. Add function to display the right error message depending on the decompression's return value. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-07include/u-boot, lib/zlib: add sources for zlib decompressionJoao Marcos Costa1-0/+1
Add zlib (v1.2.11) uncompr() function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-07fs/squashfs: new filesystemJoao Marcos Costa12-0/+2256
Add support for SquashFS filesystem. Right now, it does not support compression but support for zlib will be added in a follow-up commit. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
2020-08-04fs/fat/fat.c: Do not perform zero block reads if there are no blocks leftJason Wessel1-1/+4
While using u-boot with qemu's virtio driver I stumbled across a problem reading files less than sector size. On the real hardware the block reader seems ok with reading zero blocks, and while we could fix the virtio host side of qemu to deal with a zero block read instead of crashing, the u-boot fat driver should not be doing zero block reads in the first place. If you ask hardware to read zero blocks you are just going to get zero data. There may also be other hardware that responds similarly to the virtio interface so this is worth fixing. Without the patch I get the following and have to restart qemu because it dies. --------------------------------- => fatls virtio 0:1 30 cmdline.txt => fatload virtio 0:1 ${loadaddr} cmdline.txt qemu-system-aarch64: virtio: zero sized buffers are not allowed --------------------------------- With the patch I get the expected results. --------------------------------- => fatls virtio 0:1 30 cmdline.txt => fatload virtio 0:1 ${loadaddr} cmdline.txt 30 bytes read in 11 ms (2 KiB/s) => md.b ${loadaddr} 0x1E 40080000: 64 77 63 5f 6f 74 67 2e 6c 70 6d 5f 65 6e 61 62 dwc_otg.lpm_enab 40080010: 6c 65 3d 30 20 72 6f 6f 74 77 61 69 74 0a le=0 rootwait. --------------------------------- Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2020-07-17fs: error handling in do_load()Heinrich Schuchardt1-5/+7
If a file cannot be loaded, show an error message. Set the EFI boot device only after successfully loading a file. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-11fs/fat: reduce data size for FAT_WRITEHeinrich Schuchardt1-2/+7
Allocated tmpbuf_cluster dynamically to reduce the data size added by compiling with CONFIG_FAT_WRITE. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-07-07fs: fat_write: fix short name creation.Heinrich Schuchardt1-3/+12
Truncate file names if the buffer size is exceeded to avoid a buffer overflow. Use Sphinx style function description. Add a TODO comment. Reported-by: CID 303779 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-07cmd: fs: Add command to list supported fs typesNiel Fourie1-0/+20
Added command "fstypes" to list supported/included filesystems. Signed-off-by: Niel Fourie <lusus@denx.de> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Limit to sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-07fs: fat: fix fat iterationChristian Gmeiner1-3/+1
According to the FAT specification it is valid to have files with an attribute value of 0x0. This fixes a regression where different U-Boot versions are showing different amount of files on the same storage device. With this change U-Boot shows the same number of files and folders as Linux and Windows. Fixes: 39606d462c ("fs: fat: handle deleted directory entries correctly") Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2020-05-27cbfs: Don't require the CBFS size with cbfs_init_mem()Simon Glass1-4/+6
The size is not actually used since it is present in the header. Drop this parameter. Also tidy up error handling while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Allow reading a file from a CBFS given its base addrSimon Glass1-0/+13
Currently we support reading a file from CBFS given the address of the end of the ROM. Sometimes we only know the start of the CBFS. Add a function to find a file given that. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Change file_cbfs_find_uncached() to return an errorSimon Glass1-21/+27
This function currently returns a node pointer so there is no way to know the error code. Also it uses data in BSS which seems unnecessary since the caller might prefer to use a local variable. Update the function and split its body out into a separate function so we can use it later. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>