Skip to content

Commit b590d66

Browse files
committed
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>
1 parent 38cf2b5 commit b590d66

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lfs_fuse_bd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ int lfs_fuse_bd_read(const struct lfs_config *cfg, lfs_block_t block,
8383
ssize_t res = read(fd, buffer_, (size_t)size);
8484
if (res < 0) {
8585
return -errno;
86+
} else if (res == 0) {
87+
return -EIO;
8688
}
8789

8890
buffer_ += res;

0 commit comments

Comments
 (0)