f2fs-tools: fall back to the original version check when clock_gettime is not supported

In lower versions than macOS 10.12, they don't support clock_gettime
function. It breaks the build, so we need to fall back to the original
kernel version check algorithm, in that case.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Daeho Jeong 2021-09-28 13:46:58 -07:00 committed by Jaegeuk Kim
parent 1603a3d1de
commit 99bc49736b

View File

@ -975,6 +975,16 @@ int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr)
MSG(0, "Info: MKFS version\n \"%s\"\n", c.init_version);
MSG(0, "Info: FSCK version\n from \"%s\"\n to \"%s\"\n",
c.sb_version, c.version);
#if defined(__APPLE__)
if (!c.no_kernel_check &&
memcmp(c.sb_version, c.version, VERSION_NAME_LEN)) {
c.auto_fix = 0;
c.fix_on = 1;
memcpy(sbi->raw_super->version,
c.version, VERSION_NAME_LEN);
update_superblock(sbi->raw_super, SB_MASK(sb_addr));
}
#else
if (!c.no_kernel_check) {
struct timespec t;
u32 prev_time, cur_time, time_diff;
@ -1007,6 +1017,7 @@ int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr)
update_superblock(sbi->raw_super, SB_MASK(sb_addr));
}
out:
#endif
print_sb_state(sbi->raw_super);
return 0;
}