summaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)AuthorFilesLines
2020-09-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs: 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-08fs/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-08fs/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-08include/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-08fs/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-05fs/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-12fs/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-08fs: 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>
2020-05-27cbfs: Return the error code from file_cbfs_init()Simon Glass1-8/+15
We may as well return the error code and use it directly in the command code. CBFS still uses its own error enum which we may be able to remove, but leave it for now. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Record the start address in cbfs_privSimon Glass1-13/+31
The start address of the CBFS is used when scanning for files. It makes sense to put this in our cbfs_priv struct and calculate it when we read the header. Update the code accordingly. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Use void * for the position pointersSimon Glass1-9/+8
It doesn't make sense to use u8 * as the pointer type for accessing the CBFS since we do not access it as bytes, but via structures. Change it to void *, which allows us to avoid a cast. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Unify the two header loadersSimon Glass1-22/+37
These two functions have mostly the same code. Pull this out into a common function. Also make this function zero the private data so that callers don't have to do it. Finally, update cbfs_load_header_ptr() to take the base of the ROM as its parameter, which makes more sense than passing the address of the header within the ROM. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Adjust cbfs_load_header_ptr() to use cbfs_privSimon Glass1-3/+6
This function is strange at the moment in that it takes a header pointer but then accesses the cbfs_s global. Currently clients have their own priv pointer, so update the function to take that as a parameter instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Adjust file_cbfs_load_header() to use cbfs_privSimon Glass1-4/+5
This function is strange at the moment in that it takes a header pointer but then accesses the cbfs_s global. Currently clients have their own priv pointer, so update the function to take that as a parameter instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Adjust return value of file_cbfs_next_file()Simon Glass1-20/+23
At present this uses a true return to indicate it found a file. Adjust it to use 0 for this, so it is consistent with other functions. Update its callers accordingly and add a check for malloc() failure in file_cbfs_fill_cache(). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Use bool type for whether initialisedSimon Glass1-4/+4
At present this uses an int type. U-Boot now supports bool so use this instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Use ulong consistentlySimon Glass1-5/+4
U-Boot uses ulong for addresses but there are a few places in this driver that don't use it. Convert this driver over to follow this convention fully. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-27cbfs: Rename the result variableSimon Glass1-10/+10
At present the result variable in the cbfs_priv is called 'result' as is the local variable in a few functions. Change the latter to 'ret' which is more common in U-Boot and avoids confusion. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-05-19common: Drop linux/bitops.h from common headerSimon Glass3-0/+3
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop linux/stringify.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop linux/bug.h from common headerSimon Glass3-0/+3
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop log.h from common headerSimon Glass31-0/+31
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>