summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
...
* fs/squashfs: sqfs_get_abs_path: fix possible memory leak on errorRichard Genoud2020-11-191-14/+18
| | | | | | | | if sqfs_tokenize(rel_tokens, rc, rel); fails, the function exits without freeing the array base_tokens. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_get_abs_path: fix error checkRichard Genoud2020-11-191-1/+1
| | | | | | | | | the return value of sqfs_tokenize(rel_tokens, rc, rel); wasn't checked. (but "ret" value was !) This is obviouly a typo. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_frag_lookup: simplify error handlingRichard Genoud2020-11-191-12/+16
| | | | | | | For consistency with other functions. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_read: fix another memory leakRichard Genoud2020-11-191-0/+2
| | | | | | data_buffer was allocated in a loop and freed only once. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_read: fix memory leakRichard Genoud2020-11-191-1/+1
| | | | | | | | sqfs_closedir() should be called to free memory allocated by sqfs_opendir() Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_read: remove useless sqfs_closedir()Richard Genoud2020-11-191-1/+0
| | | | | | as sqfs_opendir failed, there's no need to call sqfs_closedir Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_read: fix dangling pointer dirs->entryRichard Genoud2020-11-191-0/+1
| | | | | | dirs->entry shouldn't be left dangling as it could be freed twice. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_size: remove useless sqfs_closedir()Richard Genoud2020-11-191-1/+0
| | | | | | as sqfs_opendir failed, there's no need to call sqfs_closedir Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_size: fix dangling pointer dirs->entryRichard Genoud2020-11-191-0/+2
| | | | | | dirs->entry shouldn't be left dangling as it could be freed twice. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_concat_tokens: check if malloc succeedsRichard Genoud2020-11-191-0/+3
| | | | | | | memory allocation should always be checked Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_read_inode_table: fix dangling pointerRichard Genoud2020-11-191-0/+1
| | | | | | inode_table should not be left dangling as it may be freed in sqfs_opendir Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_search_dir: fix memory leaksRichard Genoud2020-11-191-13/+51
| | | | | | | path, target, res, rem and sym_tokens were not free on error nor success. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_search_dir: fix dangling pointerRichard Genoud2020-11-191-0/+5
| | | | | | dirs->entry shouldn't be left dangling as it could be freed twice. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_read_directory_table: fix memory leakRichard Genoud2020-11-191-14/+17
| | | | | | | pos_list wasn't freed on every error Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_split_path: fix memory leak and dangling pointersRichard Genoud2020-11-191-12/+28
| | | | | | | *file and *dir were not freed on error Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_closedir: fix memory leakRichard Genoud2020-11-191-0/+1
| | | | | | | sqfs_dirs wasn't freed anywhere. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_opendir: simplify error handlingRichard Genoud2020-11-191-15/+12
| | | | | | | Using only one label permits to prevents bugs when moving code around. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: sqfs_opendir: fix some memory leaks and dangling pointersRichard Genoud2020-11-191-8/+29
| | | | | | When trying to load an non-existing file, the cpu hangs! Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
* fs/squashfs: fix board hang-up when calling .exists()Richard Genoud2020-11-191-0/+7
| | | | | | | | | add missing squashfs function to prevent dangling or null pointers. For exemple, when calling test [ -e somefile ], squashfs.exists may be called. Signed-off-by: Richard Genoud <richard.genoud@posteo.net> Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
* fs: btrfs: initialize @ret to 0 to prevent uninitialized return valueQu Wenruo2020-11-191-1/+1
| | | | | | | | | | | In show_dir() if we hit a ROOT_ITEM, we can exit with uninitialized @ret. Fix it by initializing it to 0. Reported-by: Coverity CID 312955 Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
* fs: btrfs: inode: handle uninitialized type before returning itQu Wenruo2020-11-191-1/+5
| | | | | | | | | | | | | | | | | | | | In btrfs_lookup_path() the local variable @type should always be updated after we hit any file/dir. But if @filename is NULL from the very beginning, then we don't initialize it and return it directly. To prevent such problem from happening, we initialize @type to BTRFS_FT_UNKNOWN. For normal execution route, it will get updated for each filename we resolved. Buf if we didn't find any path, we check if the type is still FT_UNKNOWN and ret == 0. If true we know there is something wrong, just return -EUCLEAN to inform the caller. Reported-by: Coverity CID 312958 Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
* fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPEGerard Koskamp2020-11-191-2/+2
| | | | | | | | | | | | | | I've created a squashfs file system with Yocto (it use squashfs-tools) and u-boot command sqfsls give the error:'Error while searching inode: unknown type.' After some digging in the code I found that the index is off by 1. This patch fix this issue and I can successful use the sqfsls command. After search for the squashfs format I found a link talk about a similar issue but this time in the documentation. The link is: https://github.com/AgentD/squashfs-tools-ng/commit/e6588526838caece9529 Signed-off-by: Gerard Koskamp <gerard.koskamp@nedap.com> Tested-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
* fs: btrfs: Fix typo in error messageNaoki Hayama2020-10-221-2/+2
| | | | | | | | %s/occured/occurred/ Signed-off-by: Naoki Hayama <naoki.hayama@lineo.co.jp> Reviewed-by: Marek Behún <kabel@kernel.org> Reviewed-by: Qu Wenruo <wqu@suse.com>
* Merge branch 'next'Tom Rini2020-10-0529-2491/+8523
|\ | | | | | | | | | | | | Bring in the assorted changes that have been staged in the 'next' branch prior to release. Signed-off-by: Tom Rini <trini@konsulko.com>
| * Merge branch 'master' into nextTom Rini2020-09-213-10/+18
| |\ | | | | | | | | | Merge in v2020.10-rc5
| * | fs: btrfs: Cleanup the old implementationQu Wenruo2020-09-0714-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>
| * | fs: btrfs: Imeplement btrfs_list_subvols() using new infrastructureQu Wenruo2020-09-071-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>
| * | fs: btrfs: Introduce function to resolve the path of one subvolumeQu Wenruo2020-09-071-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>
| * | fs: btrfs: Introduce function to resolve path in one subvolumeQu Wenruo2020-09-072-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>
| * | fs: btrfs: Implement btrfs_file_read()Qu Wenruo2020-09-073-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>
| * | fs: btrfs: Introduce lookup_data_extent() for later useQu Wenruo2020-09-071-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>
| * | fs: btrfs: Introduce btrfs_read_extent_inline() and btrfs_read_extent_reg()Qu Wenruo2020-09-074-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>
| * | fs: btrfs: Rename btrfs_file_read() and its callees to avoid name conflictsQu Wenruo2020-09-074-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>
| * | fs: btrfs: Use btrfs_lookup_path() to implement btrfs_exists() and btrfs_size()Qu Wenruo2020-09-071-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>
| * | fs: btrfs: Use btrfs_iter_dir() to replace btrfs_readdir()Qu Wenruo2020-09-074-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>
| * | fs: btrfs: Implement btrfs_lookup_path()Qu Wenruo2020-09-073-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>
| * | fs: btrfs: inode: Allow next_length() to return value > BTRFS_NAME_LENQu Wenruo2020-09-071-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>
| * | fs: btrfs: Use btrfs_readlink() to implement __btrfs_readlink()Qu Wenruo2020-09-072-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>
| * | fs: btrfs: Rename path resolve related functions to avoid name conflictsQu Wenruo2020-09-077-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>
| * | fs: btrfs: Crossport open_ctree_fs_info() from btrfs-progsQu Wenruo2020-09-078-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>
| * | fs: btrfs: Crossport btrfs_read_sys_array() and btrfs_read_chunk_tree()Qu Wenruo2020-09-075-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>
| * | fs: btrfs: Crossport btrfs_search_slot() from btrfs-progsQu Wenruo2020-09-072-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>
| * | fs: btrfs: Crossport struct btrfs_root to ctree.hQu Wenruo2020-09-071-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>
| * | fs: btrfs: Rename btrfs_root to __btrfs_rootQu Wenruo2020-09-078-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>
| * | fs: btrfs: Rename struct btrfs_path to struct __btrfs_pathQu Wenruo2020-09-079-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>
| * | fs: btrfs: Crossport read_tree_block() from btrfs-progsQu Wenruo2020-09-075-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>
| * | fs: btrfs: Crossport volumes.[ch] from btrfs-progsQu Wenruo2020-09-075-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>
| * | fs: btrfs: Crossport structure accessor into ctree.hQu Wenruo2020-09-073-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>
| * | fs: btrfs: Crossport extent-io.[ch] from btrfs-progsQu Wenruo2020-09-073-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>
| * | fs: btrfs: Crossport extent-cache.[ch] from btrfs-progsQu Wenruo2020-09-072-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>