diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-11-26 16:10:01 +0100 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-12-10 09:14:59 +0100 |
commit | 1e51c8d64a945946af72099dd469a3320ce02e7c (patch) | |
tree | fce39644a08905d3b21cc8dd5eb943e703a58018 | |
parent | 3049a5106c95781663202c626d2e0f56fa2c6646 (diff) | |
download | u-boot-1e51c8d64a945946af72099dd469a3320ce02e7c.zip u-boot-1e51c8d64a945946af72099dd469a3320ce02e7c.tar.gz u-boot-1e51c8d64a945946af72099dd469a3320ce02e7c.tar.bz2 |
fs: fat: search file should not allocate cluster
Searching for a file is not a write operation. So it should not lead to the
allocation of a new cluster to the directory.
If we reuse deleted entries, we might not even use the new cluster and due
to not flushing it the directory could be corrupted.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-rw-r--r-- | fs/fat/fat_write.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index a029ef8..56ea285 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -1154,10 +1154,12 @@ static void fill_dentry(fsdata *mydata, dir_entry *dentptr, memcpy(dentptr->name, shortname, SHORT_NAME_SIZE); } -/* - * Find a directory entry based on filename or start cluster number - * If the directory entry is not found, - * the new position for writing a directory entry will be returned +/** + * find_directory_entry() - find a directory entry by filename + * + * @itr: directory iterator + * @filename: name of file to find + * Return: directory entry or NULL */ static dir_entry *find_directory_entry(fat_itr *itr, char *filename) { @@ -1180,13 +1182,6 @@ static dir_entry *find_directory_entry(fat_itr *itr, char *filename) return itr->dent; } - /* allocate a cluster for more entries */ - if (!itr->dent && - (!itr->is_root || itr->fsdata->fatsize == 32) && - new_dir_table(itr)) - /* indicate that allocating dent failed */ - itr->dent = NULL; - return NULL; } @@ -1348,12 +1343,6 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer, } } - if (!itr->dent) { - printf("Error: allocating new dir entry\n"); - ret = -EIO; - goto exit; - } - if (pos) { /* No hole allowed */ ret = -EINVAL; @@ -1622,12 +1611,6 @@ int fat_mkdir(const char *new_dirname) } } - if (!itr->dent) { - printf("Error: allocating new dir entry\n"); - ret = -EIO; - goto exit; - } - /* Check if long name is needed */ ndent = set_name(itr, dirname, shortname); if (ndent < 0) { |