@@ -215,6 +215,15 @@ struct ost_id {
#define DOSTID "%#llx:%llu"
#define POSTID(oi) ostid_seq(oi), ostid_id(oi)
+struct ll_futimes_3 {
+ __u64 lfu_atime_sec;
+ __u64 lfu_atime_nsec;
+ __u64 lfu_mtime_sec;
+ __u64 lfu_mtime_nsec;
+ __u64 lfu_ctime_sec;
+ __u64 lfu_ctime_nsec;
+};
+
/*
* The ioctl naming rules:
* LL_* - works on the currently opened filehandle instead of parent dir
@@ -251,6 +260,7 @@ struct ost_id {
#define LL_IOC_PATH2FID _IOR('f', 173, long)
#define LL_IOC_GET_CONNECT_FLAGS _IOWR('f', 174, __u64 *)
#define LL_IOC_GET_MDTIDX _IOR('f', 175, int)
+#define LL_IOC_FUTIMES_3 _IOWR('f', 176, struct ll_futimes_3)
/* lustre_ioctl.h 177-210 */
#define LL_IOC_HSM_STATE_GET _IOR('f', 211, struct hsm_user_state)
@@ -2098,6 +2098,42 @@ static inline long ll_lease_type_from_fmode(fmode_t fmode)
((fmode & FMODE_WRITE) ? LL_LEASE_WRLCK : 0);
}
+static int ll_file_futimes_3(struct file *file, const struct ll_futimes_3 *lfu)
+{
+ struct inode *inode = file_inode(file);
+ struct iattr ia = {
+ .ia_valid = ATTR_ATIME | ATTR_ATIME_SET |
+ ATTR_MTIME | ATTR_MTIME_SET |
+ ATTR_CTIME,
+ .ia_atime = {
+ .tv_sec = lfu->lfu_atime_sec,
+ .tv_nsec = lfu->lfu_atime_nsec,
+ },
+ .ia_mtime = {
+ .tv_sec = lfu->lfu_mtime_sec,
+ .tv_nsec = lfu->lfu_mtime_nsec,
+ },
+ .ia_ctime = {
+ .tv_sec = lfu->lfu_ctime_sec,
+ .tv_nsec = lfu->lfu_ctime_nsec,
+ },
+ };
+ int rc;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ if (!S_ISREG(inode->i_mode))
+ return -EINVAL;
+
+ inode_lock(inode);
+ rc = ll_setattr_raw(file_dentry(file), &ia, OP_XVALID_CTIME_SET,
+ false);
+ inode_unlock(inode);
+
+ return rc;
+}
+
/*
* Give file access advices
*
@@ -2552,6 +2588,16 @@ int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
kfree(hui);
return rc;
}
+ case LL_IOC_FUTIMES_3: {
+ const struct ll_futimes_3 __user *lfu_user;
+ struct ll_futimes_3 lfu;
+
+ lfu_user = (const struct ll_futimes_3 __user *)arg;
+ if (copy_from_user(&lfu, lfu_user, sizeof(lfu)))
+ return -EFAULT;
+
+ return ll_file_futimes_3(file, &lfu);
+ }
case LL_IOC_LADVISE: {
struct llapi_ladvise_hdr *ladvise_hdr;
int alloc_size = sizeof(*ladvise_hdr);