f2fs: Add support for reporting a fake kernel version to fsck

fsck.f2fs forces a filesystem fix on boot if it detects that the current
kernel version differs from the one saved in the superblock, which results in
fsck blocking boot for a long time (~35 seconds). This commit provides a
way to report a constant fake kernel version to fsck to avoid triggering
the version check, which is useful if you boot new kernel builds
frequently.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Danny Lin 2020-08-02 02:35:30 -07:00 committed by Ksawlii
parent c0f37aaa23
commit e0f839a996
2 changed files with 43 additions and 0 deletions

View file

@ -175,6 +175,25 @@ config F2FS_SEC_BLOCK_OPERATIONS_DEBUG
If unsure, say N.
config F2FS_REPORT_FAKE_KERNEL_VERSION
bool "Report fake kernel version to fsck.f2fs"
depends on F2FS_FS
help
fsck.f2fs forces a filesystem fix on boot if it detects that the current
kernel version differs from the one saved in the superblock, which results in
fsck taking a long time to run. This option provides a way to report a
constant fake kernel version to fsck to avoid triggering the version check.
If unsure, say N.
config F2FS_FAKE_KERNEL_RELEASE
string "Kernel release for fsck.f2fs"
depends on F2FS_REPORT_FAKE_KERNEL_VERSION
config F2FS_FAKE_KERNEL_VERSION
string "Kernel version for fsck.f2fs"
depends on F2FS_REPORT_FAKE_KERNEL_VERSION
config F2FS_SEC_SUPPORT_DNODE_RELOCATION
bool "DNODE relocation support"
depends on F2FS_FS_COMPRESSION

View file

@ -1271,6 +1271,28 @@ static int override_release(char __user *release, size_t len)
return ret;
}
static int override_version(struct new_utsname __user *name)
{
#ifdef CONFIG_F2FS_REPORT_FAKE_KERNEL_VERSION
int ret;
if (strcmp(current->comm, "fsck.f2fs"))
return 0;
ret = copy_to_user(name->release, CONFIG_F2FS_FAKE_KERNEL_RELEASE,
strlen(CONFIG_F2FS_FAKE_KERNEL_RELEASE) + 1);
if (ret)
return ret;
ret = copy_to_user(name->version, CONFIG_F2FS_FAKE_KERNEL_VERSION,
strlen(CONFIG_F2FS_FAKE_KERNEL_VERSION) + 1);
return ret;
#else
return 0;
#endif
}
SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
{
struct new_utsname tmp;
@ -1285,6 +1307,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
return -EFAULT;
if (override_architecture(name))
return -EFAULT;
if (override_version(name))
return -EFAULT;
return 0;
}