int exfat_open(const char* spec, int ro);
int exfat_close(int fd);
+int exfat_fsync(int fd);
void exfat_pread(int fd, void* buffer, size_t size, off_t offset);
void exfat_pwrite(int fd, const void* buffer, size_t size, off_t offset);
ssize_t exfat_generic_pread(const struct exfat* ef, struct exfat_node* node,
return 0;
}
+int exfat_fsync(int fd)
+{
+ if (fsync(fd) != 0)
+ {
+ exfat_error("fsync failed");
+ return 1;
+ }
+ return 0;
+}
+
void exfat_pread(int fd, void* buffer, size_t size, off_t offset)
{
if (pread(fd, buffer, size, offset) != size)
static int commit_super_block(const struct exfat* ef)
{
exfat_pwrite(ef->fd, ef->sb, sizeof(struct exfat_super_block), 0);
- if (fsync(ef->fd) < 0)
- {
- exfat_error("fsync failed");
- return 1;
- }
- return 0;
+ return exfat_fsync(ef->fd);
}
static int prepare_super_block(const struct exfat* ef)
printf("Flushing... ");
fflush(stdout);
- if (fsync(fd) < 0)
+ if (exfat_fsync(fd) != 0)
{
exfat_close(fd);
- exfat_error("fsync failed");
return 1;
}
puts("done.");