aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJP Abgrall <jpa@google.com>2014-06-13 13:19:20 -0700
committerJP Abgrall <jpa@google.com>2014-06-30 13:43:31 -0700
commitce2c9c36924b4fc3786cd0e6440031d788f641aa (patch)
treeaf6e87c2c43edd9d2a97771499cc79e37ecdb713
parent1ddf6367a3b5e8e586dee1bcbf9c363439ea3ec8 (diff)
downloadf2fs-tools-ce2c9c36924b4fc3786cd0e6440031d788f641aa.tar.gz
libf2fs: move the finalize_device() into the io lib.
This is required so that libf2fs.c can be used against any kind of device (E.g. an in-memory sparse file) just by linking against something that provides the libf2fs_io.c functions. libf2fs is currently libf2fs.c + libf2fs_io.c Change-Id: I65451596e6b9c654b1ff356de4812d113e80dda8 Signed-off-by: JP Abgrall <jpa@google.com>
-rw-r--r--lib/libf2fs.c12
-rw-r--r--lib/libf2fs_io.c13
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index b71ec90..f41e8f4 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -488,15 +488,3 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
return 0;
}
-void f2fs_finalize_device(struct f2fs_configuration *c)
-{
- /*
- * We should call fsync() to flush out all the dirty pages
- * in the block device page cache.
- */
- if (fsync(c->fd) < 0)
- MSG(0, "\tError: Could not conduct fsync!!!\n");
-
- if (close(c->fd) < 0)
- MSG(0, "\tError: Failed to close device file!!!\n");
-}
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index c6f175c..9b6789c 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -69,3 +69,16 @@ int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks)
{
return dev_read(buf, addr * F2FS_BLKSIZE, nr_blks * F2FS_BLKSIZE);
}
+
+void f2fs_finalize_device(struct f2fs_configuration *c)
+{
+ /*
+ * We should call fsync() to flush out all the dirty pages
+ * in the block device page cache.
+ */
+ if (fsync(c->fd) < 0)
+ MSG(0, "\tError: Could not conduct fsync!!!\n");
+
+ if (close(c->fd) < 0)
+ MSG(0, "\tError: Failed to close device file!!!\n");
+}