aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fat/misc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 573836dcaefc..2eca073fe785 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -185,6 +185,13 @@ static long days_in_year[] = {
185 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 185 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0,
186}; 186};
187 187
188static inline int fat_tz_offset(struct msdos_sb_info *sbi)
189{
190 return (sbi->options.tz_set ?
191 -sbi->options.time_offset :
192 sys_tz.tz_minuteswest) * SECS_PER_MIN;
193}
194
188/* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ 195/* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */
189void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts, 196void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts,
190 __le16 __time, __le16 __date, u8 time_cs) 197 __le16 __time, __le16 __date, u8 time_cs)
@@ -210,10 +217,7 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts,
210 + days_in_year[month] + day 217 + days_in_year[month] + day
211 + DAYS_DELTA) * SECS_PER_DAY; 218 + DAYS_DELTA) * SECS_PER_DAY;
212 219
213 if (!sbi->options.tz_set) 220 second += fat_tz_offset(sbi);
214 second += sys_tz.tz_minuteswest * SECS_PER_MIN;
215 else
216 second -= sbi->options.time_offset * SECS_PER_MIN;
217 221
218 if (time_cs) { 222 if (time_cs) {
219 ts->tv_sec = second + (time_cs / 100); 223 ts->tv_sec = second + (time_cs / 100);
@@ -229,9 +233,7 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
229 __le16 *time, __le16 *date, u8 *time_cs) 233 __le16 *time, __le16 *date, u8 *time_cs)
230{ 234{
231 struct tm tm; 235 struct tm tm;
232 time64_to_tm(ts->tv_sec, 236 time64_to_tm(ts->tv_sec, -fat_tz_offset(sbi), &tm);
233 (sbi->options.tz_set ? sbi->options.time_offset :
234 -sys_tz.tz_minuteswest) * SECS_PER_MIN, &tm);
235 237
236 /* FAT can only support year between 1980 to 2107 */ 238 /* FAT can only support year between 1980 to 2107 */
237 if (tm.tm_year < 1980 - 1900) { 239 if (tm.tm_year < 1980 - 1900) {