linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ronnie Sahlberg <lsahlber@redhat.com>
To: linux-cifs <linux-cifs@vger.kernel.org>
Cc: Steve French <smfrench@gmail.com>
Subject: [PATCH 04/21] cifs: move cifs_parse_devname to fs_context.c
Date: Tue,  8 Dec 2020 09:36:29 +1000	[thread overview]
Message-ID: <20201207233646.29823-4-lsahlber@redhat.com> (raw)
In-Reply-To: <20201207233646.29823-1-lsahlber@redhat.com>

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/cifsproto.h  |  1 +
 fs/cifs/connect.c    | 59 ++--------------------------------------------------
 fs/cifs/fs_context.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 57 deletions(-)

diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 13ce85af1204..aa66a6b9aaf5 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -89,6 +89,7 @@ extern void cifs_mid_q_entry_release(struct mid_q_entry *midEntry);
 extern void cifs_wake_up_task(struct mid_q_entry *mid);
 extern int cifs_handle_standard(struct TCP_Server_Info *server,
 				struct mid_q_entry *mid);
+extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
 extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
 extern int cifs_discard_remaining_data(struct TCP_Server_Info *server);
 extern int cifs_call_async(struct TCP_Server_Info *server,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 17e9e95d54e5..c447ace656ed 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1256,61 +1256,6 @@ static int get_option_gid(substring_t args[], kgid_t *result)
 	return 0;
 }
 
-/*
- * Parse a devname into substrings and populate the vol->UNC and vol->prepath
- * fields with the result. Returns 0 on success and an error otherwise.
- */
-static int
-cifs_parse_devname(const char *devname, struct smb3_fs_context *ctx)
-{
-	char *pos;
-	const char *delims = "/\\";
-	size_t len;
-
-	if (unlikely(!devname || !*devname)) {
-		cifs_dbg(VFS, "Device name not specified\n");
-		return -EINVAL;
-	}
-
-	/* make sure we have a valid UNC double delimiter prefix */
-	len = strspn(devname, delims);
-	if (len != 2)
-		return -EINVAL;
-
-	/* find delimiter between host and sharename */
-	pos = strpbrk(devname + 2, delims);
-	if (!pos)
-		return -EINVAL;
-
-	/* skip past delimiter */
-	++pos;
-
-	/* now go until next delimiter or end of string */
-	len = strcspn(pos, delims);
-
-	/* move "pos" up to delimiter or NULL */
-	pos += len;
-	ctx->UNC = kstrndup(devname, pos - devname, GFP_KERNEL);
-	if (!ctx->UNC)
-		return -ENOMEM;
-
-	convert_delimiter(ctx->UNC, '\\');
-
-	/* skip any delimiter */
-	if (*pos == '/' || *pos == '\\')
-		pos++;
-
-	/* If pos is NULL then no prepath */
-	if (!*pos)
-		return 0;
-
-	ctx->prepath = kstrdup(pos, GFP_KERNEL);
-	if (!ctx->prepath)
-		return -ENOMEM;
-
-	return 0;
-}
-
 static int
 cifs_parse_mount_options(const char *mountdata, const char *devname,
 			 struct smb3_fs_context *ctx, bool is_smb3)
@@ -1414,7 +1359,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
 	ctx->backupuid_specified = false; /* no backup intent for a user */
 	ctx->backupgid_specified = false; /* no backup intent for a group */
 
