lfs_fuse_bd: Exit when read syscall returns 0

We do an assert check before lseek that the block we are reading
from is valid. read() syscalls only return 0 to signal EOF. This
is not going to happen with valid blocks.

This happens when block device has disconnected. In this case,
ignoring the 0 return value causes littlefs_fuse to remain stuck
in an infinite loop, and the overlying program and shell accessing
the LittleFS mount to be stuck in an uninterruptible sleep.

Signed-off-by: Utsav Munendra <utsavm@meta.com>
This commit is contained in:
Utsav Munendra
2025-09-23 16:43:15 -07:00
parent 38cf2b5d48
commit b590d66918

View File

@@ -83,6 +83,8 @@ int lfs_fuse_bd_read(const struct lfs_config *cfg, lfs_block_t block,
ssize_t res = read(fd, buffer_, (size_t)size);
if (res < 0) {
return -errno;
} else if (res == 0) {
return -EIO;
}
buffer_ += res;