diff -urp linux-6.1.42.orig/fs/fat/fat.h linux-6.1.42/fs/fat/fat.h --- linux-6.1.42.orig/fs/fat/fat.h 2023-07-27 08:50:53.000000000 +0200 +++ linux-6.1.42/fs/fat/fat.h 2026-08-03 20:27:28.625155858 +0200 @@ -51,6 +51,7 @@ struct fat_mount_options { nocase:1, /* Does this need case conversion? 0=need case conversion*/ usefree:1, /* Use free_clusters for FAT32 */ tz_set:1, /* Filesystem timestamps' offset set */ + dst_eu:1, /* Convert timestamps to UTC with DST correction (EU rules) */ rodir:1, /* allow ATTR_RO for directory */ discard:1, /* Issue discard requests on deletions */ dos1xfloppy:1, /* Assume default BPB for DOS 1.x floppies */ diff -urp linux-6.1.42.orig/fs/fat/inode.c linux-6.1.42/fs/fat/inode.c --- linux-6.1.42.orig/fs/fat/inode.c 2023-07-27 08:50:53.000000000 +0200 +++ linux-6.1.42/fs/fat/inode.c 2026-08-03 20:34:54.619024764 +0200 @@ -1018,6 +1018,9 @@ static int fat_show_options(struct seq_f else seq_puts(m, ",tz=UTC"); } + if (opts->dst_eu) { + seq_puts(m, ",dst_eu"); + } if (opts->errors == FAT_ERRORS_CONT) seq_puts(m, ",errors=continue"); else if (opts->errors == FAT_ERRORS_PANIC) @@ -1044,6 +1047,7 @@ enum { Opt_uni_xl, Opt_uni_xl_bool, Opt_nonumtail, Opt_nonumtail_bool, Opt_obsolete, Opt_flush, Opt_tz, Opt_rodir, Opt_errors, Opt_discard, Opt_nfs, Opt_nfs_enum, Opt_time_offset, Opt_dos1xfloppy, + Opt_dst_eu, }; static const struct constant_table fat_param_check[] = { @@ -1108,6 +1112,7 @@ const struct fs_parameter_spec fat_param fsparam_flag ("flush", Opt_flush), fsparam_enum ("tz", Opt_tz, fat_param_tz), fsparam_s32 ("time_offset", Opt_time_offset), + fsparam_flag ("dst_eu", Opt_dst_eu), fsparam_enum ("errors", Opt_errors, fat_param_errors), fsparam_flag ("discard", Opt_discard), fsparam_flag ("nfs", Opt_nfs), @@ -1231,6 +1236,14 @@ int fat_parse_param(struct fs_context *f case Opt_flush: opts->flush = 1; break; + case Opt_dst_eu: + opts->dst_eu = 1; + if(!opts->tz_set) { + /* Avoid automatic DST correction based on boot time */ + opts->tz_set = 1; + opts->time_offset = 0; + } + break; case Opt_time_offset: /* * GMT+-12 zones may have DST corrections so at least @@ -1928,6 +1941,7 @@ int fat_init_fs_context(struct fs_contex opts->numtail = 1; opts->usefree = opts->nocase = 0; opts->tz_set = 0; + opts->dst_eu = 0; opts->nfs = 0; opts->errors = FAT_ERRORS_RO; opts->debug = 0; diff -urp linux-6.1.42.orig/fs/fat/misc.c linux-6.1.42/fs/fat/misc.c --- linux-6.1.42.orig/fs/fat/misc.c 2023-07-27 08:50:53.000000000 +0200 +++ linux-6.1.42/fs/fat/misc.c 2023-07-31 14:49:16.638706948 +0200 @@ -193,6 +193,56 @@ static long days_in_year[] = { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, }; +int is_dst(time64_t second,int get) +{ + struct tm tm; + int lastmonth,lastday; + int firstmonth,firstday; + + time64_to_tm(second,0,&tm); + + /* Only European DST is implemented */ + firstmonth=2; + firstday=31; + if(tm.tm_year<96) { + /* DST switch off the last Sunday of September */ + lastmonth=8; + lastday=30; + } + else + { + /* DST switch off the last Sunday of October */ + lastmonth=9; + lastday=31; + } + if(tm.tm_mon>firstmonth && tm.tm_mon=(1+get)) return(1); + return(0); + } + return(1); + } + if(tm.tm_mon==lastmonth) + { + if((lastday-tm.tm_mday+tm.tm_wday)<=6) + { + if(tm.tm_wday==0) /* Sunday, check for hour */ + { + if(tm.tm_hour>=(1+get)) return(0); + return(1); + } + return(0); + } + return(1); + } + return(0); +} + static inline int fat_tz_offset(const struct msdos_sb_info *sbi) { return (sbi->options.tz_set ? @@ -227,6 +277,13 @@ void fat_time_fat2unix(struct msdos_sb_i second += fat_tz_offset(sbi); + /* Start DST patch: can do it only when time_offset is set because "tz_minuteswest" * + * is set at boot time and does not change if the DST changes during uptime. */ + if (sbi->options.dst_eu) { + if(is_dst(second,1)) second -= SECS_PER_HOUR; + } + /* End of DST patch */ + if (time_cs) { ts->tv_sec = second + (time_cs / 100); ts->tv_nsec = (time_cs % 100) * 10000000; @@ -244,7 +301,9 @@ void fat_time_unix2fat(struct msdos_sb_i __le16 *time, __le16 *date, u8 *time_cs) { struct tm tm; - time64_to_tm(ts->tv_sec, -fat_tz_offset(sbi), &tm); + /* Start DST reverse patch */ + time64_to_tm(ts->tv_sec, -fat_tz_offset(sbi) + (sbi->options.dst_eu && is_dst(ts->tv_sec,0)?SECS_PER_HOUR:0), &tm); + /* End DST reverse patch */ /* FAT can only support year between 1980 to 2107 */ if (tm.tm_year < 1980 - 1900) {