OSDN Git Service

Added exfat_fsync() function that performs fsync against the specified descriptor.
authorresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Tue, 14 Feb 2012 18:05:59 +0000 (18:05 +0000)
committerresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Tue, 14 Feb 2012 18:05:59 +0000 (18:05 +0000)
git-svn-id: http://exfat.googlecode.com/svn/trunk@259 60bc1c72-a15a-11de-b98f-4500b42dc123

libexfat/exfat.h
libexfat/io.c
libexfat/mount.c
mkfs/main.c

index da54f92..9ef29f2 100644 (file)
@@ -122,6 +122,7 @@ void exfat_debug(const char* format, ...)
 
 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,
index 14ef1d0..ebbe547 100644 (file)
@@ -69,6 +69,16 @@ int exfat_close(int fd)
        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)
index 94d9b6e..b06fdd0 100644 (file)
@@ -117,12 +117,7 @@ static int verify_vbr_checksum(void* sector, off_t sector_size, int fd)
 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)
index 69862b4..993ebeb 100644 (file)
@@ -331,10 +331,9 @@ static int mkfs(const char* spec, int sector_bits, int spc_bits,
 
        printf("Flushing... ");
        fflush(stdout);
-       if (fsync(fd) < 0)
+       if (exfat_fsync(fd) != 0)
        {
                exfat_close(fd);
-               exfat_error("fsync failed");
                return 1;
        }
        puts("done.");