summaryrefslogtreecommitdiff
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@suse.de>2020-11-30 21:02:48 +0300
committerSteve French <stfrench@microsoft.com>2020-12-14 18:16:22 +0300
commite73a42e07a2246ecd8b0cad70824d26ab07985c2 (patch)
tree3de15027ab55dcbf92a4fbd3c4f7bb3392f01707 /fs/cifs/misc.c
parenta87e67254bc5da9ca6f3899e354fcf03d12cfd10 (diff)
downloadlinux-e73a42e07a2246ecd8b0cad70824d26ab07985c2.tar.xz
cifs: Make extract_sharename function public
Move the function to misc.c Signed-off-by: Samuel Cabrero <scabrero@suse.de> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/misc.c')
-rw-r--r--fs/cifs/misc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 3d5cc25c167f..f0a1c24751b2 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1227,3 +1227,27 @@ char *extract_hostname(const char *unc)
return dst;
}
+
+char *extract_sharename(const char *unc)
+{
+ const char *src;
+ char *delim, *dst;
+ int len;
+
+ /* skip double chars at the beginning */
+ src = unc + 2;
+
+ /* share name is always preceded by '\\' now */
+ delim = strchr(src, '\\');
+ if (!delim)
+ return ERR_PTR(-EINVAL);
+ delim++;
+ len = strlen(delim);
+
+ /* caller has to free the memory */
+ dst = kstrndup(delim, len, GFP_KERNEL);
+ if (!dst)
+ return ERR_PTR(-ENOMEM);
+
+ return dst;
+}