[patch 6/6] vfs: mountinfo: only show mounts under tasks root

Previous thread: [patch 5/6] vfs: optimization to /proc/<pid>/mountinfo patch by Miklos Szeredi on Thursday, March 13, 2008 - 2:26 pm. (3 messages)

Next thread: [patch 3/6] vfs: mountinfo stable peer group id by Miklos Szeredi on Thursday, March 13, 2008 - 2:26 pm. (18 messages)
From: Miklos Szeredi
Date: Thursday, March 13, 2008 - 2:26 pm

From: Miklos Szeredi &lt;mszeredi@suse.cz&gt;

1. Only show reachable mounts in /proc/&lt;pid&gt;/mountinfo, this makes
mountpoints unambiguous for chrooted processes.

2. Instead of showing mountpoints relative to the current root, always
show them relative to the queried task's root.

This means, that a particular mountinfo file will always have the same
contents, regardless of which process is reading the file.  Which is a
lot more consistent, than the current behavior of /proc/&lt;pid&gt;/mounts.

Addressed comments from Jan Blunck and Ram Pai.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
---
 fs/dcache.c                   |   16 ++++++---
 fs/namespace.c                |   23 +++++++++-----
 fs/pnode.c                    |   28 ++++++++++++++---
 fs/pnode.h                    |    2 -
 fs/proc/base.c                |   68 ++++++++++++++++++++++++++----------------
 fs/seq_file.c                 |   25 +++++++++++++++
 include/linux/dcache.h        |    1 
 include/linux/mnt_namespace.h |    8 ++++
 include/linux/seq_file.h      |    2 +
 9 files changed, 128 insertions(+), 45 deletions(-)

Index: linux/fs/dcache.c
===================================================================
--- linux.orig/fs/dcache.c	2008-03-13 20:45:52.000000000 +0100
+++ linux/fs/dcache.c	2008-03-13 20:45:53.000000000 +0100
@@ -1760,12 +1760,12 @@ static int prepend(char **buffer, int *b
 
 /**
  * d_path - return the path of a dentry
- * @dentry: dentry to report
- * @vfsmnt: vfsmnt to which the dentry belongs
+ * @path: the dentry/vfsmount to report
  * @root: root dentry
  * @rootmnt: vfsmnt to which the root dentry belongs
  * @buffer: buffer to return value in
  * @buflen: buffer length
+ * @only_reachable: if true, then path must be reachable from root
  *
  * Convert a dentry into an ASCII path name. If the entry has been deleted
  * the string &quot; (deleted)&quot; is appended. Note that this is ambiguous.
@@ -1774,9 +1774,11 @@ static int prepend(char **buffer, int *b
  *
  * &quot;buflen&quot; should be ...
From: Al Viro
Date: Wednesday, March 19, 2008 - 5:12 am

Humm...  Might make sense to update *root in case we hit that place and
do the rest in callers, instead of playing with extra arguments...
Hell knows, I'd try to massage in that direction and see if anything

*UGH*.  Do you really need that?  Frankly, in that case I'd rather
--

From: Miklos Szeredi
Date: Wednesday, March 19, 2008 - 5:25 am

Agreed.  I did the separate check first, but then there's a window
between the check and __d_path() where the mountpoint might move
outside the root, and trying to prevent that would also add quite a
bit of ugliness.

Miklos
--

Previous thread: [patch 5/6] vfs: optimization to /proc/<pid>/mountinfo patch by Miklos Szeredi on Thursday, March 13, 2008 - 2:26 pm. (3 messages)

Next thread: [patch 3/6] vfs: mountinfo stable peer group id by Miklos Szeredi on Thursday, March 13, 2008 - 2:26 pm. (18 messages)