diff options
author | Paulo Alcantara <pc@manguebit.com> | 2025-04-01 01:13:49 -0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2025-04-07 01:08:27 -0500 |
commit | 3d48316df903a48a533bb313e5da821a163738cd (patch) | |
tree | dd79845c8866574c00667ffda329282ae40b77c0 /fs/smb/client/connect.c | |
parent | b365b9d404b7376c60c91cd079218bfef11b7822 (diff) | |
download | linux-3d48316df903a48a533bb313e5da821a163738cd.tar.gz linux-3d48316df903a48a533bb313e5da821a163738cd.tar.bz2 linux-3d48316df903a48a533bb313e5da821a163738cd.zip |
smb: client: optimize pathname checking
The default mapping for CIFS mounts (SFM) allows mapping backslash, so
fix it by mapping them to 0xf026 in UCS-2 and then allow files and
directories to be created with backslash in their names.
This will optimize cifs_check_name() as it won't need to check for
backslashes anymore when using default SFM mapping.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504021549.evbuYKS3-lkp@intel.com/
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb/client/connect.c')
-rw-r--r-- | fs/smb/client/connect.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 4a0b2d220fe8..49b4deff1361 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -3842,23 +3842,22 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, char *full_path, int added_treename) { - int rc; - char *s; - char sep, tmp; int skip = added_treename ? 1 : 0; + char tmp; + char *s; + int rc; - sep = CIFS_DIR_SEP(cifs_sb); s = full_path; rc = server->ops->is_path_accessible(xid, tcon, cifs_sb, ""); while (rc == 0) { /* skip separators */ - while (*s == sep) + while (*s == '/') s++; if (!*s) break; /* next separator */ - while (*s && *s != sep) + while (*s && *s != '/') s++; /* * if the treename is added, we then have to skip the first @@ -3888,13 +3887,14 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, */ int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx) { - int rc; - struct cifs_sb_info *cifs_sb = mnt_ctx->cifs_sb; struct TCP_Server_Info *server = mnt_ctx->server; - unsigned int xid = mnt_ctx->xid; - struct cifs_tcon *tcon = mnt_ctx->tcon; + struct cifs_sb_info *cifs_sb = mnt_ctx->cifs_sb; struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; + struct cifs_tcon *tcon = mnt_ctx->tcon; + unsigned int xid = mnt_ctx->xid; + bool add_treename; char *full_path; + int rc; if (!server->ops->is_path_accessible) return -EOPNOTSUPP; @@ -3902,8 +3902,8 @@ int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx) /* * cifs_build_path_to_root works only when we have a valid tcon */ - full_path = cifs_build_path_to_root(ctx, cifs_sb, tcon, - tcon->Flags & SMB_SHARE_IS_IN_DFS); + add_treename = !!(tcon->Flags & SMB_SHARE_IS_IN_DFS); + full_path = cifs_build_path_to_root(ctx, tcon, add_treename); if (full_path == NULL) return -ENOMEM; |