lede/package/kernel/ksmbd/patches/02-fix-build-with-kernel-6.6.patch
2024-01-25 20:17:05 +08:00

122 lines
3.4 KiB
Diff

From ab78eb9095c3b508dc1dceaf5757e56877a5a02e Mon Sep 17 00:00:00 2001
From: W_Y_CPP <383152993@qq.com>
Date: Thu, 25 Jan 2024 05:15:13 -0500
Subject: [PATCH] fix build with kernel 6.6
---
compat.c | 6 ++++++
smb1pdu.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/compat.c b/compat.c
index cd48401..47fe647 100644
--- a/compat.c
+++ b/compat.c
@@ -8,6 +8,12 @@
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
+int compat_inode_permission(struct path *path, struct inode *inode, int mask)
+{
+ return inode_permission(mnt_idmap(path->mnt), inode, mask);
+
+}
+
void compat_generic_fillattr(struct path *path, u32 request_mask,
struct inode *inode, struct kstat *kstat)
{
diff --git a/smb1pdu.c b/smb1pdu.c
index 7501a53..6d9d204 100644
--- a/smb1pdu.c
+++ b/smb1pdu.c
@@ -825,7 +825,12 @@ int smb_rename(struct ksmbd_work *work)
char *oldname, *newname;
struct ksmbd_file *fp = NULL;
int oldname_len;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+ struct path path, parent_path;
+ int flags = 0;
+#else
struct path path;
+#endif
bool file_present = true;
int rc = 0;
@@ -858,8 +863,12 @@ int smb_rename(struct ksmbd_work *work)
newname = NULL;
goto out;
}
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+ rc = ksmbd_vfs_kern_path_locked(work, newname, LOOKUP_NO_SYMLINKS,
+ &parent_path, &path, 1);
+#else
rc = ksmbd_vfs_kern_path(work, newname, LOOKUP_NO_SYMLINKS, &path, 1);
+#endif
if (rc)
file_present = false;
else
@@ -873,7 +882,12 @@ int smb_rename(struct ksmbd_work *work)
}
ksmbd_debug(SMB, "rename %s -> %s\n", oldname, newname);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+ rc = ksmbd_vfs_kern_path_locked(work, oldname, LOOKUP_NO_SYMLINKS,
+ &parent_path, &path, 1);
+#else
rc = ksmbd_vfs_kern_path(work, oldname, LOOKUP_NO_SYMLINKS, &path, 1);
+#endif
if (rc)
goto out;
@@ -883,8 +897,11 @@ int smb_rename(struct ksmbd_work *work)
path_put(&path);
goto out;
}
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+ rc = ksmbd_vfs_rename(work, &fp->filp->f_path, newname, flags);
+#else
rc = ksmbd_vfs_fp_rename(work, fp, newname);
+#endif
if (rc) {
rsp->hdr.Status.CifsError = STATUS_NO_MEMORY;
path_put(&path);
@@ -7344,6 +7361,9 @@ static int smb_fileinfo_rename(struct ksmbd_work *work)
struct ksmbd_file *fp;
char *newname;
int rc = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+ int flags = 0;
+#endif
req = (struct smb_com_trans2_sfi_req *)work->request_buf;
rsp = (struct smb_com_trans2_sfi_rsp *)work->response_buf;
@@ -7381,7 +7401,11 @@ static int smb_fileinfo_rename(struct ksmbd_work *work)
}
ksmbd_debug(SMB, "new name(%s)\n", newname);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
+ rc = ksmbd_vfs_rename(work, &fp->filp->f_path, newname, flags);
+#else
rc = ksmbd_vfs_fp_rename(work, fp, newname);
+#endif
if (rc) {
rsp->hdr.Status.CifsError = STATUS_UNEXPECTED_IO_ERROR;
goto out;
@@ -8380,7 +8404,11 @@ int smb_open_andx(struct ksmbd_work *work)
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
+ generic_fillattr(mnt_idmap(path.mnt), STATX_BASIC_STATS, d_inode(path.dentry),&stat);
+#else
generic_fillattr(mnt_idmap(path.mnt), d_inode(path.dentry), &stat);
+#endif
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
generic_fillattr(mnt_user_ns(path.mnt), d_inode(path.dentry), &stat);
--
2.17.1