aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/misc.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-12-17 19:02:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 20:15:22 -0500
commit58156c8fbf43e71dd091848d4dbfd780d04016e6 (patch)
treeffe31e639221d1f2434f873f93d3ee654cbfb9da /fs/fat/misc.c
parentf562146a3daf6aa0bbf2a1bc4b6b7da031ed5dcd (diff)
fat: provide option for setting timezone offset
So far FAT either offsets time stamps by sys_tz.minuteswest or leaves them as they are (when tz=UTC mount option is used). However in some cases it is useful if one can specify time stamp offset on his own (e.g. when time zone of the camera connected is different from time zone of the computer, or when HW clock is in UTC and thus sys_tz.minuteswest == 0). So provide a mount option time_offset= which allows user to specify offset in minutes that should be applied to time stamps on the filesystem. akpm: this code would work incorrectly when used via `mount -o remount', because cached inodes would not be updated. But fatfs's fat_remount() is basically a no-op anyway. Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/misc.c')
-rw-r--r--fs/fat/misc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 6d93360ca0cc..5eb600dc43a9 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -212,8 +212,10 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
212 + days_in_year[month] + day 212 + days_in_year[month] + day
213 + DAYS_DELTA) * SECS_PER_DAY; 213 + DAYS_DELTA) * SECS_PER_DAY;
214 214
215 if (!sbi->options.tz_utc) 215 if (!sbi->options.tz_set)
216 second += sys_tz.tz_minuteswest * SECS_PER_MIN; 216 second += sys_tz.tz_minuteswest * SECS_PER_MIN;
217 else
218 second -= sbi->options.time_offset * SECS_PER_MIN;
217 219
218 if (time_cs) { 220 if (time_cs) {
219 ts->tv_sec = second + (time_cs / 100); 221 ts->tv_sec = second + (time_cs / 100);
@@ -229,8 +231,9 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts,
229 __le16 *time, __le16 *date, u8 *time_cs) 231 __le16 *time, __le16 *date, u8 *time_cs)
230{ 232{
231 struct tm tm; 233 struct tm tm;
232 time_to_tm(ts->tv_sec, sbi->options.tz_utc ? 0 : 234 time_to_tm(ts->tv_sec,
233 -sys_tz.tz_minuteswest * 60, &tm); 235 (sbi->options.tz_set ? sbi->options.time_offset :
236 -sys_tz.tz_minuteswest) * SECS_PER_MIN, &tm);
234 237
235 /* FAT can only support year between 1980 to 2107 */ 238 /* FAT can only support year between 1980 to 2107 */
236 if (tm.tm_year < 1980 - 1900) { 239 if (tm.tm_year < 1980 - 1900) {