summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2019-03-21 17:05:12 -0400
committerDeepa Dinamani <deepa.kernel@gmail.com>2019-08-30 10:27:18 -0400
commit487b25bc4be9c15a5edb81c4e52160b5e84d1c4f (patch)
treed4a8e515b4dc209dc530e244ccd6814813d4790e
parentc0da64f6bb674d20a8e84bcd30679c1483668fb2 (diff)
fs: affs: Initialize filesystem timestamp ranges
Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Also fix timestamp calculation to avoid overflow while converting from days to seconds. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Acked-by: David Sterba <dsterba@suse.com> Acked-by: Jeff Layton <jlayton@kernel.org> Cc: dsterba@suse.com
-rw-r--r--fs/affs/amigaffs.c2
-rw-r--r--fs/affs/amigaffs.h3
-rw-r--r--fs/affs/inode.c4
-rw-r--r--fs/affs/super.c4
4 files changed, 10 insertions, 3 deletions
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 14a6c1b90c9f..f708c45d5f66 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -375,7 +375,7 @@ affs_secs_to_datestamp(time64_t secs, struct affs_date *ds)
375 u32 minute; 375 u32 minute;
376 s32 rem; 376 s32 rem;
377 377
378 secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60); 378 secs -= sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA;
379 if (secs < 0) 379 if (secs < 0)
380 secs = 0; 380 secs = 0;
381 days = div_s64_rem(secs, 86400, &rem); 381 days = div_s64_rem(secs, 86400, &rem);
diff --git a/fs/affs/amigaffs.h b/fs/affs/amigaffs.h
index f9bef9056659..81fb396d4dfa 100644
--- a/fs/affs/amigaffs.h
+++ b/fs/affs/amigaffs.h
@@ -32,6 +32,9 @@
32 32
33#define AFFS_ROOT_BMAPS 25 33#define AFFS_ROOT_BMAPS 25
34 34
35/* Seconds since Amiga epoch of 1978/01/01 to UNIX */
36#define AFFS_EPOCH_DELTA ((8 * 365 + 2) * 86400LL)
37
35struct affs_date { 38struct affs_date {
36 __be32 days; 39 __be32 days;
37 __be32 mins; 40 __be32 mins;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 73598bff8506..a346cf7659f1 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -150,10 +150,10 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
150 } 150 }
151 151
152 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec 152 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec
153 = (be32_to_cpu(tail->change.days) * (24 * 60 * 60) + 153 = (be32_to_cpu(tail->change.days) * 86400LL +
154 be32_to_cpu(tail->change.mins) * 60 + 154 be32_to_cpu(tail->change.mins) * 60 +
155 be32_to_cpu(tail->change.ticks) / 50 + 155 be32_to_cpu(tail->change.ticks) / 50 +
156 ((8 * 365 + 2) * 24 * 60 * 60)) + 156 AFFS_EPOCH_DELTA) +
157 sys_tz.tz_minuteswest * 60; 157 sys_tz.tz_minuteswest * 60;
158 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0; 158 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0;
159 affs_brelse(bh); 159 affs_brelse(bh);
diff --git a/fs/affs/super.c b/fs/affs/super.c
index e7d036efbaa1..cc463ae47c12 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -355,6 +355,10 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
355 sb->s_op = &affs_sops; 355 sb->s_op = &affs_sops;
356 sb->s_flags |= SB_NODIRATIME; 356 sb->s_flags |= SB_NODIRATIME;
357 357
358 sb->s_time_gran = NSEC_PER_SEC;
359 sb->s_time_min = sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA;
360 sb->s_time_max = 86400LL * U32_MAX + 86400 + sb->s_time_min;
361
358 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); 362 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
359 if (!sbi) 363 if (!sbi)
360 return -ENOMEM; 364 return -ENOMEM;