Skip to content

Commit bcb887a

Browse files
committed
btrfs-progs: convert: handle rename of inode_includes() from e2fsprogs 1.47.1
There is a new release candidate for e2fsprogs https://github.com/tytso/e2fsprogs/releases/tag/v1.47.1-rc2 Linking btrfs-progs v6.8 against this version of e2fsprogs leads to the following compile error: convert/source-ext2.c: In function 'ext4_copy_inode_timespec_extra': convert/source-ext2.c:733:13: warning: implicit declaration of function 'inode_includes' [-Wimplicit-function-declaration] 733 | if (inode_includes(inode_size, i_ ## xtime ## _extra)) { \ | ^~~~~~~~~~~~~~ convert/source-ext2.c:769:9: note: in expansion of macro 'EXT4_COPY_XTIME' 769 | EXT4_COPY_XTIME(atime, dst, tv_sec, tv_nsec); | ^~~~~~~~~~~~~~~ convert/source-ext2.c:733:40: error: 'i_atime_extra' undeclared (first use in this function) 733 | if (inode_includes(inode_size, i_ ## xtime ## _extra)) { \ | ^~ convert/source-ext2.c:769:9: note: in expansion of macro 'EXT4_COPY_XTIME' 769 | EXT4_COPY_XTIME(atime, dst, tv_sec, tv_nsec); | ^~~~~~~~~~~~~~~ convert/source-ext2.c:733:40: note: each undeclared identifier is reported only once for each function it appears in 733 | if (inode_includes(inode_size, i_ ## xtime ## _extra)) { \ | ^~ convert/source-ext2.c:769:9: note: in expansion of macro 'EXT4_COPY_XTIME' 769 | EXT4_COPY_XTIME(atime, dst, tv_sec, tv_nsec); | ^~~~~~~~~~~~~~~ convert/source-ext2.c:733:40: error: 'i_mtime_extra' undeclared (first use in this function) 733 | if (inode_includes(inode_size, i_ ## xtime ## _extra)) { \ | ^~ convert/source-ext2.c:770:9: note: in expansion of macro 'EXT4_COPY_XTIME' 770 | EXT4_COPY_XTIME(mtime, dst, tv_sec, tv_nsec); | ^~~~~~~~~~~~~~~ convert/source-ext2.c:733:40: error: 'i_ctime_extra' undeclared (first use in this function) 733 | if (inode_includes(inode_size, i_ ## xtime ## _extra)) { \ | ^~ convert/source-ext2.c:771:9: note: in expansion of macro 'EXT4_COPY_XTIME' 771 | EXT4_COPY_XTIME(ctime, dst, tv_sec, tv_nsec); | ^~~~~~~~~~~~~~~ convert/source-ext2.c:774:40: error: 'i_crtime_extra' undeclared (first use in this function) 774 | if (inode_includes(inode_size, i_crtime_extra)) { | ^~~~~~~~~~~~~~ from tytso/e2fsprogs@ca8bc92 Fix inode_includes() macro to properly wrap "inode" parameter, and rename to ext2fs_inode_includes() to avoid potential name clashes. Use this to check inode field inclusion in debugfs instead of bare constants for inode field offsets. To fix that use the new prefixed macro and add backward compatibility that would still use inode_includes(). Issue: #785 Signed-off-by: David Sterba <[email protected]>
1 parent 3b89906 commit bcb887a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ AS_IF([test "x$have_ext4_epoch_mask_define" = xno], [
312312
AC_DEFINE([EXT4_EPOCH_BITS], [2],[for encode and decode tv_nsec in ext2 inode])
313313
AC_DEFINE([EXT4_EPOCH_MASK], [((1U << EXT4_EPOCH_BITS) - 1)], [For encode and decode tv_nsec info in ext2 inode])
314314
AC_DEFINE([EXT4_NSEC_MASK], [(~0UL << EXT4_EPOCH_BITS)], [For encode and decode tv_nsec info in ext2 inode])
315-
AC_DEFINE([inode_includes(size, field)],[m4_normalize[(size >= (sizeof(((struct ext2_inode_large *)0)->field) + offsetof(struct ext2_inode_large, field)))]],
315+
# Use name from 1.47.1, backward compatibility is handled in convert/source-ext2.c
316+
AC_DEFINE([ext2fs_inode_includes(size, field)],[m4_normalize[(size >= (sizeof(((struct ext2_inode_large *)0)->field) + offsetof(struct ext2_inode_large, field)))]],
316317
[For encode and decode tv_nsec info in ext2 inode])
317318
],
318319
[AC_MSG_WARN([It seems that ext2_inode_large don't includes tv_nsec related info, probably old e2fsprogs, no 64bit time precision of converted images])],

convert/source-ext2.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,17 @@ static inline void ext4_decode_extra_time(__le32 * tv_sec, __le32 * tv_nsec,
727727
*tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS;
728728
}
729729

730+
/*
731+
* In e2fsprogs < 1.47.1 it's inode_includes, from >= on it's with ext2fs_ prefix.
732+
*/
733+
#ifndef ext2fs_inode_includes
734+
#define ext2fs_inode_includes(size, field) inode_includes(size, field)
735+
#endif
736+
730737
#define EXT4_COPY_XTIME(xtime, dst, tv_sec, tv_nsec) \
731738
do { \
732739
tv_sec = src->i_ ## xtime ; \
733-
if (inode_includes(inode_size, i_ ## xtime ## _extra)) { \
740+
if (ext2fs_inode_includes(inode_size, i_ ## xtime ## _extra)) { \
734741
tv_sec = src->i_ ## xtime ; \
735742
ext4_decode_extra_time(&tv_sec, &tv_nsec, src->i_ ## xtime ## _extra); \
736743
btrfs_set_stack_timespec_sec(&dst->xtime , tv_sec); \
@@ -771,7 +778,7 @@ static int ext4_copy_inode_timespec_extra(struct btrfs_inode_item *dst,
771778
EXT4_COPY_XTIME(ctime, dst, tv_sec, tv_nsec);
772779

773780
tv_sec = src->i_crtime;
774-
if (inode_includes(inode_size, i_crtime_extra)) {
781+
if (ext2fs_inode_includes(inode_size, i_crtime_extra)) {
775782
tv_sec = src->i_crtime;
776783
ext4_decode_extra_time(&tv_sec, &tv_nsec, src->i_crtime_extra);
777784
btrfs_set_stack_timespec_sec(&dst->otime, tv_sec);

0 commit comments

Comments
 (0)