Linux-CIFS Archive mirror
 help / color / mirror / Atom feed
From: FredTheDude <FredTheDude@proton.me>
To: "sfrench@samba.org" <sfrench@samba.org>
Cc: "pc@manguebit.org" <pc@manguebit.org>,
	"ronniesahlberg@gmail.com" <ronniesahlberg@gmail.com>,
	"sprasad@microsoft.com" <sprasad@microsoft.com>,
	"tom@talpey.com" <tom@talpey.com>,
	"bharathsm@microsoft.com" <bharathsm@microsoft.com>,
	"linux-cifs@vger.kernel.org" <linux-cifs@vger.kernel.org>,
	"samba-technical@lists.samba.org"
	<samba-technical@lists.samba.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] fs/smb/client: add verbose error logging for UNC parsing
Date: Sun, 29 Mar 2026 02:03:38 +0000	[thread overview]
Message-ID: <2__2tXx9Hngg7rDwgOdZVY8FFBkjQGk_0TviV3dVWkoCa9CZznTtxHJsVvgg9U0lyXUo-_6KKPTPFZTIGTLo9YfQczBj2CxTZypXB2ydr7c=@proton.me> (raw)

Add cifs_dbg(VFS, ...) statements to smb3_parse_devname() to provide
explicit feedback when parsing fails. Currently, the function returns
-EINVAL silently, making it difficult to debug mount failures caused
by malformed paths or missing share names.

Signed-off-by: Fredric Cover <FredTheDude@proton.me>
---

If I made any stupid mistakes, please be patient with me.
C is not my best language, and this is my first patch, and I am just a high school freshman. Thanks!
---
 fs/smb/client/fs_context.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index a4a7c7eee..03c112f4d 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -658,13 +658,17 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)

        /* make sure we have a valid UNC double delimiter prefix */
        len = strspn(devname, delims);
-       if (len != 2)
+       if (len != 2) {
+               cifs_dbg(VFS, "UNC: path must begin with // or \\\\\n");
                return -EINVAL;
+       }

        /* find delimiter between host and sharename */
        pos = strpbrk(devname + 2, delims);
-       if (!pos)
+       if (!pos) {
+               cifs_dbg(VFS, "UNC: missing delimiter between hostname and share name\n");
                return -EINVAL;
+       }

        /* record the server hostname */
        kfree(ctx->server_hostname);
@@ -677,8 +681,10 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)

        /* now go until next delimiter or end of string */
        len = strcspn(pos, delims);
-       if (!len)
+       if (!len) {
+               cifs_dbg(VFS, "UNC: missing share name\n");
                return -EINVAL;
+       }

        /* move "pos" up to delimiter or NULL */
        pos += len;
--
2.43.0

                 reply	other threads:[~2026-03-29  2:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='2__2tXx9Hngg7rDwgOdZVY8FFBkjQGk_0TviV3dVWkoCa9CZznTtxHJsVvgg9U0lyXUo-_6KKPTPFZTIGTLo9YfQczBj2CxTZypXB2ydr7c=@proton.me' \
    --to=fredthedude@proton.me \
    --cc=bharathsm@microsoft.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.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 read-only IMAP folder(s) and NNTP newsgroup(s).