Now df utility behaves properly.
sfs->f_bsize = BLOCK_SIZE(*ef.sb);
sfs->f_frsize = CLUSTER_SIZE(*ef.sb);
sfs->f_blocks = block_count;
- sfs->f_bavail = block_count - ef.sb->allocated_percent * block_count / 100;
+ sfs->f_bavail = (fsblkcnt_t) exfat_count_free_clusters(&ef) *
+ (CLUSTER_SIZE(*ef.sb) / BLOCK_SIZE(*ef.sb));
sfs->f_bfree = sfs->f_bavail;
sfs->f_namemax = EXFAT_NAME_MAX;
node->flags |= EXFAT_ATTRIB_DIRTY;
return 0;
}
+
+uint32_t exfat_count_free_clusters(struct exfat* ef)
+{
+ uint32_t free_clusters = 0;
+ uint32_t i;
+
+ for (i = 0; i < ef->cmap.size; i++)
+ if (BMAP_GET(ef->cmap.chunk, i) == 0)
+ free_clusters++;
+ return free_clusters;
+}
struct exfat_node* node, uint32_t count);
void exfat_flush_cmap(struct exfat* ef);
int exfat_truncate(struct exfat* ef, struct exfat_node* node, uint64_t size);
+uint32_t exfat_count_free_clusters(struct exfat* ef);
void exfat_stat(const struct exfat* ef, const struct exfat_node* node,
struct stat* stbuf);