From: Sven Hoexter Date: Tue, 5 Feb 2013 20:12:10 +0000 (+0100) Subject: Imported Upstream version 1.0.1 X-Git-Tag: upstream/1.0.1^0 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=c970b8dc781ddfc1fc6f7d3890babd2a8fbe028b;p=sven%2Ffuse-exfat.git Imported Upstream version 1.0.1 --- diff --git a/ChangeLog b/ChangeLog index e24b2d6..adbf727 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1.0.1 (2013-02-02) + +* Fixed unexpected removal of a directory if it is moved into itself. +* Fixed "Operation not permitted" error on reading an empty file. + 1.0.0 (2013-01-19) * Fixed crash when renaming a file within a single directory and a new name diff --git a/fuse/main.c b/fuse/main.c index 1527347..b939164 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -155,19 +155,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, off_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, off_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/libexfat/io.c b/libexfat/io.c index 1a555b9..4413aaa 100644 --- a/libexfat/io.c +++ b/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, diff --git a/libexfat/node.c b/libexfat/node.c index cce1de7..bc342b7 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -905,6 +905,23 @@ int exfat_rename(struct exfat* ef, const char* old_path, const char* new_path) exfat_put_node(ef, node); return rc; } + + /* check that target is not a subdirectory of the source */ + if (node->flags & EXFAT_ATTRIB_DIR) + { + struct exfat_node* p; + + for (p = dir; p; p = p->parent) + if (node == p) + { + if (existing != NULL) + exfat_put_node(ef, existing); + exfat_put_node(ef, dir); + exfat_put_node(ef, node); + return -EINVAL; + } + } + if (existing != NULL) { /* remove target if it's not the same node as source */ diff --git a/libexfat/version.h b/libexfat/version.h index b795e91..debd185 100644 --- a/libexfat/version.h +++ b/libexfat/version.h @@ -23,6 +23,6 @@ #define EXFAT_VERSION_MAJOR 1 #define EXFAT_VERSION_MINOR 0 -#define EXFAT_VERSION_PATCH 0 +#define EXFAT_VERSION_PATCH 1 #endif /* ifndef VERSION_H_INCLUDED */