diff options
author | Joe Peterson <joe@skyrush.com> | 2008-07-25 04:46:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:34 -0400 |
commit | b271e067c896ad4082b15e96077675d08db40625 (patch) | |
tree | 1837d1c988226116e277c4f71b7f57aed5a7df05 /fs/fat/misc.c | |
parent | e8938a62a85d1f487e02c3b01955b47c9598f6d2 (diff) |
fatfs: add UTC timestamp option
Provide a new mount option ("tz=UTC") for DOS (vfat/msdos) filesystems,
allowing timestamps to be in coordinated universal time (UTC) rather than
local time in applications where doing this is advantageous.
In particular, portable devices that use fat/vfat (such as digital
cameras) can benefit from using UTC in their internal clocks, thus
avoiding daylight saving time errors and general time ambiguity issues.
The user of the device does not have to worry about changing the time when
moving from place or when daylight saving changes.
The new mount option, when set, disables the counter-adjustment that Linux
currently makes to FAT timestamp info in anticipation of the normal
userspace time zone correction. When used in this new mode, all daylight
saving time and time zone handling is done in userspace as is normal for
many other filesystems (like ext3). The default mode, which remains
unchanged, is still appropriate when mounting volumes written in Windows
(because of its use of local time).
I originally based this patch on one submitted last year by Paul Collins,
but I updated it to work with current source and changed variable/option
naming. Ogawa Hirofumi (who maintains these filesystems) and I discussed
this patch at length on lkml, and he suggested using the option name in
the attached version of the patch. Barry Bouwsma pointed out a good
addition to the patch as well.
Signed-off-by: Joe Peterson <joe@skyrush.com>
Signed-off-by: Paul Collins <paul@ondioline.org>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Barry Bouwsma <free_beer_for_all@yahoo.com>
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.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/fat/misc.c b/fs/fat/misc.c index 61f23511eacf..79fb98ad36d4 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c | |||
@@ -142,7 +142,7 @@ static int day_n[] = { | |||
142 | }; | 142 | }; |
143 | 143 | ||
144 | /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */ | 144 | /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */ |
145 | int date_dos2unix(unsigned short time, unsigned short date) | 145 | int date_dos2unix(unsigned short time, unsigned short date, int tz_utc) |
146 | { | 146 | { |
147 | int month, year, secs; | 147 | int month, year, secs; |
148 | 148 | ||
@@ -156,16 +156,18 @@ int date_dos2unix(unsigned short time, unsigned short date) | |||
156 | ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && | 156 | ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && |
157 | month < 2 ? 1 : 0)+3653); | 157 | month < 2 ? 1 : 0)+3653); |
158 | /* days since 1.1.70 plus 80's leap day */ | 158 | /* days since 1.1.70 plus 80's leap day */ |
159 | secs += sys_tz.tz_minuteswest*60; | 159 | if (!tz_utc) |
160 | secs += sys_tz.tz_minuteswest*60; | ||
160 | return secs; | 161 | return secs; |
161 | } | 162 | } |
162 | 163 | ||
163 | /* Convert linear UNIX date to a MS-DOS time/date pair. */ | 164 | /* Convert linear UNIX date to a MS-DOS time/date pair. */ |
164 | void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date) | 165 | void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date, int tz_utc) |
165 | { | 166 | { |
166 | int day, year, nl_day, month; | 167 | int day, year, nl_day, month; |
167 | 168 | ||
168 | unix_date -= sys_tz.tz_minuteswest*60; | 169 | if (!tz_utc) |
170 | unix_date -= sys_tz.tz_minuteswest*60; | ||
169 | 171 | ||
170 | /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */ | 172 | /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */ |
171 | if (unix_date < 315532800) | 173 | if (unix_date < 315532800) |