summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fat/dir.c2
-rw-r--r--fs/fat/fat.h6
-rw-r--r--fs/fat/inode.c20
-rw-r--r--fs/fat/misc.c13
-rw-r--r--fs/fat/namei_msdos.c17
-rw-r--r--fs/fat/namei_vfat.c20
6 files changed, 30 insertions, 48 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 8e100c3bf72c..7f5f3699fc6c 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -1130,7 +1130,7 @@ error:
1130 return err; 1130 return err;
1131} 1131}
1132 1132
1133int fat_alloc_new_dir(struct inode *dir, struct timespec *ts) 1133int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts)
1134{ 1134{
1135 struct super_block *sb = dir->i_sb; 1135 struct super_block *sb = dir->i_sb;
1136 struct msdos_sb_info *sbi = MSDOS_SB(sb); 1136 struct msdos_sb_info *sbi = MSDOS_SB(sb);
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index df84d5710b59..9d7d2d5da28b 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -304,7 +304,7 @@ extern int fat_scan_logstart(struct inode *dir, int i_logstart,
304 struct fat_slot_info *sinfo); 304 struct fat_slot_info *sinfo);
305extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh, 305extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
306 struct msdos_dir_entry **de); 306 struct msdos_dir_entry **de);
307extern int fat_alloc_new_dir(struct inode *dir, struct timespec *ts); 307extern int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts);
308extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots, 308extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
309 struct fat_slot_info *sinfo); 309 struct fat_slot_info *sinfo);
310extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo); 310extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo);
@@ -412,9 +412,9 @@ void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...);
412 } while (0) 412 } while (0)
413extern int fat_clusters_flush(struct super_block *sb); 413extern int fat_clusters_flush(struct super_block *sb);
414extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); 414extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
415extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, 415extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts,
416 __le16 __time, __le16 __date, u8 time_cs); 416 __le16 __time, __le16 __date, u8 time_cs);
417extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts, 417extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
418 __le16 *time, __le16 *date, u8 *time_cs); 418 __le16 *time, __le16 *date, u8 *time_cs);
419extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs); 419extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
420 420
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index bfd589ea74c0..d6b81e31f9f5 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -508,7 +508,6 @@ static int fat_validate_dir(struct inode *dir)
508/* doesn't deal with root inode */ 508/* doesn't deal with root inode */
509int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) 509int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
510{ 510{
511 struct timespec ts;
512 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); 511 struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
513 int error; 512 int error;
514 513
@@ -559,14 +558,11 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
559 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) 558 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
560 & ~((loff_t)sbi->cluster_size - 1)) >> 9; 559 & ~((loff_t)sbi->cluster_size - 1)) >> 9;
561 560
562 fat_time_fat2unix(sbi, &ts, de->time, de->date, 0); 561 fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
563 inode->i_mtime = timespec_to_timespec64(ts);
564 if (sbi->options.isvfat) { 562 if (sbi->options.isvfat) {
565 fat_time_fat2unix(sbi, &ts, de->ctime, 563 fat_time_fat2unix(sbi, &inode->i_ctime, de->ctime,
566 de->cdate, de->ctime_cs); 564 de->cdate, de->ctime_cs);
567 inode->i_ctime = timespec_to_timespec64(ts); 565 fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0);
568 fat_time_fat2unix(sbi, &ts, 0, de->adate, 0);
569 inode->i_atime = timespec_to_timespec64(ts);
570 } else 566 } else
571 inode->i_ctime = inode->i_atime = inode->i_mtime; 567 inode->i_ctime = inode->i_atime = inode->i_mtime;
572 568
@@ -843,7 +839,6 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf)
843 839
844static int __fat_write_inode(struct inode *inode, int wait) 840static int __fat_write_inode(struct inode *inode, int wait)
845{ 841{
846 struct timespec ts;
847 struct super_block *sb = inode->i_sb; 842 struct super_block *sb = inode->i_sb;
848 struct msdos_sb_info *sbi = MSDOS_SB(sb); 843 struct msdos_sb_info *sbi = MSDOS_SB(sb);
849 struct buffer_head *bh; 844 struct buffer_head *bh;
@@ -881,16 +876,13 @@ retry:
881 raw_entry->size = cpu_to_le32(inode->i_size); 876 raw_entry->size = cpu_to_le32(inode->i_size);
882 raw_entry->attr = fat_make_attrs(inode); 877 raw_entry->attr = fat_make_attrs(inode);
883 fat_set_start(raw_entry, MSDOS_I(inode)->i_logstart); 878 fat_set_start(raw_entry, MSDOS_I(inode)->i_logstart);
884 ts = timespec64_to_timespec(inode->i_mtime); 879 fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time,
885 fat_time_unix2fat(sbi, &ts, &raw_entry->time,
886 &raw_entry->date, NULL); 880 &raw_entry->date, NULL);
887 if (sbi->options.isvfat) { 881 if (sbi->options.isvfat) {
888 __le16 atime; 882 __le16 atime;
889 ts = timespec64_to_timespec(inode->i_ctime); 883 fat_time_unix2fat(sbi, &inode->i_ctime, &raw_entry->ctime,
890 fat_time_unix2fat(sbi, &ts, &raw_entry->ctime,
891 &raw_entry->cdate, &raw_entry->ctime_cs); 884 &raw_entry->cdate, &raw_entry->ctime_cs);
892 ts = timespec64_to_timespec(inode->i_atime); 885 fat_time_unix2fat(sbi, &inode->i_atime, &atime,
893 fat_time_unix2fat(sbi, &ts, &atime,
894 &raw_entry->adate, NULL); 886 &raw_entry->adate, NULL);
895 } 887 }
896 spin_unlock(&sbi->inode_hash_lock); 888 spin_unlock(&sbi->inode_hash_lock);
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index f9bdc1e01c98..573836dcaefc 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -180,17 +180,18 @@ int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster)
180#define IS_LEAP_YEAR(y) (!((y) & 3) && (y) != YEAR_2100) 180#define IS_LEAP_YEAR(y) (!((y) & 3) && (y) != YEAR_2100)
181 181
182/* Linear day numbers of the respective 1sts in non-leap years. */ 182/* Linear day numbers of the respective 1sts in non-leap years. */
183static time_t days_in_year[] = { 183static long days_in_year[] = {
184 /* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */ 184 /* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
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
188/* Convert a FAT time/date pair to a UNIX date (seconds since 1 1 70). */ 188/* 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 timespec *ts, 189void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts,
190 __le16 __time, __le16 __date, u8 time_cs) 190 __le16 __time, __le16 __date, u8 time_cs)
191{ 191{
192 u16 time = le16_to_cpu(__time), date = le16_to_cpu(__date); 192 u16 time = le16_to_cpu(__time), date = le16_to_cpu(__date);
193 time_t second, day, leap_day, month, year; 193 time64_t second;
194 long day, leap_day, month, year;
194 195
195 year = date >> 9; 196 year = date >> 9;
196 month = max(1, (date >> 5) & 0xf); 197 month = max(1, (date >> 5) & 0xf);
@@ -205,7 +206,7 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
205 second = (time & 0x1f) << 1; 206 second = (time & 0x1f) << 1;
206 second += ((time >> 5) & 0x3f) * SECS_PER_MIN; 207 second += ((time >> 5) & 0x3f) * SECS_PER_MIN;
207 second += (time >> 11) * SECS_PER_HOUR; 208 second += (time >> 11) * SECS_PER_HOUR;
208 second += (year * 365 + leap_day 209 second += (time64_t)(year * 365 + leap_day
209 + days_in_year[month] + day 210 + days_in_year[month] + day
210 + DAYS_DELTA) * SECS_PER_DAY; 211 + DAYS_DELTA) * SECS_PER_DAY;
211 212
@@ -224,11 +225,11 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
224} 225}
225 226
226/* Convert linear UNIX date to a FAT time/date pair. */ 227/* Convert linear UNIX date to a FAT time/date pair. */
227void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts, 228void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
228 __le16 *time, __le16 *date, u8 *time_cs) 229 __le16 *time, __le16 *date, u8 *time_cs)
229{ 230{
230 struct tm tm; 231 struct tm tm;
231 time_to_tm(ts->tv_sec, 232 time64_to_tm(ts->tv_sec,
232 (sbi->options.tz_set ? sbi->options.time_offset : 233 (sbi->options.tz_set ? sbi->options.time_offset :
233 -sys_tz.tz_minuteswest) * SECS_PER_MIN, &tm); 234 -sys_tz.tz_minuteswest) * SECS_PER_MIN, &tm);
234 235
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 16a832c37d66..efb8c40c9d27 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -225,7 +225,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
225/***** Creates a directory entry (name is already formatted). */ 225/***** Creates a directory entry (name is already formatted). */
226static int msdos_add_entry(struct inode *dir, const unsigned char *name, 226static int msdos_add_entry(struct inode *dir, const unsigned char *name,
227 int is_dir, int is_hid, int cluster, 227 int is_dir, int is_hid, int cluster,
228 struct timespec *ts, struct fat_slot_info *sinfo) 228 struct timespec64 *ts, struct fat_slot_info *sinfo)
229{ 229{
230 struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb); 230 struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
231 struct msdos_dir_entry de; 231 struct msdos_dir_entry de;
@@ -250,7 +250,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
250 if (err) 250 if (err)
251 return err; 251 return err;
252 252
253 dir->i_ctime = dir->i_mtime = timespec_to_timespec64(*ts); 253 dir->i_ctime = dir->i_mtime = *ts;
254 if (IS_DIRSYNC(dir)) 254 if (IS_DIRSYNC(dir))
255 (void)fat_sync_inode(dir); 255 (void)fat_sync_inode(dir);
256 else 256 else
@@ -267,7 +267,6 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
267 struct inode *inode = NULL; 267 struct inode *inode = NULL;
268 struct fat_slot_info sinfo; 268 struct fat_slot_info sinfo;
269 struct timespec64 ts; 269 struct timespec64 ts;
270 struct timespec t;
271 unsigned char msdos_name[MSDOS_NAME]; 270 unsigned char msdos_name[MSDOS_NAME];
272 int err, is_hid; 271 int err, is_hid;
273 272
@@ -286,8 +285,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
286 } 285 }
287 286
288 ts = current_time(dir); 287 ts = current_time(dir);
289 t = timespec64_to_timespec(ts); 288 err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &ts, &sinfo);
290 err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &t, &sinfo);
291 if (err) 289 if (err)
292 goto out; 290 goto out;
293 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); 291 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
@@ -347,7 +345,6 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
347 struct inode *inode; 345 struct inode *inode;
348 unsigned char msdos_name[MSDOS_NAME]; 346 unsigned char msdos_name[MSDOS_NAME];
349 struct timespec64 ts; 347 struct timespec64 ts;
350 struct timespec t;
351 int err, is_hid, cluster; 348 int err, is_hid, cluster;
352 349
353 mutex_lock(&MSDOS_SB(sb)->s_lock); 350 mutex_lock(&MSDOS_SB(sb)->s_lock);
@@ -365,13 +362,12 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
365 } 362 }
366 363
367 ts = current_time(dir); 364 ts = current_time(dir);
368 t = timespec64_to_timespec(ts); 365 cluster = fat_alloc_new_dir(dir, &ts);
369 cluster = fat_alloc_new_dir(dir, &t);
370 if (cluster < 0) { 366 if (cluster < 0) {
371 err = cluster; 367 err = cluster;
372 goto out; 368 goto out;
373 } 369 }
374 err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &t, &sinfo); 370 err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo);
375 if (err) 371 if (err)
376 goto out_free; 372 goto out_free;
377 inc_nlink(dir); 373 inc_nlink(dir);
@@ -503,9 +499,8 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
503 new_i_pos = MSDOS_I(new_inode)->i_pos; 499 new_i_pos = MSDOS_I(new_inode)->i_pos;
504 fat_detach(new_inode); 500 fat_detach(new_inode);
505 } else { 501 } else {
506 struct timespec t = timespec64_to_timespec(ts);
507 err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0, 502 err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0,
508 &t, &sinfo); 503 &ts, &sinfo);
509 if (err) 504 if (err)
510 goto out; 505 goto out;
511 new_i_pos = sinfo.i_pos; 506 new_i_pos = sinfo.i_pos;
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 9a5469120caa..82cd1e69cbdf 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -577,7 +577,7 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
577 577
578static int vfat_build_slots(struct inode *dir, const unsigned char *name, 578static int vfat_build_slots(struct inode *dir, const unsigned char *name,
579 int len, int is_dir, int cluster, 579 int len, int is_dir, int cluster,
580 struct timespec *ts, 580 struct timespec64 *ts,
581 struct msdos_dir_slot *slots, int *nr_slots) 581 struct msdos_dir_slot *slots, int *nr_slots)
582{ 582{
583 struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb); 583 struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
@@ -653,7 +653,7 @@ out_free:
653} 653}
654 654
655static int vfat_add_entry(struct inode *dir, const struct qstr *qname, 655static int vfat_add_entry(struct inode *dir, const struct qstr *qname,
656 int is_dir, int cluster, struct timespec *ts, 656 int is_dir, int cluster, struct timespec64 *ts,
657 struct fat_slot_info *sinfo) 657 struct fat_slot_info *sinfo)
658{ 658{
659 struct msdos_dir_slot *slots; 659 struct msdos_dir_slot *slots;
@@ -678,7 +678,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname,
678 goto cleanup; 678 goto cleanup;
679 679
680 /* update timestamp */ 680 /* update timestamp */
681 dir->i_ctime = dir->i_mtime = dir->i_atime = timespec_to_timespec64(*ts); 681 dir->i_ctime = dir->i_mtime = dir->i_atime = *ts;
682 if (IS_DIRSYNC(dir)) 682 if (IS_DIRSYNC(dir))
683 (void)fat_sync_inode(dir); 683 (void)fat_sync_inode(dir);
684 else 684 else
@@ -762,14 +762,12 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
762 struct inode *inode; 762 struct inode *inode;
763 struct fat_slot_info sinfo; 763 struct fat_slot_info sinfo;
764 struct timespec64 ts; 764 struct timespec64 ts;
765 struct timespec t;
766 int err; 765 int err;
767 766
768 mutex_lock(&MSDOS_SB(sb)->s_lock); 767 mutex_lock(&MSDOS_SB(sb)->s_lock);
769 768
770 ts = current_time(dir); 769 ts = current_time(dir);
771 t = timespec64_to_timespec(ts); 770 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
772 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &t, &sinfo);
773 if (err) 771 if (err)
774 goto out; 772 goto out;
775 inode_inc_iversion(dir); 773 inode_inc_iversion(dir);
@@ -853,19 +851,17 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
853 struct inode *inode; 851 struct inode *inode;
854 struct fat_slot_info sinfo; 852 struct fat_slot_info sinfo;
855 struct timespec64 ts; 853 struct timespec64 ts;
856 struct timespec t;
857 int err, cluster; 854 int err, cluster;
858 855
859 mutex_lock(&MSDOS_SB(sb)->s_lock); 856 mutex_lock(&MSDOS_SB(sb)->s_lock);
860 857
861 ts = current_time(dir); 858 ts = current_time(dir);
862 t = timespec64_to_timespec(ts); 859 cluster = fat_alloc_new_dir(dir, &ts);
863 cluster = fat_alloc_new_dir(dir, &t);
864 if (cluster < 0) { 860 if (cluster < 0) {
865 err = cluster; 861 err = cluster;
866 goto out; 862 goto out;
867 } 863 }
868 err = vfat_add_entry(dir, &dentry->d_name, 1, cluster, &t, &sinfo); 864 err = vfat_add_entry(dir, &dentry->d_name, 1, cluster, &ts, &sinfo);
869 if (err) 865 if (err)
870 goto out_free; 866 goto out_free;
871 inode_inc_iversion(dir); 867 inode_inc_iversion(dir);
@@ -904,7 +900,6 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
904 struct inode *old_inode, *new_inode; 900 struct inode *old_inode, *new_inode;
905 struct fat_slot_info old_sinfo, sinfo; 901 struct fat_slot_info old_sinfo, sinfo;
906 struct timespec64 ts; 902 struct timespec64 ts;
907 struct timespec t;
908 loff_t new_i_pos; 903 loff_t new_i_pos;
909 int err, is_dir, update_dotdot, corrupt = 0; 904 int err, is_dir, update_dotdot, corrupt = 0;
910 struct super_block *sb = old_dir->i_sb; 905 struct super_block *sb = old_dir->i_sb;
@@ -939,9 +934,8 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
939 new_i_pos = MSDOS_I(new_inode)->i_pos; 934 new_i_pos = MSDOS_I(new_inode)->i_pos;
940 fat_detach(new_inode); 935 fat_detach(new_inode);
941 } else { 936 } else {
942 t = timespec64_to_timespec(ts);
943 err = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir, 0, 937 err = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir, 0,
944 &t, &sinfo); 938 &ts, &sinfo);
945 if (err) 939 if (err)
946 goto out; 940 goto out;
947 new_i_pos = sinfo.i_pos; 941 new_i_pos = sinfo.i_pos;