diff mbox series

[15/26] xfs: redefine xfs_ictimestamp_t

Message ID 160375534433.881414.13405550882427665693.stgit@magnolia
State Accepted
Headers show
Series xfsprogs: widen timestamps to deal with y2038 | expand

Commit Message

Darrick J. Wong Oct. 26, 2020, 11:35 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Source kernel commit: 30e05599219f3c15bd5f24190af0e33cdb4a00e5

Redefine xfs_ictimestamp_t as a uint64_t typedef in preparation for the
bigtime functionality.  Preserve the legacy structure format so that we
can let the compiler take care of the masking and shifting.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_log_format.h |    7 +++++--
 logprint/log_misc.c     |   19 +++++++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h
index e3400c9c71cd..8bd00da6d2a4 100644
--- a/libxfs/xfs_log_format.h
+++ b/libxfs/xfs_log_format.h
@@ -368,10 +368,13 @@  static inline int xfs_ilog_fdata(int w)
  * directly mirrors the xfs_dinode structure as it must contain all the same
  * information.
  */
-typedef struct xfs_ictimestamp {
+typedef uint64_t xfs_ictimestamp_t;
+
+/* Legacy timestamp encoding format. */
+struct xfs_legacy_ictimestamp {
 	int32_t		t_sec;		/* timestamp seconds */
 	int32_t		t_nsec;		/* timestamp nanoseconds */
-} xfs_ictimestamp_t;
+};
 
 /*
  * Define the format of the inode core that is logged. This structure must be
diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index a747cbd360af..47976cdf328a 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -435,6 +435,16 @@  xlog_print_trans_qoff(char **ptr, uint len)
     }
 }	/* xlog_print_trans_qoff */
 
+static inline time64_t
+xlog_extract_dinode_ts(
+	const xfs_ictimestamp_t		its)
+{
+	struct xfs_legacy_ictimestamp	*lits;
+
+	lits = (struct xfs_legacy_ictimestamp *)&its;
+	return (time64_t)lits->t_sec;
+}
+
 void
 xlog_print_dinode_ts(
 	struct xfs_log_dinode	*ldip,
@@ -443,12 +453,13 @@  xlog_print_dinode_ts(
 	const char		*fmt;
 
 	if (compact)
-		fmt = _("atime 0x%x mtime 0x%x ctime 0x%x\n");
+		fmt = _("atime 0x%llx mtime 0x%llx ctime 0x%llx\n");
 	else
-		fmt = _("		atime:%d  mtime:%d  ctime:%d\n");
+		fmt = _("		atime:%lld  mtime:%lld  ctime:%lld\n");
 
-	printf(fmt, ldip->di_atime.t_sec, ldip->di_mtime.t_sec,
-			ldip->di_ctime.t_sec);
+	printf(fmt, xlog_extract_dinode_ts(ldip->di_atime),
+		    xlog_extract_dinode_ts(ldip->di_mtime),
+		    xlog_extract_dinode_ts(ldip->di_ctime));
 }
 
 static void