aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorMarkus Rechberger <Markus.Rechberger@amd.com>2007-05-08 03:23:39 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:14:58 -0400
commit4d7bf11d649c72621ca31b8ea12b9c94af380e63 (patch)
treec4a3c11cf6d13210ed344de0ae091d3f7523c689 /fs/ext4
parent8948e11f450e6189a79e47d6051c3d5a0b98e3f3 (diff)
ext2/3/4: fix file date underflow on ext2 3 filesystems on 64 bit systems
Taken from http://bugzilla.kernel.org/show_bug.cgi?id=5079 signed long ranges from -2.147.483.648 to 2.147.483.647 on x86 32bit 10000011110110100100111110111101 .. -2,082,844,739 10000011110110100100111110111101 .. 2,212,122,557 <- this currently gets stored on the disk but when converting it to a 64bit signed long value it loses its sign and becomes positive. Cc: Andreas Dilger <adilger@dilger.ca> Cc: <linux-ext4@vger.kernel.org> Andreas says: This patch is now treating timestamps with the high bit set as negative times (before Jan 1, 1970). This means we lose 1/2 of the possible range of timestamps (lopping off 68 years before unix timestamp overflow - now only 30 years away :-) to handle the extremely rare case of setting timestamps into the distant past. If we are only interested in fixing the underflow case, we could just limit the values to 0 instead of storing negative values. At worst this will skew the timestamp by a few hours for timezones in the far east (files would still show Jan 1, 1970 in "ls -l" output). That said, it seems 32-bit systems (mine at least) allow files to be set into the past (01/01/1907 works fine) so it seems this patch is bringing the x86_64 behaviour into sync with other kernels. On the plus side, we have a patch that is ready to add nanosecond timestamps to ext3 and as an added bonus adds 2 high bits to the on-disk timestamp so this extends the maximum date to 2242. Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/inode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 810b6d6474bf..053cd1f453cc 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2611,9 +2611,9 @@ void ext4_read_inode(struct inode * inode)
2611 } 2611 }
2612 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); 2612 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2613 inode->i_size = le32_to_cpu(raw_inode->i_size); 2613 inode->i_size = le32_to_cpu(raw_inode->i_size);
2614 inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime); 2614 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2615 inode->i_ctime.tv_sec = le32_to_cpu(raw_inode->i_ctime); 2615 inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime);
2616 inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->i_mtime); 2616 inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime);
2617 inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0; 2617 inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
2618 2618
2619 ei->i_state = 0; 2619 ei->i_state = 0;