aboutsummaryrefslogtreecommitdiffstats
path: root/fs/affs/amigaffs.c
diff options
context:
space:
mode:
authorDengChao <chao.deng@linaro.org>2015-11-12 21:40:41 +0800
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-09 02:59:19 -0500
commitdb39c16724d019029d7533561754d92bef1b389a (patch)
tree9db0304601bce4a0704f721105dc756bcec0d649 /fs/affs/amigaffs.c
parentfs/9p: use fscache mutex rather than spinlock (diff)
downloadlinux-dev-db39c16724d019029d7533561754d92bef1b389a.tar.xz
linux-dev-db39c16724d019029d7533561754d92bef1b389a.zip
fs:affs:Replace time_t with time64_t
The affs code uses "time_t" and "get_seconds()". This will cause problems on 32-bit architectures in 2038 when time_t overflows. This patch replaces them with "time64_t" and "ktime_get_real_seconds()". This patch introduces expensive 64-bit divsion in "secs_to_datestamp()", considering this function is not called so often, the cost should be acceptable. Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: DengChao <chao.deng@linaro.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/affs/amigaffs.c')
-rw-r--r--fs/affs/amigaffs.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 5fa92bc790ef..d6c7a51c93e4 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -8,6 +8,7 @@
* Please send bug reports to: hjw@zvw.de
*/
+#include <linux/math64.h>
#include "affs.h"
/*
@@ -366,22 +367,22 @@ affs_fix_checksum(struct super_block *sb, struct buffer_head *bh)
}
void
-secs_to_datestamp(time_t secs, struct affs_date *ds)
+secs_to_datestamp(time64_t secs, struct affs_date *ds)
{
u32 days;
u32 minute;
+ s32 rem;
secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60);
if (secs < 0)
secs = 0;
- days = secs / 86400;
- secs -= days * 86400;
- minute = secs / 60;
- secs -= minute * 60;
+ days = div_s64_rem(secs, 86400, &rem);
+ minute = rem / 60;
+ rem -= minute * 60;
ds->days = cpu_to_be32(days);
ds->mins = cpu_to_be32(minute);
- ds->ticks = cpu_to_be32(secs * 50);
+ ds->ticks = cpu_to_be32(rem * 50);
}
umode_t