X-Git-Url: http://git.sven.stormbind.net/?p=sven%2Fexfat-utils.git;a=blobdiff_plain;f=libexfat%2Fcluster.c;h=34f027cc3270a8aa214e56b496bdc3530d80f4a3;hp=523e9fbf523f4adf7df20485d899da26cb578f35;hb=refs%2Ftags%2Fupstream%2F1.2.5;hpb=9420cfdeee25e4d97e7fc6f7cbb286e5089caccb diff --git a/libexfat/cluster.c b/libexfat/cluster.c index 523e9fb..34f027c 100644 --- a/libexfat/cluster.c +++ b/libexfat/cluster.c @@ -3,7 +3,7 @@ exFAT file system implementation library. Free exFAT implementation. - Copyright (C) 2010-2015 Andrew Nayenko + Copyright (C) 2010-2016 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 @@ -67,7 +67,7 @@ static cluster_t s2c(const struct exfat* ef, off_t sector) static uint32_t bytes2clusters(const struct exfat* ef, uint64_t bytes) { uint64_t cluster_size = CLUSTER_SIZE(*ef->sb); - return (bytes + cluster_size - 1) / cluster_size; + return DIV_ROUND_UP(bytes, cluster_size); } cluster_t exfat_next_cluster(const struct exfat* ef, @@ -149,10 +149,13 @@ static int flush_nodes(struct exfat* ef, struct exfat_node* node) return exfat_flush_node(ef, node); } -int exfat_flush(struct exfat* ef) +int exfat_flush_nodes(struct exfat* ef) { - int rc = flush_nodes(ef, ef->root); + return flush_nodes(ef, ef->root); +} +int exfat_flush(struct exfat* ef) +{ if (ef->cmap.dirty) { if (exfat_pwrite(ef->dev, ef->cmap.chunk, @@ -165,7 +168,7 @@ int exfat_flush(struct exfat* ef) ef->cmap.dirty = false; } - return rc; + return 0; } static bool set_next_cluster(const struct exfat* ef, bool contiguous,