]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: affs: Initialize filesystem timestamp ranges
authorDeepa Dinamani <deepa.kernel@gmail.com>
Thu, 21 Mar 2019 21:05:12 +0000 (14:05 -0700)
committerDeepa Dinamani <deepa.kernel@gmail.com>
Fri, 30 Aug 2019 14:27:18 +0000 (07:27 -0700)
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
fs/affs/amigaffs.c
fs/affs/amigaffs.h
fs/affs/inode.c
fs/affs/super.c

index 14a6c1b90c9fb8e0652ad848fa46536cfd96484b..f708c45d5f664d84475f6a42214d0732c43325b9 100644 (file)
@@ -375,7 +375,7 @@ affs_secs_to_datestamp(time64_t secs, struct affs_date *ds)
        u32      minute;
        s32      rem;
 
-       secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60);
+       secs -= sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA;
        if (secs < 0)
                secs = 0;
        days    = div_s64_rem(secs, 86400, &rem);
index f9bef905665927551acd4034370a902e6441981b..81fb396d4dfa37fe7f4296e50751eb5ad1b797df 100644 (file)
@@ -32,6 +32,9 @@
 
 #define AFFS_ROOT_BMAPS                25
 
+/* Seconds since Amiga epoch of 1978/01/01 to UNIX */
+#define AFFS_EPOCH_DELTA ((8 * 365 + 2) * 86400LL)
+
 struct affs_date {
        __be32 days;
        __be32 mins;
index 73598bff8506d45dbfcdfa2804bdbe393fe32149..a346cf7659f19804db57d64d6702c5d2130b7230 100644 (file)
@@ -150,10 +150,10 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
        }
 
        inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec
-                      = (be32_to_cpu(tail->change.days) * (24 * 60 * 60) +
+                      = (be32_to_cpu(tail->change.days) * 86400LL +
                         be32_to_cpu(tail->change.mins) * 60 +
                         be32_to_cpu(tail->change.ticks) / 50 +
-                        ((8 * 365 + 2) * 24 * 60 * 60)) +
+                        AFFS_EPOCH_DELTA) +
                         sys_tz.tz_minuteswest * 60;
        inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0;
        affs_brelse(bh);
index e7d036efbaa1ec474c2825427926834895b3f2e2..cc463ae47c12a0bc7cc1c6e444103a8950154b8c 100644 (file)
@@ -355,6 +355,10 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
        sb->s_op                = &affs_sops;
        sb->s_flags |= SB_NODIRATIME;
 
+       sb->s_time_gran = NSEC_PER_SEC;
+       sb->s_time_min = sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA;
+       sb->s_time_max = 86400LL * U32_MAX + 86400 + sb->s_time_min;
+
        sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
        if (!sbi)
                return -ENOMEM;