Skip to content

Commit

Permalink
ksmbd: set ATTR_CTIME when updating mtime
Browse files Browse the repository at this point in the history
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Dec 6, 2024
1 parent 19fed40 commit f13d906
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6485,19 +6485,18 @@ static int set_file_basic_info(struct ksmbd_file *fp,
attrs.ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET);
}

attrs.ia_valid |= ATTR_CTIME;
if (file_info->ChangeTime)
if (file_info->ChangeTime) {
attrs.ia_ctime = ksmbd_NTtimeToUnix(file_info->ChangeTime);
else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
attrs.ia_ctime = inode_get_ctime(inode);
inode_set_ctime_to_ts(inode, attrs.ia_ctime);
#else
attrs.ia_ctime = inode->i_ctime;
inode->i_ctime = attrs.ia_ctime;
#endif
}

if (file_info->LastWriteTime) {
attrs.ia_mtime = ksmbd_NTtimeToUnix(file_info->LastWriteTime);
attrs.ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET);
attrs.ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET | ATTR_CTIME);
}

if (file_info->Attributes) {
Expand Down Expand Up @@ -6539,14 +6538,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,
return -EACCES;

inode_lock(inode);
if (attrs.ia_valid & ATTR_MTIME) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
inode_set_ctime_to_ts(inode, attrs.ia_ctime);
#else
inode->i_ctime = attrs.ia_ctime;
#endif
attrs.ia_valid &= ~ATTR_CTIME;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
rc = notify_change(idmap, dentry, &attrs, NULL);
Expand Down

0 comments on commit f13d906

Please sign in to comment.