Commit 9afc5eee authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

y2038: globally rename compat_time to old_time32



Christoph Hellwig suggested a slightly different path for handling
backwards compatibility with the 32-bit time_t based system calls:

Rather than simply reusing the compat_sys_* entry points on 32-bit
architectures unchanged, we get rid of those entry points and the
compat_time types by renaming them to something that makes more sense
on 32-bit architectures (which don't have a compat mode otherwise),
and then share the entry points under the new name with the 64-bit
architectures that use them for implementing the compatibility.

The following types and interfaces are renamed here, and moved
from linux/compat_time.h to linux/time32.h:

old				new
---				---
compat_time_t			old_time32_t
struct compat_timeval		struct old_timeval32
struct compat_timespec		struct old_timespec32
struct compat_itimerspec	struct old_itimerspec32
ns_to_compat_timeval()		ns_to_old_timeval32()
get_compat_itimerspec64()	get_old_itimerspec32()
put_compat_itimerspec64()	put_old_itimerspec32()
compat_get_timespec64()		get_old_timespec32()
compat_put_timespec64()		put_old_timespec32()

As we already have aliases in place, this patch addresses only the
instances that are relevant to the system call interface in particular,
not those that occur in device drivers and other modules. Those
will get handled separately, while providing the 64-bit version
of the respective interfaces.

I'm not renaming the timex, rusage and itimerval structures, as we are
still debating what the new interface will look like, and whether we
will need a replacement at all.

This also doesn't change the names of the syscall entry points, which can
be done more easily when we actually switch over the 32-bit architectures
to use them, at that point we need to change COMPAT_SYSCALL_DEFINEx to
SYSCALL_DEFINEx with a new name, e.g. with a _time32 suffix.

Suggested-by: default avatarChristoph Hellwig <hch@infradead.org>
Link: https://lore.kernel.org/lkml/20180705222110.GA5698@infradead.org/


Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 33e26418
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -86,11 +86,11 @@ struct compat_stat {
	compat_off_t	st_size;
	compat_off_t	st_blksize;
	compat_off_t	st_blocks;
	compat_time_t	st_atime;
	old_time32_t	st_atime;
	compat_ulong_t	st_atime_nsec;
	compat_time_t	st_mtime;
	old_time32_t	st_mtime;
	compat_ulong_t	st_mtime_nsec;
	compat_time_t	st_ctime;
	old_time32_t	st_ctime;
	compat_ulong_t	st_ctime_nsec;
	compat_ulong_t	__unused4[2];
};
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@

#ifdef CONFIG_COMPAT

#include <linux/compat_time.h>
#include <linux/time.h>
#include <asm/compat.h>

/*
+3 −3
Original line number Diff line number Diff line
@@ -59,11 +59,11 @@ struct compat_stat {
	s32		st_pad2[2];
	compat_off_t	st_size;
	s32		st_pad3;
	compat_time_t	st_atime;
	old_time32_t	st_atime;
	s32		st_atime_nsec;
	compat_time_t	st_mtime;
	old_time32_t	st_mtime;
	s32		st_mtime_nsec;
	compat_time_t	st_ctime;
	old_time32_t	st_ctime;
	s32		st_ctime_nsec;
	s32		st_blksize;
	s32		st_blocks;
+7 −7
Original line number Diff line number Diff line
@@ -54,10 +54,10 @@ struct elf_prstatus32
	pid_t	pr_ppid;
	pid_t	pr_pgrp;
	pid_t	pr_sid;
	struct compat_timeval pr_utime; /* User time */
	struct compat_timeval pr_stime; /* System time */
	struct compat_timeval pr_cutime;/* Cumulative user time */
	struct compat_timeval pr_cstime;/* Cumulative system time */
	struct old_timeval32 pr_utime; /* User time */
	struct old_timeval32 pr_stime; /* System time */
	struct old_timeval32 pr_cutime;/* Cumulative user time */
	struct old_timeval32 pr_cstime;/* Cumulative system time */
	elf_gregset_t pr_reg;	/* GP registers */
	int pr_fpvalid;		/* True if math co-processor being used.  */
};
@@ -81,9 +81,9 @@ struct elf_prpsinfo32
#define elf_caddr_t	u32
#define init_elf_binfmt init_elfn32_binfmt

#define jiffies_to_timeval jiffies_to_compat_timeval
#define jiffies_to_timeval jiffies_to_old_timeval32
static __inline__ void
jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
{
	/*
	 * Convert jiffies to nanoseconds and separate with
@@ -101,6 +101,6 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
#define TASK_SIZE TASK_SIZE32

#undef ns_to_timeval
#define ns_to_timeval ns_to_compat_timeval
#define ns_to_timeval ns_to_old_timeval32

#include "../../../fs/binfmt_elf.c"
+7 −7
Original line number Diff line number Diff line
@@ -59,10 +59,10 @@ struct elf_prstatus32
	pid_t	pr_ppid;
	pid_t	pr_pgrp;
	pid_t	pr_sid;
	struct compat_timeval pr_utime; /* User time */
	struct compat_timeval pr_stime; /* System time */
	struct compat_timeval pr_cutime;/* Cumulative user time */
	struct compat_timeval pr_cstime;/* Cumulative system time */
	struct old_timeval32 pr_utime; /* User time */
	struct old_timeval32 pr_stime; /* System time */
	struct old_timeval32 pr_cutime;/* Cumulative user time */
	struct old_timeval32 pr_cstime;/* Cumulative system time */
	elf_gregset_t pr_reg;	/* GP registers */
	int pr_fpvalid;		/* True if math co-processor being used.  */
};
@@ -86,9 +86,9 @@ struct elf_prpsinfo32
#define elf_caddr_t	u32
#define init_elf_binfmt init_elf32_binfmt

#define jiffies_to_timeval jiffies_to_compat_timeval
#define jiffies_to_timeval jiffies_to_old_timeval32
static inline void
jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value)
{
	/*
	 * Convert jiffies to nanoseconds and separate with
@@ -104,6 +104,6 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
#define TASK_SIZE TASK_SIZE32

#undef ns_to_timeval
#define ns_to_timeval ns_to_compat_timeval
#define ns_to_timeval ns_to_old_timeval32

#include "../../../fs/binfmt_elf.c"
Loading