[PATCH v2 2/5] fs: fat: determine_fatent() error handling
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sun Jul 31 13:58:34 CEST 2022
Handle disk full errors.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
v2:
no change
---
fs/fat/fat_write.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index a137e14f41..57522f96a8 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -827,6 +827,8 @@ static int new_dir_table(fat_itr *itr)
unsigned int bytesperclust = mydata->clust_size * mydata->sect_size;
dir_newclust = determine_fatent(mydata, 0);
+ if (dir_newclust < 0)
+ return dir_newclust;
/*
* Flush before updating FAT to ensure valid directory structure
@@ -927,8 +929,8 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
loff_t maxsize, loff_t *gotsize)
{
unsigned int bytesperclust = mydata->clust_size * mydata->sect_size;
- __u32 curclust = START(dentptr);
- __u32 endclust = 0, newclust = 0;
+ int curclust = START(dentptr);
+ int endclust = 0, newclust = 0;
u64 cur_pos, filesize;
loff_t offset, actsize, wsize;
@@ -1069,12 +1071,16 @@ set_clusters:
/* Assure that curclust is valid */
if (!curclust) {
curclust = determine_fatent(mydata, 0);
+ if (curclust < 0)
+ return -1;
set_start_cluster(mydata, dentptr, curclust);
} else {
newclust = get_fatent(mydata, curclust);
if (IS_LAST_CLUST(newclust, mydata->fatsize)) {
newclust = determine_fatent(mydata, curclust);
+ if (newclust < 0)
+ return -1;
set_fatent_value(mydata, curclust, newclust);
curclust = newclust;
} else {
@@ -1095,6 +1101,8 @@ set_clusters:
/* search for consecutive clusters */
while (actsize < filesize) {
newclust = determine_fatent(mydata, endclust);
+ if (newclust < 0)
+ return -1;
if ((newclust - 1) != endclust)
/* write to <curclust..endclust> */
--
2.36.1
More information about the U-Boot
mailing list