On Thursday 02 January 2020 20:30:03 Namjae Jeon wrote: > 2020-01-02 18:19 GMT+09:00, Pali Rohár <pali.rohar@xxxxxxxxx>: > > On Thursday 02 January 2020 16:20:32 Namjae Jeon wrote: > >> This adds the implementation of misc operations for exfat. > >> > >> Signed-off-by: Namjae Jeon <namjae.jeon@xxxxxxxxxxx> > >> Signed-off-by: Sungjong Seo <sj1557.seo@xxxxxxxxxxx> > >> --- > >> fs/exfat/misc.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++ > >> 1 file changed, 253 insertions(+) > >> create mode 100644 fs/exfat/misc.c > >> > >> diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c > >> new file mode 100644 > >> index 000000000000..7f533bcb3b3f > >> --- /dev/null > >> +++ b/fs/exfat/misc.c > > > > ... > > > >> +/* <linux/time.h> externs sys_tz > >> + * extern struct timezone sys_tz; > >> + */ > >> +#define UNIX_SECS_1980 315532800L > >> + > >> +#if BITS_PER_LONG == 64 > >> +#define UNIX_SECS_2108 4354819200L > >> +#endif > > > > ... > > > >> +#define TIMEZONE_CUR_OFFSET() ((sys_tz.tz_minuteswest / (-15)) & 0x7F) > >> +/* Convert linear UNIX date to a FAT time/date pair. */ > >> +void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec64 > >> *ts, > >> + struct exfat_date_time *tp) > >> +{ > >> + time_t second = ts->tv_sec; > >> + time_t day, month, year; > >> + time_t ld; /* leap day */ > > > > Question for other maintainers: Has kernel code already time_t defined > > as 64bit? Or it is still just 32bit and 32bit systems and some time64_t > > needs to be used? I remember that there was discussion about these > > problems, but do not know if it was changed/fixed or not... Just a > > pointer for possible Y2038 problem. As "ts" is of type timespec64, but > > "second" of type time_t. > My bad, I will change it with time64_t. Now I have looked into sources and time_t is just typedef from __kernel_old_time_t type. So it looks like that time64_t is the type which should be used in new code. But somebody else should confirm this information. > > > >> + > >> + /* Treats as local time with proper time */ > >> + second -= sys_tz.tz_minuteswest * SECS_PER_MIN; > >> + tp->timezone.valid = 1; > >> + tp->timezone.off = TIMEZONE_CUR_OFFSET(); > >> + > >> + /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */ > >> + if (second < UNIX_SECS_1980) { > >> + tp->second = 0; > >> + tp->minute = 0; > >> + tp->hour = 0; > >> + tp->day = 1; > >> + tp->month = 1; > >> + tp->year = 0; > >> + return; > >> + } > >> + > >> + if (second >= UNIX_SECS_2108) { > > > > Hello, this code cause compile errors on 32bit systems as UNIX_SECS_2108 > > macro is not defined when BITS_PER_LONG == 32. > > > > Value 4354819200 really cannot fit into 32bit signed integer, so you > > should use 64bit signed integer. I would suggest to define this macro > > value via LL not just L suffix (and it would work on both 32 and 64bit) > Okay. > > > > #define UNIX_SECS_2108 4354819200LL > > > >> + tp->second = 59; > >> + tp->minute = 59; > >> + tp->hour = 23; > >> + tp->day = 31; > >> + tp->month = 12; > >> + tp->year = 127; > >> + return; > >> + } > Okay, I will check it. > Thanks for your review! > > > > -- > > Pali Rohár > > pali.rohar@xxxxxxxxx > > -- Pali Rohár pali.rohar@xxxxxxxxx