diff options
-rw-r--r-- | METADATA | 4 | ||||
-rw-r--r-- | include/f2fs_fs.h | 3 | ||||
-rw-r--r-- | lib/libf2fs.c | 2 | ||||
-rw-r--r-- | mkfs/f2fs_format.c | 2 | ||||
-rw-r--r-- | mkfs/f2fs_format_main.c | 39 |
5 files changed, 42 insertions, 8 deletions
@@ -12,7 +12,7 @@ third_party { license_type: RESTRICTED last_upgrade_date { year: 2022 - month: 2 - day: 3 + month: 3 + day: 22 } } diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index d236437..412130f 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -41,6 +41,9 @@ #include <inttypes.h> #ifdef HAVE_LINUX_TYPES_H +#ifndef __SANE_USERSPACE_TYPES__ +#define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */ +#endif #include <linux/types.h> #endif #include <sys/types.h> diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 420dfda..94fb91d 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -952,7 +952,7 @@ int get_device_info(int i) c.kd = open("/proc/version", O_RDONLY); #endif if (c.kd < 0) { - MSG(0, "\tInfo: No support kernel version!\n"); + MSG(0, "Info: not exist /proc/version!\n"); c.kd = -2; } } diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 864d285..dba0cec 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -578,10 +578,10 @@ static int f2fs_prepare_super_block(void) if (c.kd >= 0) { dev_read_version(c.version, 0, VERSION_LEN); get_kernel_version(c.version); - MSG(0, "Info: format version with\n \"%s\"\n", c.version); } else { get_kernel_uname_version(c.version); } + MSG(0, "Info: format version with\n \"%s\"\n", c.version); memcpy(sb->version, c.version, VERSION_LEN); memcpy(sb->init_version, c.version, VERSION_LEN); diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 8d4dbe1..bf78756 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include <fcntl.h> #include <string.h> +#include <stdbool.h> #include <unistd.h> #include <sys/stat.h> #ifndef ANDROID_WINDOWS_HOST @@ -24,13 +25,16 @@ #include "config.h" #ifdef HAVE_LIBBLKID -# include <blkid.h> +#include <blkid.h> #endif #include "f2fs_fs.h" #include "quota.h" #include "f2fs_format_utils.h" +#ifdef HAVE_SYS_UTSNAME_H +#include <sys/utsname.h> +#endif #ifdef WITH_ANDROID #include <sparse/sparse.h> extern struct sparse_file *f2fs_sparse_file; @@ -75,7 +79,7 @@ static void mkfs_usage() static void f2fs_show_info() { - MSG(0, "\n\tF2FS-tools: mkfs.f2fs Ver: %s (%s)\n\n", + MSG(0, "\n F2FS-tools: mkfs.f2fs Ver: %s (%s)\n\n", F2FS_TOOLS_VERSION, F2FS_TOOLS_DATE); if (c.heap == 0) @@ -104,11 +108,34 @@ static void f2fs_show_info() MSG(0, "Info: Enable Compression\n"); } +#if defined(ANDROID_TARGET) && defined(HAVE_SYS_UTSNAME_H) +static bool kernel_version_over(unsigned int min_major, unsigned int min_minor) +{ + unsigned int major, minor; + struct utsname uts; + + if ((uname(&uts) != 0) || + (sscanf(uts.release, "%u.%u", &major, &minor) != 2)) + return false; + if (major > min_major) + return true; + if (major == min_major && minor >= min_minor) + return true; + return false; +} +#else +static bool kernel_version_over(unsigned int UNUSED(min_major), + unsigned int UNUSED(min_minor)) +{ + return false; +} +#endif + static void add_default_options(void) { switch (c.defset) { case CONF_ANDROID: - /* -d1 -f -O encrypt -O quota -O verity -w 4096 -R 0:0 */ + /* -d1 -f -w 4096 -R 0:0 */ c.dbg_lv = 1; force_overwrite = 1; c.wanted_sector_size = 4096; @@ -118,8 +145,12 @@ static void add_default_options(void) if (c.feature & cpu_to_le32(F2FS_FEATURE_RO)) return; + /* -O encrypt -O project_quota,extra_attr,{quota} -O verity */ c.feature |= cpu_to_le32(F2FS_FEATURE_ENCRYPT); - c.feature |= cpu_to_le32(F2FS_FEATURE_QUOTA_INO); + if (!kernel_version_over(4, 14)) + c.feature |= cpu_to_le32(F2FS_FEATURE_QUOTA_INO); + c.feature |= cpu_to_le32(F2FS_FEATURE_PRJQUOTA); + c.feature |= cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR); c.feature |= cpu_to_le32(F2FS_FEATURE_VERITY); break; } |