+ return true;
+}
+
+static int commit_super_block(const struct exfat* ef)
+{
+ if (exfat_pwrite(ef->dev, ef->sb, sizeof(struct exfat_super_block), 0) < 0)
+ {
+ exfat_error("failed to write super block");
+ return 1;
+ }
+ return exfat_fsync(ef->dev);
+}
+
+int exfat_soil_super_block(const struct exfat* ef)
+{
+ if (ef->ro)
+ return 0;
+
+ ef->sb->volume_state = cpu_to_le16(
+ le16_to_cpu(ef->sb->volume_state) | EXFAT_STATE_MOUNTED);
+ return commit_super_block(ef);
+}
+
+static void exfat_free(struct exfat* ef)
+{
+ exfat_close(ef->dev); /* first of all, close the descriptor */
+ ef->dev = NULL; /* struct exfat_dev is freed by exfat_close() */
+ free(ef->root);
+ ef->root = NULL;
+ free(ef->zero_cluster);
+ ef->zero_cluster = NULL;
+ free(ef->cmap.chunk);
+ ef->cmap.chunk = NULL;
+ free(ef->upcase);
+ ef->upcase = NULL;
+ free(ef->sb);
+ ef->sb = NULL;