Merge branch 'bugfix/vfs_fat_(p)write_on_diskfull_v4.3' into 'release/v4.3'

vfs: bugfix vfs_fat_write/pwrite upon disk-full (v4.3)

See merge request espressif/esp-idf!17650
This commit is contained in:
Ivan Grokhotkov 2022-04-21 23:12:44 +08:00
commit 9532e1ccc6

View File

@ -375,6 +375,10 @@ static ssize_t vfs_fat_write(void* ctx, int fd, const void * data, size_t size)
}
unsigned written = 0;
res = f_write(file, data, size, &written);
if (((written == 0) && (size != 0)) && (res == 0)) {
errno = ENOSPC;
return -1;
}
if (res != FR_OK) {
ESP_LOGD(TAG, "%s: fresult=%d", __func__, res);
errno = fresult_to_errno(res);
@ -459,6 +463,10 @@ static ssize_t vfs_fat_pwrite(void *ctx, int fd, const void *src, size_t size, o
unsigned wr = 0;
f_res = f_write(file, src, size, &wr);
if (((wr == 0) && (size != 0)) && (f_res == 0)) {
errno = ENOSPC;
return -1;
}
if (f_res == FR_OK) {
ret = wr;
} else {