diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2008-11-06 15:53:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-06 18:41:20 -0500 |
commit | 7decd1cb0305b97243f283fa7f4baf5fe613edeb (patch) | |
tree | d17b291fd622c8ea45fd0ac8346f3c82c13759b6 /fs/fat/inode.c | |
parent | 9e975dae2970d22557662761c8505ce9fd165684 (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/inode.c')
-rw-r--r-- | fs/fat/inode.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 3921de2013a4..079d9d5e0d36 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -381,22 +381,12 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
381 | MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED; | 381 | MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED; |
382 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) | 382 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) |
383 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; | 383 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; |
384 | inode->i_mtime.tv_sec = | 384 | |
385 | date_dos2unix(le16_to_cpu(de->time), le16_to_cpu(de->date), | 385 | fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0); |
386 | sbi->options.tz_utc); | ||
387 | inode->i_mtime.tv_nsec = 0; | ||
388 | if (sbi->options.isvfat) { | 386 | if (sbi->options.isvfat) { |
389 | int secs = de->ctime_cs / 100; | 387 | fat_time_fat2unix(sbi, &inode->i_ctime, de->ctime, |
390 | int csecs = de->ctime_cs % 100; | 388 | de->cdate, de->ctime_cs); |
391 | inode->i_ctime.tv_sec = | 389 | fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0); |
392 | date_dos2unix(le16_to_cpu(de->ctime), | ||
393 | le16_to_cpu(de->cdate), | ||
394 | sbi->options.tz_utc) + secs; | ||
395 | inode->i_ctime.tv_nsec = csecs * 10000000; | ||
396 | inode->i_atime.tv_sec = | ||
397 | date_dos2unix(0, le16_to_cpu(de->adate), | ||
398 | sbi->options.tz_utc); | ||
399 | inode->i_atime.tv_nsec = 0; | ||
400 | } else | 390 | } else |
401 | inode->i_ctime = inode->i_atime = inode->i_mtime; | 391 | inode->i_ctime = inode->i_atime = inode->i_mtime; |
402 | 392 | ||
@@ -591,16 +581,14 @@ retry: | |||
591 | raw_entry->attr = fat_attr(inode); | 581 | raw_entry->attr = fat_attr(inode); |
592 | raw_entry->start = cpu_to_le16(MSDOS_I(inode)->i_logstart); | 582 | raw_entry->start = cpu_to_le16(MSDOS_I(inode)->i_logstart); |
593 | raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); | 583 | raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); |
594 | fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, | 584 | fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time, |
595 | &raw_entry->date, sbi->options.tz_utc); | 585 | &raw_entry->date, NULL); |
596 | if (sbi->options.isvfat) { | 586 | if (sbi->options.isvfat) { |
597 | __le16 atime; | 587 | __le16 atime; |
598 | fat_date_unix2dos(inode->i_ctime.tv_sec, &raw_entry->ctime, | 588 | fat_time_unix2fat(sbi, &inode->i_ctime, &raw_entry->ctime, |
599 | &raw_entry->cdate, sbi->options.tz_utc); | 589 | &raw_entry->cdate, &raw_entry->ctime_cs); |
600 | fat_date_unix2dos(inode->i_atime.tv_sec, &atime, | 590 | fat_time_unix2fat(sbi, &inode->i_atime, &atime, |
601 | &raw_entry->adate, sbi->options.tz_utc); | 591 | &raw_entry->adate, NULL); |
602 | raw_entry->ctime_cs = (inode->i_ctime.tv_sec & 1) * 100 + | ||
603 | inode->i_ctime.tv_nsec / 10000000; | ||
604 | } | 592 | } |
605 | spin_unlock(&sbi->inode_hash_lock); | 593 | spin_unlock(&sbi->inode_hash_lock); |
606 | mark_buffer_dirty(bh); | 594 | mark_buffer_dirty(bh); |