]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/fat/namei_msdos.c
Merge tag 'for-linus-20181102' of git://git.kernel.dk/linux-block
[linux.git] / fs / fat / namei_msdos.c
index 16a832c37d663b518432387e5826c1b957fee3d9..f2cd365a4e86ec01bf02a2d5afdd5f00c07dab66 100644 (file)
@@ -225,7 +225,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
 /***** Creates a directory entry (name is already formatted). */
 static int msdos_add_entry(struct inode *dir, const unsigned char *name,
                           int is_dir, int is_hid, int cluster,
-                          struct timespec *ts, struct fat_slot_info *sinfo)
+                          struct timespec64 *ts, struct fat_slot_info *sinfo)
 {
        struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
        struct msdos_dir_entry de;
@@ -250,7 +250,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
        if (err)
                return err;
 
-       dir->i_ctime = dir->i_mtime = timespec_to_timespec64(*ts);
+       fat_truncate_time(dir, ts, S_CTIME|S_MTIME);
        if (IS_DIRSYNC(dir))
                (void)fat_sync_inode(dir);
        else
@@ -267,7 +267,6 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        struct inode *inode = NULL;
        struct fat_slot_info sinfo;
        struct timespec64 ts;
-       struct timespec t;
        unsigned char msdos_name[MSDOS_NAME];
        int err, is_hid;
 
@@ -286,8 +285,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        }
 
        ts = current_time(dir);
-       t = timespec64_to_timespec(ts);
-       err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &t, &sinfo);
+       err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &ts, &sinfo);
        if (err)
                goto out;
        inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
@@ -296,7 +294,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
                err = PTR_ERR(inode);
                goto out;
        }
-       inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
+       fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME);
        /* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
        d_instantiate(dentry, inode);
@@ -329,7 +327,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
        drop_nlink(dir);
 
        clear_nlink(inode);
-       inode->i_ctime = current_time(inode);
+       fat_truncate_time(inode, NULL, S_CTIME);
        fat_detach(inode);
 out:
        mutex_unlock(&MSDOS_SB(sb)->s_lock);
@@ -347,7 +345,6 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        struct inode *inode;
        unsigned char msdos_name[MSDOS_NAME];
        struct timespec64 ts;
-       struct timespec t;
        int err, is_hid, cluster;
 
        mutex_lock(&MSDOS_SB(sb)->s_lock);
@@ -365,13 +362,12 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        }
 
        ts = current_time(dir);
-       t = timespec64_to_timespec(ts);
-       cluster = fat_alloc_new_dir(dir, &t);
+       cluster = fat_alloc_new_dir(dir, &ts);
        if (cluster < 0) {
                err = cluster;
                goto out;
        }
-       err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &t, &sinfo);
+       err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo);
        if (err)
                goto out_free;
        inc_nlink(dir);
@@ -384,7 +380,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
                goto out;
        }
        set_nlink(inode, 2);
-       inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
+       fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME);
        /* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
        d_instantiate(dentry, inode);
@@ -417,7 +413,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
        if (err)
                goto out;
        clear_nlink(inode);
-       inode->i_ctime = current_time(inode);
+       fat_truncate_time(inode, NULL, S_CTIME);
        fat_detach(inode);
 out:
        mutex_unlock(&MSDOS_SB(sb)->s_lock);
@@ -482,7 +478,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
                                mark_inode_dirty(old_inode);
 
                        inode_inc_iversion(old_dir);
-                       old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
+                       fat_truncate_time(old_dir, NULL, S_CTIME|S_MTIME);
                        if (IS_DIRSYNC(old_dir))
                                (void)fat_sync_inode(old_dir);
                        else
@@ -503,9 +499,8 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
                new_i_pos = MSDOS_I(new_inode)->i_pos;
                fat_detach(new_inode);
        } else {
-               struct timespec t = timespec64_to_timespec(ts);
                err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0,
-                                     &t, &sinfo);
+                                     &ts, &sinfo);
                if (err)
                        goto out;
                new_i_pos = sinfo.i_pos;
@@ -543,7 +538,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
        if (err)
                goto error_dotdot;
        inode_inc_iversion(old_dir);
-       old_dir->i_ctime = old_dir->i_mtime = ts;
+       fat_truncate_time(old_dir, &ts, S_CTIME|S_MTIME);
        if (IS_DIRSYNC(old_dir))
                (void)fat_sync_inode(old_dir);
        else
@@ -553,7 +548,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
                drop_nlink(new_inode);
                if (is_dir)
                        drop_nlink(new_inode);
-               new_inode->i_ctime = ts;
+               fat_truncate_time(new_inode, &ts, S_CTIME);
        }
 out:
        brelse(sinfo.bh);
@@ -642,6 +637,7 @@ static const struct inode_operations msdos_dir_inode_operations = {
        .rename         = msdos_rename,
        .setattr        = fat_setattr,
        .getattr        = fat_getattr,
+       .update_time    = fat_update_time,
 };
 
 static void setup(struct super_block *sb)