Skip to content

Commit 8db26e9

Browse files
authored
Merge pull request #85 from utsavm9/read_return_zero
lfs_fuse_bd: Avoid being stuck in loop when read syscall returns 0
2 parents d4066cf + b590d66 commit 8db26e9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lfs_fuse.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ int lfs_fuse_releasedir(const char *path, struct fuse_file_info *fi) {
264264
int lfs_fuse_readdir(const char *path, void *buf,
265265
fuse_fill_dir_t filler, off_t offset,
266266
struct fuse_file_info *fi) {
267-
267+
268268
lfs_dir_t *dir = (lfs_dir_t*)fi->fh;
269269
struct stat s;
270270
struct lfs_info info;
@@ -545,13 +545,13 @@ int lfs_fuse_opt_proc(void *data, const char *arg,
545545
case KEY_MIGRATE:
546546
migrate = true;
547547
return 0;
548-
548+
549549
case KEY_HELP:
550550
fprintf(stderr, help_text, args->argv[0]);
551551
fuse_opt_add_arg(args, "-ho");
552552
fuse_main(args->argc, args->argv, &lfs_fuse_ops, NULL);
553553
exit(1);
554-
554+
555555
case KEY_VERSION:
556556
fprintf(stderr, "littlefs-fuse version: v%d.%d\n",
557557
LFS_FUSE_VERSION_MAJOR, LFS_FUSE_VERSION_MINOR);

lfs_fuse_bd.c

Lines changed: 2 additions & 1 deletion
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;
@@ -135,4 +137,3 @@ int lfs_fuse_bd_sync(const struct lfs_config *cfg) {
135137

136138
return 0;
137139
}
138-

0 commit comments

Comments
 (0)