Skip to content

Commit

Permalink
f2fs: Add support for reporting a fake kernel version to fsck
Browse files Browse the repository at this point in the history
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>
Change-Id: I65974f63d81171947399ff31b22fb9e95d14a6f3

Signed-off-by: Carlos Jimenez (JavaShin-X) <javashin1986@gmail.com>

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) <javashin1986@gmail.com>
Signed-off-by: TogoFire <italomellopereira@gmail.com>
  • Loading branch information
kdrag0n authored and TogoFire committed Aug 23, 2023
1 parent 801cfee commit d8602ce
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
20 changes: 20 additions & 0 deletions fs/f2fs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

22 changes: 22 additions & 0 deletions kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d8602ce

Please sign in to comment.