Merge branch 'bugfix/vfs_fat_(p)write_on_diskfull' into 'master'

vfs: bugfix vfs_fat_write/pwrite upon disk-full

Closes IDFGH-2995

See merge request espressif/esp-idf!17515
pull/11508/head
Vamshi Gajjela 2022-03-22 21:07:42 +08:00
commit edb66b674f
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -369,6 +369,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);
@ -453,6 +457,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 {