btrfs-progs: convert: check for extra timespec support in e2fsprogs

In 5.10 the convert gained support for extended inode time precision,
but this is not available on older distros and breaks build. Add a
configure-time check for the EXT4_EPOCH_MASK macro and add a stub in
case it's not detected.

This means that the 64bit timestamps will not be transferred from the
original filesystem in such environment, at least a warning is printed.

Issue: #344
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-02-24 16:31:11 +01:00
parent ce2de8282b
commit 405e36d53c
2 changed files with 26 additions and 0 deletions

View File

@ -251,6 +251,11 @@ else
AC_DEFINE([HAVE_OWN_FIEMAP_EXTENT_SHARED_DEFINE], [0], [We did not define FIEMAP_EXTENT_SHARED])
fi
HAVE_OWN_EXT4_EPOCH_MASK_DEFINE=0
AX_CHECK_DEFINE([ext2fs/ext2_fs.h], [EXT4_EPOCH_MASK], [],
[HAVE_OWN_EXT4_EPOCH_MASK_DEFINE=1
AC_MSG_WARN([no definition of EXT4_EPOCH_MASK found, probably old e2fsprogs, will use own definition, no 64bit time precision of converted images])])
dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
dnl
dnl The default PKG_CHECK_MODULES() action-if-not-found is end the

View File

@ -692,6 +692,8 @@ static void ext2_copy_inode_item(struct btrfs_inode_item *dst,
memset(&dst->reserved, 0, sizeof(dst->reserved));
}
#if HAVE_OWN_EXT4_EPOCH_MASK_DEFINE
/*
* Copied and modified from fs/ext4/ext4.h
*/
@ -761,6 +763,25 @@ out:
return ret;
}
#else /* HAVE_OWN_EXT4_EPOCH_MASK_DEFINE */
static int ext4_copy_inode_timespec_extra(struct btrfs_inode_item *dst,
ext2_ino_t ext2_ino, u32 s_inode_size,
ext2_filsys ext2_fs)
{
static int warn = 0;
if (!warn) {
warning(
"extended inode (size %u) found but e2fsprogs don't support reading extra timespec",
s_inode_size);
warn = 1;
}
return 0;
}
#endif /* !HAVE_OWN_EXT4_EPOCH_MASK_DEFINE */
static int ext2_check_state(struct btrfs_convert_context *cctx)
{
ext2_filsys fs = cctx->fs_data;