Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db39c167 authored by DengChao's avatar DengChao Committed by Al Viro
Browse files

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDengChao <chao.deng@linaro.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 8f5fed1e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -138,7 +138,7 @@ extern int affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh);
extern int	affs_remove_header(struct dentry *dentry);
extern int	affs_remove_header(struct dentry *dentry);
extern u32	affs_checksum_block(struct super_block *sb, struct buffer_head *bh);
extern u32	affs_checksum_block(struct super_block *sb, struct buffer_head *bh);
extern void	affs_fix_checksum(struct super_block *sb, struct buffer_head *bh);
extern void	affs_fix_checksum(struct super_block *sb, struct buffer_head *bh);
extern void	secs_to_datestamp(time_t secs, struct affs_date *ds);
extern void	secs_to_datestamp(time64_t secs, struct affs_date *ds);
extern umode_t	prot_to_mode(u32 prot);
extern umode_t	prot_to_mode(u32 prot);
extern void	mode_to_prot(struct inode *inode);
extern void	mode_to_prot(struct inode *inode);
__printf(3, 4)
__printf(3, 4)
+7 −6
Original line number Original line Diff line number Diff line
@@ -8,6 +8,7 @@
 *  Please send bug reports to: hjw@zvw.de
 *  Please send bug reports to: hjw@zvw.de
 */
 */


#include <linux/math64.h>
#include "affs.h"
#include "affs.h"


/*
/*
@@ -366,22 +367,22 @@ affs_fix_checksum(struct super_block *sb, struct buffer_head *bh)
}
}


void
void
secs_to_datestamp(time_t secs, struct affs_date *ds)
secs_to_datestamp(time64_t secs, struct affs_date *ds)
{
{
	u32	 days;
	u32	 days;
	u32	 minute;
	u32	 minute;
	s32	 rem;


	secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60);
	secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60);
	if (secs < 0)
	if (secs < 0)
		secs = 0;
		secs = 0;
	days    = secs / 86400;
	days    = div_s64_rem(secs, 86400, &rem);
	secs   -= days * 86400;
	minute  = rem / 60;
	minute  = secs / 60;
	rem    -= minute * 60;
	secs   -= minute * 60;


	ds->days = cpu_to_be32(days);
	ds->days = cpu_to_be32(days);
	ds->mins = cpu_to_be32(minute);
	ds->mins = cpu_to_be32(minute);
	ds->ticks = cpu_to_be32(secs * 50);
	ds->ticks = cpu_to_be32(rem * 50);
}
}


umode_t
umode_t
+1 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ affs_commit_super(struct super_block *sb, int wait)
	struct affs_root_tail *tail = AFFS_ROOT_TAIL(sb, bh);
	struct affs_root_tail *tail = AFFS_ROOT_TAIL(sb, bh);


	lock_buffer(bh);
	lock_buffer(bh);
	secs_to_datestamp(get_seconds(), &tail->disk_change);
	secs_to_datestamp(ktime_get_real_seconds(), &tail->disk_change);
	affs_fix_checksum(sb, bh);
	affs_fix_checksum(sb, bh);
	unlock_buffer(bh);
	unlock_buffer(bh);