aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/dir.c
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2008-11-06 15:53:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-06 18:41:20 -0500
commit7decd1cb0305b97243f283fa7f4baf5fe613edeb (patch)
treed17b291fd622c8ea45fd0ac8346f3c82c13759b6 /fs/fat/dir.c
parent9e975dae2970d22557662761c8505ce9fd165684 (diff)
fat: Fix and cleanup timestamp conversion
This cleans date_dos2unix()/fat_date_unix2dos() up. New code should be much more readable. And this fixes those old functions. Those doesn't handle 2100 correctly. 2100 isn't leap year, but old one handles it as leap year. Also, with this, centi sec is handled and is fixed. Signed-off-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/dir.c')
-rw-r--r--fs/fat/dir.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 08b23ad25f1c..a601c6d45bc0 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -1089,6 +1089,7 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)
1089 struct msdos_dir_entry *de; 1089 struct msdos_dir_entry *de;
1090 sector_t blknr; 1090 sector_t blknr;
1091 __le16 date, time; 1091 __le16 date, time;
1092 u8 time_cs;
1092 int err, cluster; 1093 int err, cluster;
1093 1094
1094 err = fat_alloc_clusters(dir, &cluster, 1); 1095 err = fat_alloc_clusters(dir, &cluster, 1);
@@ -1102,7 +1103,7 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)
1102 goto error_free; 1103 goto error_free;
1103 } 1104 }
1104 1105
1105 fat_date_unix2dos(ts->tv_sec, &time, &date, sbi->options.tz_utc); 1106 fat_time_unix2fat(sbi, ts, &time, &date, &time_cs);
1106 1107
1107 de = (struct msdos_dir_entry *)bhs[0]->b_data; 1108 de = (struct msdos_dir_entry *)bhs[0]->b_data;
1108 /* filling the new directory slots ("." and ".." entries) */ 1109 /* filling the new directory slots ("." and ".." entries) */
@@ -1112,13 +1113,14 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec *ts)
1112 de[0].lcase = de[1].lcase = 0; 1113 de[0].lcase = de[1].lcase = 0;
1113 de[0].time = de[1].time = time; 1114 de[0].time = de[1].time = time;
1114 de[0].date = de[1].date = date; 1115 de[0].date = de[1].date = date;
1115 de[0].ctime_cs = de[1].ctime_cs = 0;
1116 if (sbi->options.isvfat) { 1116 if (sbi->options.isvfat) {
1117 /* extra timestamps */ 1117 /* extra timestamps */
1118 de[0].ctime = de[1].ctime = time; 1118 de[0].ctime = de[1].ctime = time;
1119 de[0].ctime_cs = de[1].ctime_cs = time_cs;
1119 de[0].adate = de[0].cdate = de[1].adate = de[1].cdate = date; 1120 de[0].adate = de[0].cdate = de[1].adate = de[1].cdate = date;
1120 } else { 1121 } else {
1121 de[0].ctime = de[1].ctime = 0; 1122 de[0].ctime = de[1].ctime = 0;
1123 de[0].ctime_cs = de[1].ctime_cs = 0;
1122 de[0].adate = de[0].cdate = de[1].adate = de[1].cdate = 0; 1124 de[0].adate = de[0].cdate = de[1].adate = de[1].cdate = 0;
1123 } 1125 }
1124 de[0].start = cpu_to_le16(cluster); 1126 de[0].start = cpu_to_le16(cluster);