summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--exfat/exfat-fuse/main.c18
-rw-r--r--exfat/libexfat/io.c2
2 files changed, 13 insertions, 7 deletions
diff --git a/exfat/exfat-fuse/main.c b/exfat/exfat-fuse/main.c
index 6771096f3..e50c14a74 100644
--- a/exfat/exfat-fuse/main.c
+++ b/exfat/exfat-fuse/main.c
@@ -154,19 +154,25 @@ static int fuse_exfat_release(const char* path, struct fuse_file_info* fi)
static int fuse_exfat_read(const char* path, char* buffer, size_t size,
off64_t offset, struct fuse_file_info* fi)
{
+ ssize_t ret;
+
exfat_debug("[%s] %s (%zu bytes)", __func__, path, size);
- if (exfat_generic_pread(&ef, get_node(fi), buffer, size, offset) != size)
- return EOF;
- return size;
+ ret = exfat_generic_pread(&ef, get_node(fi), buffer, size, offset);
+ if (ret < 0)
+ return -EIO;
+ return ret;
}
static int fuse_exfat_write(const char* path, const char* buffer, size_t size,
off64_t offset, struct fuse_file_info* fi)
{
+ ssize_t ret;
+
exfat_debug("[%s] %s (%zu bytes)", __func__, path, size);
- if (exfat_generic_pwrite(&ef, get_node(fi), buffer, size, offset) != size)
- return EOF;
- return size;
+ ret = exfat_generic_pwrite(&ef, get_node(fi), buffer, size, offset);
+ if (ret < 0)
+ return -EIO;
+ return ret;
}
static int fuse_exfat_unlink(const char* path)
diff --git a/exfat/libexfat/io.c b/exfat/libexfat/io.c
index 65df63a78..1be028cf3 100644
--- a/exfat/libexfat/io.c
+++ b/exfat/libexfat/io.c
@@ -341,7 +341,7 @@ ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node,
}
if (!ef->ro && !ef->noatime)
exfat_update_atime(node);
- return size - remainder;
+ return MIN(size, node->size - offset) - remainder;
}
ssize_t exfat_generic_pwrite(struct exfat* ef, struct exfat_node* node,