[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251205042958.2658496-8-chenxiaosong.chenxiaosong@linux.dev>
Date: Fri, 5 Dec 2025 12:29:55 +0800
From: chenxiaosong.chenxiaosong@...ux.dev
To: sfrench@...ba.org,
smfrench@...il.com,
linkinjeon@...nel.org,
linkinjeon@...ba.org
Cc: linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org,
chenxiaosong@...nxiaosong.com,
ChenXiaoSong <chenxiaosong@...inos.cn>
Subject: [PATCH v2 7/9] smb/client: introduce smb2_get_err_map()
From: ChenXiaoSong <chenxiaosong@...inos.cn>
Preparation for KUnit tests.
Signed-off-by: ChenXiaoSong <chenxiaosong@...inos.cn>
---
fs/smb/client/smb2maperror.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index df8db12ff7a9..f5d999f3b569 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -2433,13 +2433,27 @@ static int cmp_smb2_status(const void *_a, const void *_b)
return 0;
}
+static struct status_to_posix_error *
+smb2_get_err_map(__le32 smb2_status)
+{
+ struct status_to_posix_error *err_map, key;
+
+ key = (struct status_to_posix_error) {
+ .smb2_status = smb2_status,
+ };
+ err_map = bsearch(&key, smb2_error_map_table, err_map_num,
+ sizeof(struct status_to_posix_error),
+ cmp_smb2_status);
+ return err_map;
+}
+
int
map_smb2_to_linux_error(char *buf, bool log_err)
{
struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
int rc = -EIO;
__le32 smb2err = shdr->Status;
- struct status_to_posix_error *err_map, key;
+ struct status_to_posix_error *err_map;
if (smb2err == 0) {
trace_smb3_cmd_done(le32_to_cpu(shdr->Id.SyncId.TreeId),
@@ -2453,12 +2467,7 @@ map_smb2_to_linux_error(char *buf, bool log_err)
(smb2err != STATUS_END_OF_FILE)) ||
(cifsFYI & CIFS_RC);
- key = (struct status_to_posix_error) {
- .smb2_status = smb2err,
- };
- err_map = bsearch(&key, smb2_error_map_table, err_map_num,
- sizeof(struct status_to_posix_error),
- cmp_smb2_status);
+ err_map = smb2_get_err_map(smb2err);
if (!err_map)
goto out;
--
2.43.0
Powered by blists - more mailing lists