mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
fat: convert to new timestamp accessors
Convert to using the new inode timestamp accessor functions. Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://lore.kernel.org/r/20231004185347.80880-35-jlayton@kernel.org Tested-by: Klara Modin <klarasmodin@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
11cc6426ad
commit
daaf2bf039
@ -512,6 +512,7 @@ static int fat_validate_dir(struct inode *dir)
|
||||
int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
|
||||
{
|
||||
struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
|
||||
struct timespec64 mtime;
|
||||
int error;
|
||||
|
||||
MSDOS_I(inode)->i_pos = 0;
|
||||
@ -561,14 +562,18 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
|
||||
inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
|
||||
& ~((loff_t)sbi->cluster_size - 1)) >> 9;
|
||||
|
||||
fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
|
||||
inode_set_ctime_to_ts(inode, inode->i_mtime);
|
||||
fat_time_fat2unix(sbi, &mtime, de->time, de->date, 0);
|
||||
inode_set_mtime_to_ts(inode, mtime);
|
||||
inode_set_ctime_to_ts(inode, mtime);
|
||||
if (sbi->options.isvfat) {
|
||||
fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0);
|
||||
struct timespec64 atime;
|
||||
|
||||
fat_time_fat2unix(sbi, &atime, 0, de->adate, 0);
|
||||
inode_set_atime_to_ts(inode, atime);
|
||||
fat_time_fat2unix(sbi, &MSDOS_I(inode)->i_crtime, de->ctime,
|
||||
de->cdate, de->ctime_cs);
|
||||
} else
|
||||
inode->i_atime = fat_truncate_atime(sbi, &inode->i_mtime);
|
||||
inode_set_atime_to_ts(inode, fat_truncate_atime(sbi, &mtime));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -849,6 +854,7 @@ static int __fat_write_inode(struct inode *inode, int wait)
|
||||
struct msdos_sb_info *sbi = MSDOS_SB(sb);
|
||||
struct buffer_head *bh;
|
||||
struct msdos_dir_entry *raw_entry;
|
||||
struct timespec64 mtime;
|
||||
loff_t i_pos;
|
||||
sector_t blocknr;
|
||||
int err, offset;
|
||||
@ -882,12 +888,14 @@ static int __fat_write_inode(struct inode *inode, int wait)
|
||||
raw_entry->size = cpu_to_le32(inode->i_size);
|
||||
raw_entry->attr = fat_make_attrs(inode);
|
||||
fat_set_start(raw_entry, MSDOS_I(inode)->i_logstart);
|
||||
fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time,
|
||||
mtime = inode_get_mtime(inode);
|
||||
fat_time_unix2fat(sbi, &mtime, &raw_entry->time,
|
||||
&raw_entry->date, NULL);
|
||||
if (sbi->options.isvfat) {
|
||||
struct timespec64 ts = inode_get_atime(inode);
|
||||
__le16 atime;
|
||||
fat_time_unix2fat(sbi, &inode->i_atime, &atime,
|
||||
&raw_entry->adate, NULL);
|
||||
|
||||
fat_time_unix2fat(sbi, &ts, &atime, &raw_entry->adate, NULL);
|
||||
fat_time_unix2fat(sbi, &MSDOS_I(inode)->i_crtime, &raw_entry->ctime,
|
||||
&raw_entry->cdate, &raw_entry->ctime_cs);
|
||||
}
|
||||
@ -1407,7 +1415,8 @@ static int fat_read_root(struct inode *inode)
|
||||
MSDOS_I(inode)->mmu_private = inode->i_size;
|
||||
|
||||
fat_save_attrs(inode, ATTR_DIR);
|
||||
inode->i_mtime = inode->i_atime = inode_set_ctime(inode, 0, 0);
|
||||
inode_set_mtime_to_ts(inode,
|
||||
inode_set_atime_to_ts(inode, inode_set_ctime(inode, 0, 0)));
|
||||
set_nlink(inode, fat_subdirs(inode)+2);
|
||||
|
||||
return 0;
|
||||
|
@ -325,15 +325,15 @@ int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags)
|
||||
}
|
||||
|
||||
if (flags & S_ATIME)
|
||||
inode->i_atime = fat_truncate_atime(sbi, now);
|
||||
inode_set_atime_to_ts(inode, fat_truncate_atime(sbi, now));
|
||||
/*
|
||||
* ctime and mtime share the same on-disk field, and should be
|
||||
* identical in memory. all mtime updates will be applied to ctime,
|
||||
* but ctime updates are ignored.
|
||||
*/
|
||||
if (flags & S_MTIME)
|
||||
inode->i_mtime = inode_set_ctime_to_ts(inode,
|
||||
fat_truncate_mtime(sbi, now));
|
||||
inode_set_mtime_to_ts(inode,
|
||||
inode_set_ctime_to_ts(inode, fat_truncate_mtime(sbi, now)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user