From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@ZenIV.linux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
hch@infradead.org
Subject: [patch 3/3] vfs: fix sys_getcwd for detached mounts
Date: Mon, 23 Jun 2008 18:11:54 +0200 [thread overview]
Message-ID: <20080623161213.116829182@szeredi.hu> (raw)
In-Reply-To: <20080623161151.597847108@szeredi.hu>
[-- Attachment #1: vfs-fix-sys_getcwd-for-detached-mounts.patch --]
[-- Type: text/plain, Size: 1396 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Currently getcwd(2) on a detached mount will give a garbled result:
> mkdir /mnt/foo
> mount --bind /etc /mnt/foo
> cd /mnt/foo/skel
> /bin/pwd
/mnt/foo/skel
> umount -l /mnt/foo
> /bin/pwd
etcskel
After the patch it will give "detached:skel" as result.
Thanks to John Johansen for pointing out this bug.
Comment from Al Viro: use "detached:" prefix to differentiate it from
attached paths.
Reported-by: John Johansen <jjohansen@suse.de>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/dcache.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Index: linux-2.6/fs/dcache.c
===================================================================
--- linux-2.6.orig/fs/dcache.c 2008-06-23 17:35:39.000000000 +0200
+++ linux-2.6/fs/dcache.c 2008-06-23 17:46:05.000000000 +0200
@@ -1828,8 +1828,16 @@ char *__d_path(const struct path *path,
global_root:
retval += 1; /* hit the slash */
- if (prepend_name(&retval, &buflen, &dentry->d_name) != 0)
- goto Elong;
+
+ if (IS_ROOT(dentry)) {
+ /* Attached, or pseudo filesystem with "foo:" prefix */
+ if (prepend_name(&retval, &buflen, &dentry->d_name) != 0)
+ goto Elong;
+ } else {
+ /* Detached */
+ if (prepend(&retval, &buflen, "detached:", 9) != 0)
+ goto Elong;
+ }
root->mnt = vfsmnt;
root->dentry = dentry;
return retval;
--
next prev parent reply other threads:[~2008-06-23 16:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-23 16:11 [patch 0/3] vfs: d_path cleanups and fixes Miklos Szeredi
2008-06-23 16:11 ` [patch 1/3] vfs: dcache sparse fixes Miklos Szeredi
2008-06-23 16:11 ` [patch 2/3] vfs: dcache cleanups Miklos Szeredi
2008-06-23 16:11 ` Miklos Szeredi [this message]
2008-06-23 16:53 ` [patch 3/3] vfs: fix sys_getcwd for detached mounts Miklos Szeredi
2008-06-23 16:58 ` Miklos Szeredi
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=20080623161213.116829182@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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
all inboxes | Powered by JetHome®