I think I found the bug in the linux 5.4, but I have no idea whether or how to 
submit a patch...
The handling of exfat changes completely in the following (but not LTS) 
versions.

In the file drivers/staging/exfat/exfat_super.c, in lines 60-

static void exfat_time_fat2unix(struct timespec64 *ts, struct date_time_t *tp)
{
        ts->tv_sec = mktime64(tp->Year + 1980, tp->Month + 1, tp->Day,   // 
shouldn't it be tp->Month, tp->Day .... ?????!!!
                              tp->Hour, tp->Minute, tp->Second);

        ts->tv_nsec = tp->MilliSecond * NSEC_PER_MSEC;
}

static void exfat_time_unix2fat(struct timespec64 *ts, struct date_time_t *tp)
{
        time64_t second = ts->tv_sec;
        struct tm tm;

        time64_to_tm(second, 0, &tm);
[...]
        tp->MilliSecond = ts->tv_nsec / NSEC_PER_MSEC;
        tp->Second      = tm.tm_sec;
        tp->Minute      = tm.tm_min;
        tp->Hour        = tm.tm_hour;
        tp->Day         = tm.tm_mday;
        tp->Month       = tm.tm_mon + 1;
        tp->Year        = tm.tm_year + 1900 - 1980;
}

The meaning of the field Month in struct date_time_t has no
documentation in the header exfat.h, but the function unix2fat produces
a month from 1-12 in date_time_t by adding 1 to the result of
time64_to_tm.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1872504

Title:
  date modified is wrong for files on an exfat formatted drive

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/1872504/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to