modules: fix nfs and ksmbd build with kernel 6.6

This commit is contained in:
coolsnowwolf 2024-01-25 20:17:05 +08:00
parent 6022ecc6bc
commit e7298575b9
3 changed files with 128 additions and 6 deletions

View File

@ -1,12 +1,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ksmbd
PKG_VERSION:=3.4.8
PKG_VERSION:=2023.12.22
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/cifsd-team/ksmbd/releases/download/$(PKG_VERSION)
PKG_HASH:=209bfba4dc5c50007942a3ec24f86a7f7c628618ac07f79c62e3404dc247d495
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/cifsd-team/ksmbd
PKG_SOURCE_VERSION:=0590dfae7a6e0a50eda6584286b2c6215aaddea1
PKG_MIRROR_HASH:=95415120722db35ca599ab6ca36fd6310fc11ca50acf7d6235d4b0f397c46dd4
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=COPYING
@ -40,6 +41,7 @@ define KernelPackage/fs-ksmbd
+kmod-oid-registry
endef
# The last two DEPENDS are hacks in order to get CONFIG_ASN1 and CONFIG_OID_REGISTRY
# which it seems can't be selected independently. Some bug in either base or upstream.

View File

@ -0,0 +1,121 @@
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

View File

@ -440,8 +440,7 @@ define KernelPackage/fs-nfs-common
FILES:= \
$(LINUX_DIR)/fs/lockd/lockd.ko \
$(LINUX_DIR)/net/sunrpc/sunrpc.ko \
$(LINUX_DIR)/fs/nfs_common/grace.ko \
$(LINUX_DIR)/fs/nfs_common/nfs_ssc.ko@ge5.10
$(LINUX_DIR)/fs/nfs_common/grace.ko
AUTOLOAD:=$(call AutoLoad,30,grace sunrpc lockd)
endef