linux-cifs.vger.kernel.org archive mirror
 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 v4 01/11] cifs: Make extract_hostname function public
Date: Mon, 30 Nov 2020 19:02:47 +0100	[thread overview]
Message-ID: <20201130180257.31787-2-scabrero@suse.de> (raw)
In-Reply-To: <20201130180257.31787-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 28c1459fb0fc..a938371af6ef 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
@@ -1232,39 +1231,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.2


  reply	other threads:[~2020-11-30 18:04 UTC|newest]

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

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=20201130180257.31787-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;
as well as URLs for NNTP newsgroup(s).