All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 8/8 v3] cifs: Add support for follow_link on dfs shares under posix extensions
Date: Mon,  2 Dec 2013 16:37:43 +0000	[thread overview]
Message-ID: <1386002263-8630-1-git-send-email-sprabhu@redhat.com> (raw)
In-Reply-To: <1385399395-19217-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

When using posix extensions, dfs shares in the dfs root show up as
symlinks resulting in userland tools such as 'ls' calling readlink() on
these shares. Since these are dfs shares, we end up returning -EREMOTE.

$ ls -l /mnt
ls: cannot read symbolic link /mnt/test: Object is remote
total 0
lrwxrwxrwx. 1 root root 19 Nov  6 09:47 test

With added follow_link() support for dfs shares, when using unix
extensions, we call GET_DFS_REFERRAL to obtain the DFS referral and
return the first node returned.

The dfs share in the dfs root is now displayed in the following manner.
$ ls -l /mnt
total 0
lrwxrwxrwx. 1 root root 19 Nov  6 09:47 test -> \vm140-31\test

Signed-off-by: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/smb1ops.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 988fddb7..abd2cc9 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -908,6 +908,33 @@ cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
 }
 
 static int
+cifs_unix_dfs_readlink(const unsigned int xid, struct cifs_tcon *tcon,
+		       const unsigned char *searchName, char **symlinkinfo,
+		       const struct nls_table *nls_codepage)
+{
+#ifdef CONFIG_CIFS_DFS_UPCALL
+	int rc;
+	unsigned int num_referrals = 0;
+	struct dfs_info3_param *referrals = NULL;
+
+	rc = get_dfs_path(xid, tcon->ses, searchName, nls_codepage,
+			  &num_referrals, &referrals, 0);
+
+	if (!rc && num_referrals > 0) {
+		*symlinkinfo = kstrndup(referrals->node_name,
+					strlen(referrals->node_name),
+					GFP_KERNEL);
+		if (!*symlinkinfo)
+			rc = -ENOMEM;
+		free_dfs_info_array(referrals, num_referrals);
+	}
+	return rc;
+#else /* No DFS support */
+	return -EREMOTE;
+#endif
+}
+
+static int
 cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
 		   const char *full_path, char **target_path,
 		   struct cifs_sb_info *cifs_sb)
@@ -922,6 +949,11 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
 	if (cap_unix(tcon->ses)) {
 		rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, target_path,
 					     cifs_sb->local_nls);
+		if (rc == -EREMOTE)
+			rc = cifs_unix_dfs_readlink(xid, tcon, full_path,
+						    target_path,
+						    cifs_sb->local_nls);
+
 		goto out;
 	}
 
-- 
1.8.3.1

  parent reply	other threads:[~2013-12-02 16:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 17:09 [PATCH 0/8] Clean up MF-Symlink code and add readlink support for DFS shares Sachin Prabhu
     [not found] ` <1385399395-19217-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-25 17:09   ` [PATCH 1/8] cifs: We do not drop reference to tlink in CIFSCheckMFSymlink() Sachin Prabhu
     [not found]     ` <1385399395-19217-2-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:35       ` Jeff Layton
     [not found]         ` <20131127063507.6e1a9a14-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2013-12-09 15:37           ` Steve French
     [not found]     ` <CAH2r5mufmo9P_qaM7g8zRtPxKW9yaZ+HMba21PUUw9odXEpzGg@mail.gmail.com>
     [not found]       ` <CAH2r5mufmo9P_qaM7g8zRtPxKW9yaZ+HMba21PUUw9odXEpzGg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-09 16:23         ` Sachin Prabhu
2013-11-25 17:09   ` [PATCH 2/8] cifs: Rename and cleanup open_query_close_cifs_symlink() Sachin Prabhu
     [not found]     ` <1385399395-19217-3-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:36       ` Jeff Layton
2013-11-25 17:09   ` [PATCH 3/8] cifs: Rename MF symlink function names Sachin Prabhu
     [not found]     ` <1385399395-19217-4-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:36       ` Jeff Layton
2013-11-25 17:09   ` [PATCH 4/8] cifs: use protocol specific call for query_mf_symlink() Sachin Prabhu
     [not found]     ` <1385399395-19217-5-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:39       ` Jeff Layton
2013-11-25 17:09   ` [PATCH 5/8] cifs: Add create MFSymlinks to protocol ops struct Sachin Prabhu
     [not found]     ` <1385399395-19217-6-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:40       ` Jeff Layton
2013-11-25 17:09   ` [PATCH 6/8] cifs: Re-order M-F Symlink code Sachin Prabhu
     [not found]     ` <1385399395-19217-7-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:41       ` Jeff Layton
2013-11-25 17:09   ` [PATCH 7/8] cifs: move unix extension call to cifs_query_symlink() Sachin Prabhu
     [not found]     ` <1385399395-19217-8-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:41       ` Jeff Layton
2013-11-25 17:09   ` [PATCH 8/8] cifs: Add support for readlink on dfs shares under posix extensions Sachin Prabhu
     [not found]     ` <1385399395-19217-9-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-27 11:45       ` Jeff Layton
     [not found]         ` <20131127064551.7a8b77a2-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2013-11-27 12:58           ` Sachin Prabhu
2013-11-27 13:05             ` Jeff Layton
2013-11-27 17:10       ` Christoph Hellwig
2013-11-27 13:27   ` [PATCH 7/8 v2] cifs: move unix extension call to cifs_query_symlink() Sachin Prabhu
2013-11-27 13:27   ` [PATCH 8/8 v2] cifs: Add support for readlink on dfs shares under posix extensions Sachin Prabhu
     [not found]     ` <1385558835-7990-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-12-02 16:41       ` Sachin Prabhu
2013-12-02 16:37   ` Sachin Prabhu [this message]
2014-01-20  6:44   ` [PATCH 0/8] Clean up MF-Symlink code and add readlink support for DFS shares Steve French

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=1386002263-8630-1-git-send-email-sprabhu@redhat.com \
    --to=sprabhu-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.