From d8602ce01c5405a17b009e90372b9cdc832aa045 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Thu, 12 Nov 2020 01:33:47 -0400 Subject: [PATCH] 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 Change-Id: I65974f63d81171947399ff31b22fb9e95d14a6f3 Signed-off-by: Carlos Jimenez (JavaShin-X) ocean stock-kernel = CONFIG_F2FS_REPORT_FAKE_KERNEL_VERSION=y CONFIG_F2FS_FAKE_KERNEL_RELEASE="4.9.206-perf+" CONFIG_F2FS_FAKE_KERNEL_VERSION="#1 SMP PREEMPT Wed Sep 30 23:50:55 CDT 2020 aarch64" Signed-off-by: Carlos Jimenez (JavaShin-X) Signed-off-by: TogoFire --- fs/f2fs/Kconfig | 20 ++++++++++++++++++++ kernel/sys.c | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig index 0eb3fe186b36..d23b0a061fc8 100644 --- a/fs/f2fs/Kconfig +++ b/fs/f2fs/Kconfig @@ -103,3 +103,23 @@ config F2FS_FAULT_INJECTION Test F2FS to inject faults such as ENOMEM, ENOSPC, and so on. 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 + diff --git a/kernel/sys.c b/kernel/sys.c index e4a0277d65a2..3336be257e25 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1143,6 +1143,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;