X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Ffuse-exfat.git;a=blobdiff_plain;f=libexfat%2Fcluster.c;fp=libexfat%2Fcluster.c;h=4ee6135fd84f152040188bc0d7041cb7a9065850;hp=0f2e91b07317e4bfbb9bc180b180a54021bfa7c3;hb=aa03032454625361e1abc1cf80f4db0492ae5b81;hpb=b8b3f5e8940dd7a0ce964dfecd8c6c6139dab421 diff --git a/libexfat/cluster.c b/libexfat/cluster.c index 0f2e91b..4ee6135 100644 --- a/libexfat/cluster.c +++ b/libexfat/cluster.c @@ -3,7 +3,7 @@ exFAT file system implementation library. Free exFAT implementation. - Copyright (C) 2010-2018 Andrew Nayenko + Copyright (C) 2010-2023 Andrew Nayenko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -426,9 +426,14 @@ int exfat_truncate(struct exfat* ef, struct exfat_node* node, uint64_t size, if (erase) { - rc = erase_range(ef, node, node->size, size); + rc = erase_range(ef, node, node->valid_size, size); if (rc != 0) return rc; + node->valid_size = size; + } + else + { + node->valid_size = MIN(node->valid_size, size); } exfat_update_mtime(node);