mkfs.f2fs: add casefolding and project quota config
authorJaegeuk Kim <jaegeuk@kernel.org>
Sat, 18 Jul 2020 03:10:21 +0000 (20:10 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 21 Jul 2020 00:39:02 +0000 (17:39 -0700)
This can be used for Android build support.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
include/f2fs_fs.h
lib/libf2fs.c
mkfs/f2fs_format_main.c

index f60dc0f..3323be1 100644 (file)
@@ -1527,6 +1527,7 @@ extern const struct f2fs_nls_table *f2fs_load_nls_table(int encoding);
 #define F2FS_ENC_UTF8_12_0     1
 
 extern int f2fs_str2encoding(const char *string);
+extern char *f2fs_encoding2str(const int encoding);
 extern int f2fs_get_encoding_flags(int encoding);
 extern int f2fs_str2encoding_flags(char **param, __u16 *flags);
 
index 5937076..55fa391 100644 (file)
@@ -1306,6 +1306,17 @@ int f2fs_str2encoding(const char *string)
        return -EINVAL;
 }
 
+char *f2fs_encoding2str(const int encoding)
+{
+       int i;
+
+       for (i = 0 ; i < ARRAY_SIZE(f2fs_encoding_map); i++)
+               if (f2fs_encoding_map[i].encoding_magic == encoding)
+                       return f2fs_encoding_map[i].name;
+
+       return NULL;
+}
+
 int f2fs_get_encoding_flags(int encoding)
 {
        int i;
index 0d77a77..90c8759 100644 (file)
@@ -89,6 +89,12 @@ static void f2fs_show_info()
 
        if (c.defset == CONF_ANDROID)
                MSG(0, "Info: Set conf for android\n");
+
+       if (c.feature & le32_to_cpu(F2FS_FEATURE_CASEFOLD))
+               MSG(0, "Info: Enable %s with casefolding\n",
+                                       f2fs_encoding2str(c.s_encoding));
+       if (c.feature & le32_to_cpu(F2FS_FEATURE_PRJQUOTA))
+               MSG(0, "Info: Enable Project quota\n");
 }
 
 static void add_default_options(void)
@@ -105,6 +111,14 @@ static void add_default_options(void)
                c.root_uid = c.root_gid = 0;
                break;
        }
+#ifdef CONF_CASEFOLD
+       c.s_encoding = F2FS_ENC_UTF8_12_1;
+       c.feature |= cpu_to_le32(F2FS_FEATURE_CASEFOLD);
+#endif
+#ifdef CONF_PROJID
+       c.feature |= cpu_to_le32(F2FS_FEATURE_PRJQUOTA);
+       c.feature |= cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR);
+#endif
 }
 
 static void f2fs_parse_options(int argc, char *argv[])