OSDN Git Service

Handle I/O error in exfat_flush().
authorresver@gmail.com <resver@gmail.com@60bc1c72-a15a-11de-b98f-4500b42dc123>
Tue, 6 Aug 2013 20:16:20 +0000 (20:16 +0000)
committerresver@gmail.com <resver@gmail.com@60bc1c72-a15a-11de-b98f-4500b42dc123>
Tue, 6 Aug 2013 20:16:20 +0000 (20:16 +0000)
git-svn-id: http://exfat.googlecode.com/svn/trunk@380 60bc1c72-a15a-11de-b98f-4500b42dc123

fuse/main.c
libexfat/cluster.c
libexfat/exfat.h
libexfat/node.c

index 333c2c4..e33060d 100644 (file)
@@ -163,7 +163,9 @@ static int fuse_exfat_fsync(const char* path, int datasync,
        rc = exfat_flush_node(&ef, get_node(fi));
        if (rc != 0)
                return rc;
-       exfat_flush(&ef);
+       rc = exfat_flush(&ef);
+       if (rc != 0)
+               return rc;
        return exfat_fsync(ef.dev);
 }
 
index b4189c6..5cabdbb 100644 (file)
@@ -136,17 +136,20 @@ static cluster_t find_bit_and_set(bitmap_t* bitmap, size_t start, size_t end)
        return EXFAT_CLUSTER_END;
 }
 
-void exfat_flush(struct exfat* ef)
+int exfat_flush(struct exfat* ef)
 {
        if (ef->cmap.dirty)
        {
-               /* FIXME handle I/O error */
                if (exfat_pwrite(ef->dev, ef->cmap.chunk,
                                BMAP_SIZE(ef->cmap.chunk_size),
                                exfat_c2o(ef, ef->cmap.start_cluster)) < 0)
-                       exfat_bug("failed to write clusters bitmap");
+               {
+                       exfat_error("failed to write clusters bitmap");
+                       return -EIO;
+               }
                ef->cmap.dirty = false;
        }
+       return 0;
 }
 
 static bool set_next_cluster(const struct exfat* ef, bool contiguous,
index 5a4cff4..50f690c 100644 (file)
@@ -166,7 +166,7 @@ cluster_t exfat_next_cluster(const struct exfat* ef,
                const struct exfat_node* node, cluster_t cluster);
 cluster_t exfat_advance_cluster(const struct exfat* ef,
                struct exfat_node* node, uint32_t count);
-void exfat_flush(struct exfat* ef);
+int exfat_flush(struct exfat* ef);
 int exfat_truncate(struct exfat* ef, struct exfat_node* node, uint64_t size,
                bool erase);
 uint32_t exfat_count_free_clusters(const struct exfat* ef);
index 0e66fc3..fea371b 100644 (file)
@@ -62,7 +62,9 @@ void exfat_put_node(struct exfat* ef, struct exfat_node* node)
                        exfat_truncate(ef, node, 0, true);
                        free(node);
                }
-               exfat_flush(ef);
+               /* FIXME handle I/O error */
+               if (exfat_flush(ef) != 0)
+                       exfat_bug("flush failed");
        }
 }