-	switch (cifs_parse_devname(devname, ctx)) {
+	switch (smb3_parse_devname(devname, ctx)) {
 	case 0:
 		break;
 	case -ENOMEM:
@@ -4534,7 +4479,7 @@ static int check_dfs_prepath(struct cifs_sb_info *cifs_sb, struct smb3_fs_contex
 			struct smb3_fs_context v = {NULL};
 			/* if @path contains a tree name, skip it in the prefix path */
 			if (added_treename) {
-				rc = cifs_parse_devname(path, &v);
+				rc = smb3_parse_devname(path, &v);
 				if (rc)
 					break;
 				rc = -EREMOTE;
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 301201903b45..3b15f9a882b2 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -260,3 +260,59 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
 
 	return rc;
 }
+
+/*
+ * Parse a devname into substrings and populate the ctx->UNC and ctx->prepath
+ * fields with the result. Returns 0 on success and an error otherwise.
+ */
+int
+smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
+{
+	char *pos;
+	const char *delims = "/\\";
+	size_t len;
+
+	if (unlikely(!devname || !*devname)) {
+		cifs_dbg(VFS, "Device name not specified\n");
+		return -EINVAL;
+	}
+
+	/* make sure we have a valid UNC double delimiter prefix */
+	len = strspn(devname, delims);
+	if (len != 2)
+		return -EINVAL;
+
+	/* find delimiter between host and sharename */
+	pos = strpbrk(devname + 2, delims);
+	if (!pos)
+		return -EINVAL;
+
+	/* skip past delimiter */
+	++pos;
+
+	/* now go until next delimiter or end of string */
+	len = strcspn(pos, delims);
+
+	/* move "pos" up to delimiter or NULL */
+	pos += len;
+	ctx->UNC = kstrndup(devname, pos - devname, GFP_KERNEL);
+	if (!ctx->UNC)
+		return -ENOMEM;
+
+	convert_delimiter(ctx->UNC, '\\');
+
+	/* skip any delimiter */
+	if (*pos == '/' || *pos == '\\')
+		pos++;
+
+	/* If pos is NULL then no prepath */
+	if (!*pos)
+		return 0;
+
+	ctx->prepath = kstrdup(pos, GFP_KERNEL);
+	if (!ctx->prepath)
+		return -ENOMEM;
+
+	return 0;
+}
+
-- 
2.13.6


  parent reply	other threads:[~2020-12-07 23:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20201207233646.29823-1-lsahlber@redhat.com>
2020-12-07 23:36 ` [PATCH 02/21] cifs: rename dup_vol to smb3_fs_context_dup and move it into fs_context.c Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 03/21] cifs: move the enum for cifs parameters into fs_context.h Ronnie Sahlberg
2020-12-07 23:36 ` Ronnie Sahlberg [this message]
2020-12-07 23:36 ` [PATCH 05/21] cifs: switch to new mount api Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 06/21] cifs: remove the devname argument to cifs_compose_mount_options Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 07/21] cifs: add an smb3_fs_context to cifs_sb Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 08/21] cifs: get rid of cifs_sb->mountdata Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 09/21] cifs: remove [gu]id/backup[gu]id/file_mode/dir_mode from cifs_sb Ronnie Sahlberg
2020-12-12 19:42   ` Steve French
2020-12-07 23:36 ` [PATCH 10/21] cifs: remove actimeo " Ronnie Sahlberg
2020-12-12 19:44   ` Steve French
2020-12-07 23:36 ` [PATCH 11/21] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 12/21] cifs: move [brw]size from cifs_sb to cifs_sb->ctx Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 13/21] cifs: add initial reconfigure support Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 14/21] cifs: we do not allow changing username/password/unc/... during remount Ronnie Sahlberg
2020-12-08  5:06   ` Steve French
2020-12-08 18:42     ` Pavel Shilovsky
2020-12-08 21:38       ` ronnie sahlberg
2020-12-07 23:36 ` [PATCH 15/21] cifs: simplify handling of cifs_sb/ctx->local_nls Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 16/21] cifs: don't create a temp nls in cifs_setup_ipc Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 17/21] cifs: uncomplicate printing the iocharset parameter Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 18/21] cifs: do not allow changing posix_paths during remount Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 19/21] cifs: remove ctx argument from cifs_setup_cifs_sb Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 20/21] cifs: move update of flags into a separate function Ronnie Sahlberg
2020-12-07 23:36 ` [PATCH 21/21] cifs: update mnt_cifs_flags during reconfigure Ronnie Sahlberg

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=20201207233646.29823-4-lsahlber@redhat.com \
    --to=lsahlber@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=smfrench@gmail.com \
    /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).