mirror of
https://github.com/littlefs-project/littlefs-fuse.git
synced 2025-10-14 02:27:38 +08:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user