mkfs: define DISCARD/SECDISCARD macro
If SECDISCARD/DISCARD is not defined, we can set it.
In Android, we must set -DWITH_BLKDISCARD to discard the partition.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/mkfs/f2fs_format_utils.c b/mkfs/f2fs_format_utils.c
index ddeafeb..d469ce5 100644
--- a/mkfs/f2fs_format_utils.c
+++ b/mkfs/f2fs_format_utils.c
@@ -27,6 +27,13 @@
#include <linux/falloc.h>
#endif
+#ifndef BLKDISCARD
+#define BLKDISCARD _IO(0x12,119)
+#endif
+#ifndef BLKSECDISCARD
+#define BLKSECDISCARD _IO(0x12,125)
+#endif
+
int f2fs_trim_device()
{
unsigned long long range[2];
@@ -54,8 +61,17 @@
#endif
return 0;
} else if (S_ISBLK(stat_buf.st_mode)) {
+#ifdef BLKSECDISCARD
+ if (ioctl(config.fd, BLKSECDISCARD, &range) < 0) {
+ MSG(0, "Info: This device doesn't support BLKSECDISCARD\n");
+ } else {
+ MSG(0, "Info: Secure Discarded %lu sectors\n",
+ config.total_sectors);
+ return 0;
+ }
+#endif
if (ioctl(config.fd, BLKDISCARD, &range) < 0) {
- MSG(0, "Info: This device doesn't support TRIM\n");
+ MSG(0, "Info: This device doesn't support BLKDISCARD\n");
} else {
MSG(0, "Info: Discarded %lu sectors\n",
config.total_sectors);