- exfat_pwrite(ef->dev, ef->cmap.chunk, (ef->cmap.chunk_size + 7) / 8,
- exfat_c2o(ef, ef->cmap.start_cluster));
- ef->cmap.dirty = false;
+ struct exfat_node* p;
+
+ for (p = node->child; p != NULL; p = p->next)
+ {
+ int rc = flush_nodes(ef, p);
+ if (rc != 0)
+ return rc;
+ }
+ return exfat_flush_node(ef, node);
+}
+
+int exfat_flush(struct exfat* ef)
+{
+ int rc = flush_nodes(ef, ef->root);
+
+ if (ef->cmap.dirty)
+ {
+ if (exfat_pwrite(ef->dev, ef->cmap.chunk,
+ BMAP_SIZE(ef->cmap.chunk_size),
+ exfat_c2o(ef, ef->cmap.start_cluster)) < 0)
+ {
+ exfat_error("failed to write clusters bitmap");
+ return -EIO;
+ }
+ ef->cmap.dirty = false;
+ }
+
+ return rc;