diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-06-13 16:51:32 +0900 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-06-13 17:06:02 +0900 |
commit | 0575dd1c56ef731662687fa5b7817335b14c69ee (patch) | |
tree | ad01145924f7df43673a9b7b5e05c6cd4a0d3ac9 | |
parent | 3ba4ce8950e1a53f760e8ed200ad2b7d13cfa585 (diff) | |
download | android_external_f2fs-tools-0575dd1c56ef731662687fa5b7817335b14c69ee.tar.gz android_external_f2fs-tools-0575dd1c56ef731662687fa5b7817335b14c69ee.tar.bz2 android_external_f2fs-tools-0575dd1c56ef731662687fa5b7817335b14c69ee.zip |
libf2fs, fsck, mkfs: call f2fs_finalize_device before exit
The fsck tool should call f2fs_finalize_device before exit to close the device
file.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fsck/main.c | 3 | ||||
-rw-r--r-- | include/f2fs_fs.h | 1 | ||||
-rw-r--r-- | lib/libf2fs.c | 12 | ||||
-rw-r--r-- | mkfs/f2fs_format.c | 2 | ||||
-rw-r--r-- | mkfs/f2fs_format_main.c | 2 | ||||
-rw-r--r-- | mkfs/f2fs_format_utils.c | 14 | ||||
-rw-r--r-- | mkfs/f2fs_format_utils.h | 1 |
7 files changed, 18 insertions, 17 deletions
diff --git a/fsck/main.c b/fsck/main.c index 5aa3956..46f5d04 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -203,6 +203,9 @@ int main (int argc, char **argv) } f2fs_do_umount(sbi); + + f2fs_finalize_device(&config); + printf("\nDone.\n"); return ret; } diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 4f44866..53b8cb9 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -659,6 +659,7 @@ extern int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len); extern void f2fs_init_configuration(struct f2fs_configuration *); extern int f2fs_dev_is_umounted(struct f2fs_configuration *); extern int f2fs_get_device_info(struct f2fs_configuration *); +extern void f2fs_finalize_device(struct f2fs_configuration *); extern int dev_read(void *, __u64, size_t); extern int dev_write(void *, __u64, size_t); diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 6168c5c..8d6c670 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -493,3 +493,15 @@ 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/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index c7c6971..1568545 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -880,7 +880,5 @@ exit: if (err) MSG(0, "\tError: Could not format the device!!!\n"); - f2fs_finalize_device(); - return err; } diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 2b6c195..19c52e4 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -129,6 +129,8 @@ int main(int argc, char *argv[]) if (f2fs_format_device() < 0) return -1; + f2fs_finalize_device(&config); + MSG(0, "Info: format successful\n"); return 0; diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c index f4c3767..5cc2a32 100644 --- a/mkfs/f2fs_format_utils.c +++ b/mkfs/f2fs_format_utils.c @@ -15,20 +15,6 @@ #include "f2fs_fs.h" -void f2fs_finalize_device() -{ - /* - * We should call fsync() to flush out all the dirty pages - * in the block device page cache. - */ - if (fsync(config.fd) < 0) - MSG(0, "\tError: Could not conduct fsync!!!\n"); - - if (close(config.fd) < 0) - MSG(0, "\tError: Failed to close device file!!!\n"); - -} - int f2fs_trim_device() { unsigned long long range[2]; diff --git a/mkfs/f2fs_format_utils.h b/mkfs/f2fs_format_utils.h index fb731fc..9eb2cea 100644 --- a/mkfs/f2fs_format_utils.h +++ b/mkfs/f2fs_format_utils.h @@ -12,6 +12,5 @@ extern struct f2fs_configuration config; -void f2fs_finalize_device(void); int f2fs_trim_device(void); int f2fs_format_device(void); |