mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 01:59:54 +00:00
mkfs.f2fs: set project quota by default for -g android for v4.14+
commit 0d3d26dd26f528edbfa972cad3439daa2972020d category: bugfix issue: #I6VAS0 CVE: NA Signed-off-by: DongSenhao <dongsenhao2@huawei.com> --------------------------------------- With this patch, "-g android" enables project quota only by default, if the kernel is over v4.14. Otherwise, it enables usr/grp/proj all together. 1) -O quota : enables usr/grp 2) -O project_quota -O extra_attr : enabled prj 3) -O quota -O project_quota -O extra_attr : enables usr/grp/proj 4) -g android : enables proj (4.14+), usr/grp/proj (old kernel) 5) -g android -O project_quota -O extra_attr : enables usr/grp/proj Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
parent
2ecd0c220f
commit
55c68bc9b9
@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef ANDROID_WINDOWS_HOST
|
||||
@ -33,6 +34,9 @@
|
||||
#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;
|
||||
@ -106,11 +110,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;
|
||||
@ -120,8 +147,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user