Here is the fourth version for converting parport device(ppdev) to y2038 safe. The first three could found at [1], [2], [3].
An y2038 safe application/kernel use 64bit time_t(aka time64_t) instead of 32bit time_t. There are the 5 cases need to support:
summary |u:arch |u:tv_sec |k:arch |k:tv_sec -------------------|-------|---------|-------|-------- 32_y2038_unsafe |32 |32 |32 |32 32_y2038_safe |32 |64 |32 |64 compat_y2038_unsafe|32 |32 |64 |64 compat_y2038_safe |32 |64 |64 |64 64_y2038_safe |64 |64 |64 |64
notes: 1. xxx_y2038_safe/unsafe. 32 means app running on the 32bit kernel. Compat means 32bit app running on 64bit kernel. 64 means 64bit app running on 64bit kernel. 2. 1.3.5 are the original one, we need keep the compatability. 2,4 is new one we need to support.
There are different ways to do this. Convert to 64bit time and/or define COMPAT_USE_64BIT_TIME 0 or 1 to indicate y2038 safe or unsafe.
But it is not mean that we need to convert all the time relative struct to 64bit. Because some time relative struct(e.g. timeval in ppdev.c) is mainly the offset of the real time.
The main issue in ppdev.c is PPSETTIME/PPGETTIME which transfer timeval between user space and kernel. My approach here is handle them as different ioctl command.
Build successful on arm64 and arm.
Changes since V3: 1. create pp_set_timeout, pp_get_timeout to reduce the duplicated code in my patch according to the suggestion of arnd. I use div_u64_rem instead of jiffies_to_timespec64 because it could save a divide operaion.
[1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html [2] https://lists.linaro.org/pipermail/y2038/2015-June/000567.html [3] https://lists.linaro.org/pipermail/y2038/2015-November/001093.html
Bamvor Jian Zhang (2): ppdev: convert to y2038 safe ppdev: add support for compat ioctl
drivers/char/ppdev.c | 91 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 20 deletions(-)