public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Cabrero <scabrero@suse.de>
To: linux-cifs@vger.kernel.org
Cc: Samuel Cabrero <scabrero@suse.de>
Subject: [PATCH v3 01/11] cifs: Make extract_hostname function public
Date: Fri, 30 Oct 2020 12:52:00 +0100	[thread overview]
Message-ID: <20201030115210.8888-2-scabrero@suse.de> (raw)
In-Reply-To: <20201030115210.8888-1-scabrero@suse.de>

Move the function to misc.c and give it a public header.

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
---
 fs/cifs/cifsproto.h |  1 +
 fs/cifs/connect.c   | 34 ----------------------------------
 fs/cifs/misc.c      | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 24c6f36177ba..d716e81d86fa 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -620,6 +620,7 @@ int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov,
 struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server);
 void cifs_put_tcp_super(struct super_block *sb);
 int update_super_prepath(struct cifs_tcon *tcon, char *prefix);
+char *extract_hostname(const char *unc);
 
 #ifdef CONFIG_CIFS_DFS_UPCALL
 static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index c38156f324dd..5aadc4632097 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -284,7 +284,6 @@ static int ip_connect(struct TCP_Server_Info *server);
 static int generic_ip_connect(struct TCP_Server_Info *server);
 static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
 static void cifs_prune_tlinks(struct work_struct *work);
-static char *extract_hostname(const char *unc);
 
 /*
  * Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may
@@ -1230,39 +1229,6 @@ cifs_demultiplex_thread(void *p)
 	module_put_and_exit(0);
 }
 
-/* extract the host portion of the UNC string */
-static char *
-extract_hostname(const char *unc)
-{
-	const char *src;
-	char *dst, *delim;
-	unsigned int len;
-
-	/* skip double chars at beginning of string */
-	/* BB: check validity of these bytes? */
-	if (strlen(unc) < 3)
-		return ERR_PTR(-EINVAL);
-	for (src = unc; *src && *src == '\\'; src++)
-		;
-	if (!*src)
-		return ERR_PTR(-EINVAL);
-
-	/* delimiter between hostname and sharename is always '\\' now */
-	delim = strchr(src, '\\');
-	if (!delim)
-		return ERR_PTR(-EINVAL);
-
-	len = delim - src;
-	dst = kmalloc((len + 1), GFP_KERNEL);
-	if (dst == NULL)
-		return ERR_PTR(-ENOMEM);
-
-	memcpy(dst, src, len);
-	dst[len] = '\0';
-
-	return dst;
-}
-
 static int get_option_ul(substring_t args[], unsigned long *option)
 {
 	int rc;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 1c14cf01dbef..3d5cc25c167f 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -1195,3 +1195,35 @@ int update_super_prepath(struct cifs_tcon *tcon, char *prefix)
 	cifs_put_tcon_super(sb);
 	return rc;
 }
+
+/* extract the host portion of the UNC string */
+char *extract_hostname(const char *unc)
+{
+	const char *src;
+	char *dst, *delim;
+	unsigned int len;
+
+	/* skip double chars at beginning of string */
+	/* BB: check validity of these bytes? */
+	if (strlen(unc) < 3)
+		return ERR_PTR(-EINVAL);
+	for (src = unc; *src && *src == '\\'; src++)
+		;
+	if (!*src)
+		return ERR_PTR(-EINVAL);
+
+	/* delimiter between hostname and sharename is always '\\' now */
+	delim = strchr(src, '\\');
+	if (!delim)
+		return ERR_PTR(-EINVAL);
+
+	len = delim - src;
+	dst = kmalloc((len + 1), GFP_KERNEL);
+	if (dst == NULL)
+		return ERR_PTR(-ENOMEM);
+
+	memcpy(dst, src, len);
+	dst[len] = '\0';
+
+	return dst;
+}
-- 
2.29.0


  reply	other threads:[~2020-10-30 11:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 11:51 [PATCH v3 00/11] Witness protocol support for transparent failover Samuel Cabrero
2020-10-30 11:52 ` Samuel Cabrero [this message]
2020-10-30 11:52 ` [PATCH v3 02/11] cifs: Make extract_sharename function public Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 03/11] cifs: Register generic netlink family Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 04/11] cifs: add witness mount option and data structs Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 05/11] cifs: Send witness register and unregister commands to userspace daemon Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 06/11] cifs: Set witness notification handler for messages from " Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 07/11] cifs: Add witness information to debug data dump Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 08/11] cifs: Send witness register messages to userspace daemon in echo task Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 09/11] cifs: Simplify reconnect code when dfs upcall is enabled Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 10/11] cifs: Handle witness client move notification Samuel Cabrero
2020-10-30 11:52 ` [PATCH v3 11/11] cifs: Handle witness share moved notification Samuel Cabrero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201030115210.8888-2-scabrero@suse.de \
    --to=scabrero@suse.de \
    --cc=linux-cifs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox