aboutsummaryrefslogtreecommitdiffstats
path: root/mkfs/f2fs_format_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'mkfs/f2fs_format_utils.c')
-rw-r--r--mkfs/f2fs_format_utils.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
index 5e466bc..6792ce0 100644
--- a/mkfs/f2fs_format_utils.c
+++ b/mkfs/f2fs_format_utils.c
@@ -4,9 +4,7 @@
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * Dual licensed under the GPL or LGPL version 2 licenses.
*/
#define _LARGEFILE64_SOURCE
@@ -14,23 +12,16 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <linux/fs.h>
+#ifndef ANDROID
+#include "f2fs_fs.h"
+#else
#include "include/f2fs_fs.h"
+#endif
-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");
-
-}
+#ifdef HAVE_LINUX_FS_H
+#include <linux/fs.h>
+#endif
int f2fs_trim_device()
{
@@ -48,14 +39,20 @@ int f2fs_trim_device()
return -1;
}
+#if defined(WITH_BLKDISCARD) && defined(BLKDISCARD)
MSG(0, "Info: Discarding device\n");
if (S_ISREG(stat_buf.st_mode))
return 0;
else if (S_ISBLK(stat_buf.st_mode)) {
- if (ioctl(config.fd, BLKDISCARD, &range) < 0)
+ if (ioctl(config.fd, BLKDISCARD, &range) < 0) {
MSG(0, "Info: This device doesn't support TRIM\n");
+ } else {
+ MSG(0, "Info: Discarded %lu sectors\n",
+ config.total_sectors);
+ }
} else
return -1;
+#endif
return 0;
}