aboutsummaryrefslogtreecommitdiff
path: root/fs
AgeCommit message (Collapse)Author
2020-12-10fs: fat: fat_find_empty_dentries()Heinrich Schuchardt
Provide a function to find a series of empty directory entries. The current directory is scanned for deleted entries. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: flush new directory clusterHeinrich Schuchardt
When handling long file names directory entries may be split over multiple clusters. We must make sure that new clusters are zero filled on disk. When allocating a new cluster for a directory flush it. The flushing should be executed before updating the FAT. This way if flushing fails, we still have a valid directory structure. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: set start cluster for root directoryHeinrich Schuchardt
When iterating over a child directory we set itr->start_clust. Do the same when over the root directory. When looking for deleted directory entries or existing short names we will have to iterate over directories a second and third time. With this patch we do not need any special logic for the root directory. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: dentry iterator for fill_dir_slot()Heinrich Schuchardt
For reusing deleted directory entries we have to adjust the function called to step to the next directory entry. This patch alone is not enough to actually reuse deleted directory entries as the fill_dir_slot() is still called with first never used directory entry. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: generate unique short namesHeinrich Schuchardt
File names must be unique within their directory. So before assigning a short name we must check that it is unique. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: call set_name() only onceHeinrich Schuchardt
In set_name() we select the short name. Once this is correctly implemented this will be a performance intensive operation because we need to check that the name does not exist yet. So set_name should only be called once. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: pass shortname to fill_dir_slotHeinrich Schuchardt
Currently we pass the short name via the directory iterator. Pass it explicitly as a parameter. This removes the requirement to set the short name in the iterator before writing the long name. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: create correct short namesHeinrich Schuchardt
The current function set_name() used to create short names has the following deficiencies resolved by this patch: * Long names (e.g. FOO.TXT) are stored even if a short name is enough. * Short names with spaces are created, e.g. "A ~1.TXT". * Short names with illegal characters are created, e.g. "FOO++BAR". * Debug output does not not consider that the short file name has no concluding '\0'. The solution for the following bug is split of into a separate patch: * Short file names must be unique. This patch only provides the loop over possible short file names. Fixes: c30a15e590c ("FAT: Add FAT write feature") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: export fat_next_cluster()Heinrich Schuchardt
Rename function next_cluster() to fat_next_cluster() and export it. When creating a new directory entries we should reuse deleted entries. This requires re-scanning the directory. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10fs: fat: correct first cluster for '..'Heinrich Schuchardt
The FAT specification [1] requires that for a '..' directory entry pointing to the root directory the fields DIR_FstClusHi and DIR_FstClusLo are 0. [1] Microsoft FAT Specification, Microsoft Corporation, August 30 2005 Fixes: 31a18d570d96 ("fs: fat: support mkdir") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
2020-11-29fs: fat: use ATTR_ARCH instead of anonymous 0x20Heinrich Schuchardt
Using constants instead of anonymous numbers increases code readability. Fixes: 704df6aa0a28 ("fs: fat: refactor write interface for a file offset") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-11-29fs: fat: directory entries starting with 0x05Heinrich Schuchardt
0x05 is used as replacement letter for 0xe5 at the first position of short file names. We must not skip over directory entries starting with 0x05. Cf. Microsoft FAT Specification, August 30 2005 Fixes: 39606d462c97 ("fs: fat: handle deleted directory entries correctly") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-11-29fs: fat: avoid NULL dereference when root dir is fullHeinrich Schuchardt
When trying to create a file in the full root directory of a FAT32 filesystem a NULL dereference can be observed. When the root directory of a FAT16 filesystem is full fill_dir_slot() must return -1 to signal that a new directory entry could not be allocated. Fixes: cd2d727fff7e ("fs: fat: allocate a new cluster for root directory of fat32") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-11-19fs/squashfs: implement exists() functionRichard Genoud
This permits to find a file and use the distro_bootcmd Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read: remove buggy offset functionalityRichard Genoud
offset is the offset in the file read, not the offset in the destination buffer. If the offset is not null, this will lead to a memory corruption. So, for now, we are returning an error if the offset is used. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read: don't write beyond buffer sizeRichard Genoud
The length of the buffer wasn't taken into account when writing to the given buffer. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_probe: use sqfs_decompressor_init() return valueRichard Genoud
sqfs_decompressor_init() returns a value, so it's better to use it than to force the return value to EINVAL (it could be ENOMEM) Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_probe: reset cur_dev/cur_part_info to NULL on errorRichard Genoud
Resetting the context on error will prevent some checks like: if (!ctx.cur_dev) To pass when the probe method has failed Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_probe: fix possible memory leak on errorRichard Genoud
If SquashFS magic number is invalid, there's a memory leak. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read: fix memory leak on finfo.blk_sizesRichard Genoud
finfo.blk_sizes may not be freed in case of error in the for loop Setting it to null and freeing it at the end makes prevents that from happening. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_get_abs_path: fix possible memory leak on errorRichard Genoud
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>
2020-11-19fs/squashfs: sqfs_get_abs_path: fix error checkRichard Genoud
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>
2020-11-19fs/squashfs: sqfs_frag_lookup: simplify error handlingRichard Genoud
For consistency with other functions. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read: fix another memory leakRichard Genoud
data_buffer was allocated in a loop and freed only once. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read: fix memory leakRichard Genoud
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>
2020-11-19fs/squashfs: sqfs_read: remove useless sqfs_closedir()Richard Genoud
as sqfs_opendir failed, there's no need to call sqfs_closedir Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read: fix dangling pointer dirs->entryRichard Genoud
dirs->entry shouldn't be left dangling as it could be freed twice. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_size: remove useless sqfs_closedir()Richard Genoud
as sqfs_opendir failed, there's no need to call sqfs_closedir Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_size: fix dangling pointer dirs->entryRichard Genoud
dirs->entry shouldn't be left dangling as it could be freed twice. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_concat_tokens: check if malloc succeedsRichard Genoud
memory allocation should always be checked Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read_inode_table: fix dangling pointerRichard Genoud
inode_table should not be left dangling as it may be freed in sqfs_opendir Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_search_dir: fix memory leaksRichard Genoud
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>
2020-11-19fs/squashfs: sqfs_search_dir: fix dangling pointerRichard Genoud
dirs->entry shouldn't be left dangling as it could be freed twice. Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_read_directory_table: fix memory leakRichard Genoud
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>
2020-11-19fs/squashfs: sqfs_split_path: fix memory leak and dangling pointersRichard Genoud
*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>
2020-11-19fs/squashfs: sqfs_closedir: fix memory leakRichard Genoud
sqfs_dirs wasn't freed anywhere. Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: sqfs_opendir: simplify error handlingRichard Genoud
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>
2020-11-19fs/squashfs: sqfs_opendir: fix some memory leaks and dangling pointersRichard Genoud
When trying to load an non-existing file, the cpu hangs! Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
2020-11-19fs/squashfs: fix board hang-up when calling .exists()Richard Genoud
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>
2020-11-19fs: btrfs: initialize @ret to 0 to prevent uninitialized return valueQu Wenruo
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>
2020-11-19fs: btrfs: inode: handle uninitialized type before returning itQu Wenruo
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>
2020-11-19fs/squashfs: Fix index off by 1 for inode SQFS_LDIR_TYPEGerard Koskamp
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>
2020-10-22fs: btrfs: Fix typo in error messageNaoki Hayama
%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>
2020-10-05Merge branch 'next'Tom Rini
Bring in the assorted changes that have been staged in the 'next' branch prior to release. Signed-off-by: Tom Rini <trini@konsulko.com>
2020-09-29fs/squashfs: parameter check sqfs_read_metablock()Heinrich Schuchardt
We should check if the incoming parameter file_mapping is not NULL instead of checking after adding an offset. Reported-by: Coverity CID 307210 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2020-09-21Merge branch 'master' into nextTom Rini
Merge in v2020.10-rc5
2020-09-18fs/squashfs: Fix Coverity Scan defectsJoao Marcos Costa
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 Wenruo
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 Wenruo
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 Wenruo
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>