diff options
Diffstat (limited to 'fs/fat')
| -rw-r--r-- | fs/fat/file.c | 37 | ||||
| -rw-r--r-- | fs/fat/inode.c | 26 |
2 files changed, 24 insertions, 39 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c index 62ffa9139400..7134403d5be2 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
| @@ -12,39 +12,6 @@ | |||
| 12 | #include <linux/smp_lock.h> | 12 | #include <linux/smp_lock.h> |
| 13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
| 14 | 14 | ||
| 15 | static ssize_t fat_file_aio_write(struct kiocb *iocb, const char __user *buf, | ||
| 16 | size_t count, loff_t pos) | ||
| 17 | { | ||
| 18 | struct inode *inode = iocb->ki_filp->f_dentry->d_inode; | ||
| 19 | int retval; | ||
| 20 | |||
| 21 | retval = generic_file_aio_write(iocb, buf, count, pos); | ||
| 22 | if (retval > 0) { | ||
| 23 | inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; | ||
| 24 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; | ||
| 25 | mark_inode_dirty(inode); | ||
| 26 | // check the locking rules | ||
| 27 | // if (IS_SYNC(inode)) | ||
| 28 | // fat_sync_inode(inode); | ||
| 29 | } | ||
| 30 | return retval; | ||
| 31 | } | ||
| 32 | |||
| 33 | static ssize_t fat_file_writev(struct file *filp, const struct iovec *iov, | ||
| 34 | unsigned long nr_segs, loff_t *ppos) | ||
| 35 | { | ||
| 36 | struct inode *inode = filp->f_dentry->d_inode; | ||
| 37 | int retval; | ||
| 38 | |||
| 39 | retval = generic_file_writev(filp, iov, nr_segs, ppos); | ||
| 40 | if (retval > 0) { | ||
| 41 | inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; | ||
| 42 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; | ||
| 43 | mark_inode_dirty(inode); | ||
| 44 | } | ||
| 45 | return retval; | ||
| 46 | } | ||
| 47 | |||
| 48 | int fat_generic_ioctl(struct inode *inode, struct file *filp, | 15 | int fat_generic_ioctl(struct inode *inode, struct file *filp, |
| 49 | unsigned int cmd, unsigned long arg) | 16 | unsigned int cmd, unsigned long arg) |
| 50 | { | 17 | { |
| @@ -148,9 +115,9 @@ struct file_operations fat_file_operations = { | |||
| 148 | .read = do_sync_read, | 115 | .read = do_sync_read, |
| 149 | .write = do_sync_write, | 116 | .write = do_sync_write, |
| 150 | .readv = generic_file_readv, | 117 | .readv = generic_file_readv, |
| 151 | .writev = fat_file_writev, | 118 | .writev = generic_file_writev, |
| 152 | .aio_read = generic_file_aio_read, | 119 | .aio_read = generic_file_aio_read, |
| 153 | .aio_write = fat_file_aio_write, | 120 | .aio_write = generic_file_aio_write, |
| 154 | .mmap = generic_file_mmap, | 121 | .mmap = generic_file_mmap, |
| 155 | .ioctl = fat_generic_ioctl, | 122 | .ioctl = fat_generic_ioctl, |
| 156 | .fsync = file_fsync, | 123 | .fsync = file_fsync, |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index a7cbe68e2259..e2effe2dc9b2 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
| @@ -102,6 +102,19 @@ static int fat_prepare_write(struct file *file, struct page *page, | |||
| 102 | &MSDOS_I(page->mapping->host)->mmu_private); | 102 | &MSDOS_I(page->mapping->host)->mmu_private); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | static int fat_commit_write(struct file *file, struct page *page, | ||
| 106 | unsigned from, unsigned to) | ||
| 107 | { | ||
| 108 | struct inode *inode = page->mapping->host; | ||
| 109 | int err = generic_commit_write(file, page, from, to); | ||
| 110 | if (!err && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) { | ||
| 111 | inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; | ||
| 112 | MSDOS_I(inode)->i_attrs |= ATTR_ARCH; | ||
| 113 | mark_inode_dirty(inode); | ||
| 114 | } | ||
| 115 | return err; | ||
| 116 | } | ||
| 117 | |||
| 105 | static sector_t _fat_bmap(struct address_space *mapping, sector_t block) | 118 | static sector_t _fat_bmap(struct address_space *mapping, sector_t block) |
| 106 | { | 119 | { |
| 107 | return generic_block_bmap(mapping, block, fat_get_block); | 120 | return generic_block_bmap(mapping, block, fat_get_block); |
| @@ -112,7 +125,7 @@ static struct address_space_operations fat_aops = { | |||
| 112 | .writepage = fat_writepage, | 125 | .writepage = fat_writepage, |
| 113 | .sync_page = block_sync_page, | 126 | .sync_page = block_sync_page, |
| 114 | .prepare_write = fat_prepare_write, | 127 | .prepare_write = fat_prepare_write, |
| 115 | .commit_write = generic_commit_write, | 128 | .commit_write = fat_commit_write, |
| 116 | .bmap = _fat_bmap | 129 | .bmap = _fat_bmap |
| 117 | }; | 130 | }; |
| 118 | 131 | ||
| @@ -287,9 +300,9 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
| 287 | inode->i_blksize = sbi->cluster_size; | 300 | inode->i_blksize = sbi->cluster_size; |
| 288 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) | 301 | inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) |
| 289 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; | 302 | & ~((loff_t)sbi->cluster_size - 1)) >> 9; |
| 290 | inode->i_mtime.tv_sec = inode->i_atime.tv_sec = | 303 | inode->i_mtime.tv_sec = |
| 291 | date_dos2unix(le16_to_cpu(de->time), le16_to_cpu(de->date)); | 304 | date_dos2unix(le16_to_cpu(de->time), le16_to_cpu(de->date)); |
| 292 | inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0; | 305 | inode->i_mtime.tv_nsec = 0; |
| 293 | if (sbi->options.isvfat) { | 306 | if (sbi->options.isvfat) { |
| 294 | int secs = de->ctime_cs / 100; | 307 | int secs = de->ctime_cs / 100; |
| 295 | int csecs = de->ctime_cs % 100; | 308 | int csecs = de->ctime_cs % 100; |
| @@ -297,8 +310,11 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) | |||
| 297 | date_dos2unix(le16_to_cpu(de->ctime), | 310 | date_dos2unix(le16_to_cpu(de->ctime), |
| 298 | le16_to_cpu(de->cdate)) + secs; | 311 | le16_to_cpu(de->cdate)) + secs; |
| 299 | inode->i_ctime.tv_nsec = csecs * 10000000; | 312 | inode->i_ctime.tv_nsec = csecs * 10000000; |
| 313 | inode->i_atime.tv_sec = | ||
| 314 | date_dos2unix(le16_to_cpu(0), le16_to_cpu(de->adate)); | ||
| 315 | inode->i_atime.tv_nsec = 0; | ||
| 300 | } else | 316 | } else |
| 301 | inode->i_ctime = inode->i_mtime; | 317 | inode->i_ctime = inode->i_atime = inode->i_mtime; |
| 302 | 318 | ||
| 303 | return 0; | 319 | return 0; |
| 304 | } | 320 | } |
| @@ -500,7 +516,9 @@ retry: | |||
| 500 | raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); | 516 | raw_entry->starthi = cpu_to_le16(MSDOS_I(inode)->i_logstart >> 16); |
| 501 | fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, &raw_entry->date); | 517 | fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, &raw_entry->date); |
| 502 | if (sbi->options.isvfat) { | 518 | if (sbi->options.isvfat) { |
| 519 | __le16 atime; | ||
| 503 | fat_date_unix2dos(inode->i_ctime.tv_sec,&raw_entry->ctime,&raw_entry->cdate); | 520 | fat_date_unix2dos(inode->i_ctime.tv_sec,&raw_entry->ctime,&raw_entry->cdate); |
| 521 | fat_date_unix2dos(inode->i_atime.tv_sec,&atime,&raw_entry->adate); | ||
| 504 | raw_entry->ctime_cs = (inode->i_ctime.tv_sec & 1) * 100 + | 522 | raw_entry->ctime_cs = (inode->i_ctime.tv_sec & 1) * 100 + |
| 505 | inode->i_ctime.tv_nsec / 10000000; | 523 | inode->i_ctime.tv_nsec / 10000000; |
| 506 | } | 524 | } |
