]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: copy crtime correctly now that it's timespec64
authorDarrick J. Wong <djwong@kernel.org>
Fri, 7 May 2021 14:42:17 +0000 (10:42 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 7 May 2021 14:42:17 +0000 (10:42 -0400)
The incore i_mtime and di_crtime are both timespec64 now, which means
that tv_sec is a 64-bit value.  Don't cast that to int32_t when we're
creating an inode, because we'll end up truncating the creation time
incorrectly, should an xfsprogs of this vintage make it to 2039. :P

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/util.c

index 1025ad2462989685769bf28b1cebbc77ae7f7a26..a49aee9e7e1a1eeaef64d3c15f7d856f0688051c 100644 (file)
@@ -290,8 +290,7 @@ libxfs_init_new_inode(
                VFS_I(ip)->i_version = 1;
                ip->i_d.di_flags2 = pip ? ip->i_mount->m_ino_geo.new_diflags2 :
                                xfs_flags2diflags2(ip, fsx->fsx_xflags);
-               ip->i_d.di_crtime.tv_sec = (int32_t)VFS_I(ip)->i_mtime.tv_sec;
-               ip->i_d.di_crtime.tv_nsec = (int32_t)VFS_I(ip)->i_mtime.tv_nsec;
+               ip->i_d.di_crtime = VFS_I(ip)->i_mtime; /* struct copy */
                ip->i_d.di_cowextsize = pip ? 0 : fsx->fsx_cowextsize;
        }