public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* Correction to nanosecond timestamp patch for 64-bit arch
@ 2007-06-17 13:02 Kalpak Shah
  2007-06-18 10:09 ` Kalpak Shah
  0 siblings, 1 reply; 3+ messages in thread
From: Kalpak Shah @ 2007-06-17 13:02 UTC (permalink / raw)
  To: linux-ext4; +Cc: Andreas Dilger, Mingming Cao

http://bugzilla.kernel.org/show_bug.cgi?id=5079 mentions the problem with timestamps in ext2/3/4. If the timestamp is set to before epoch, the files have their dates changed on 64-bit partitions.

The corrections from this bug also need to be incorporated in the nanosecond patch. 

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>

Index: linux-2.6.21/include/linux/ext4_fs.h
===================================================================
--- linux-2.6.21.orig/include/linux/ext4_fs.h
+++ linux-2.6.21/include/linux/ext4_fs.h
@@ -366,9 +366,9 @@ static inline __le32 ext4_encode_extra_t
 static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
 {
        if (sizeof(time->tv_sec) > 4)
-	       time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK)
-			       << 32;
-       time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2;
+	       time->tv_sec |= (__u64)((signed)le32_to_cpu(extra) &
+				       EXT4_EPOCH_MASK) << 32;
+       time->tv_nsec = ((signed)le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2;
 }
 
 #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)			       \
@@ -390,7 +390,7 @@ do {									       \
 
 #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)			       \
 do {									       \
-	(inode)->xtime.tv_sec = le32_to_cpu((raw_inode)->xtime);	       \
+	(inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);       \
 	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     \
 		ext4_decode_extra_time(&(inode)->xtime,			       \
 				       raw_inode->xtime ## _extra);	       \
@@ -399,7 +399,8 @@ do {									       \
 #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode)			       \
 do {									       \
 	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime))		       \
-		(einode)->xtime.tv_sec = le32_to_cpu((raw_inode)->xtime);      \
+		(einode)->xtime.tv_sec = 				       \
+				(signed)le32_to_cpu((raw_inode)->xtime);       \
 	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra))	       \
 		ext4_decode_extra_time(&(einode)->xtime,		       \
 				       raw_inode->xtime ## _extra);	       \

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-18 10:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-17 13:02 Correction to nanosecond timestamp patch for 64-bit arch Kalpak Shah
2007-06-18 10:09 ` Kalpak Shah
2007-06-18 10:49   ` Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox