Re: [d_path 0/7] Fixes to d_path: Respin

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ulrich Drepper <drepper@...>
Cc: Alan Cox <alan@...>, <jjohansen@...>, <linux-kernel@...>, <linux-security-module@...>, <linux-fsdevel@...>, <chrisw@...>, Andrew Morton <akpm@...>
Date: Saturday, April 21, 2007 - 3:04 pm

On Friday 20 April 2007 21:17, Ulrich Drepper wrote:

What I described is a supported feature, nothing more and nothing less. It's 
also relatively easy to handle this case correctly in glibc, e.g.,

--- a/sysdeps/unix/sysv/linux/internal_statvfs.c
+++ b/sysdeps/unix/sysv/linux/internal_statvfs.c
@@ -139,6 +139,7 @@ __statvfs_getflags (const char *name, in
 	      char *cp = mntbuf.mnt_opts;
 	      char *opt;
 
+	      result = 0;
 	      while ((opt = strsep (&cp, ",")) != NULL)
 		if (strcmp (opt, "ro") == 0)
 		  result |= ST_RDONLY;
@@ -157,9 +158,10 @@ __statvfs_getflags (const char *name, in
 		else if (strcmp (opt, "nodiratime") == 0)
 		  result |= ST_NODIRATIME;
 
-	      /* We can stop looking for more entries.  */
 	      success = true;
-	      break;
+	      /* Don't stop looking: the same device may be mounted several
+	         times with different options; in that case, the last entry
+		 is the topmost mount.  */
 	    }
 	}
       /* Maybe the kernel names for the filesystems changed or the


There is no way to avoid these problems with chroots; it's not that anybody 
creates stupid problems on purpose.

The approach I'm proposing fixes these problems. It has a small disadvantage 
for statvfs / fstatvfs in some situations, which is due to the fact that the 
kernel doesn't offer a direct interface for querying the mount options of a 
file descriptor or path, and so glibc has to resort to messing 
with /proc/mounts. I don't see a nice way of fixing this without introducing 
[f]statvfs syscalls right now.

This is what POSIX says about statvfs / fstatvfs:

In my opinion, the advantage of not reporting bogus pathnames in /proc/mounts 
by far outweighs the problems is sometimes causes for fstatvfs(). Anyone 
relying on the information obtained from statvfs / fstatvfs is making false 
assumptions anyway, and in "normal setups" as you called them, nothing 
changes for fstatvfs and statvfs.

Andreas
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [AppArmor 31/41] Fix __d_path() for lazy unmounts and ma..., Andreas Gruenbacher, (Sun Apr 15, 1:40 pm)
Re: [AppArmor 31/41] Fix __d_path() for lazy unmounts and ma..., Andreas Gruenbacher, (Mon Apr 16, 9:35 pm)
[d_path 2/7] Make d_path() consistent across mount operations, Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
[d_path 0/7] Fixes to d_path: Respin, Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
Re: [d_path 0/7] Fixes to d_path: Respin, Alan Cox, (Fri Apr 20, 5:30 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Andreas Gruenbacher, (Fri Apr 20, 7:45 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Ulrich Drepper, (Fri Apr 20, 11:15 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Andreas Gruenbacher, (Fri Apr 20, 11:21 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Ulrich Drepper, (Fri Apr 20, 11:24 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Andreas Gruenbacher, (Fri Apr 20, 12:40 pm)
Re: [d_path 0/7] Fixes to d_path: Respin, Ulrich Drepper, (Fri Apr 20, 3:17 pm)
Re: [d_path 0/7] Fixes to d_path: Respin, Andreas Gruenbacher, (Sat Apr 21, 3:04 pm)
Re: [d_path 0/7] Fixes to d_path: Respin, Christoph Hellwig, (Sun Apr 22, 5:10 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Andreas Gruenbacher, (Sun Apr 22, 11:48 am)
Re: [d_path 0/7] Fixes to d_path: Respin, Ulrich Drepper, (Sat Apr 21, 3:46 pm)
Re: [d_path 0/7] Fixes to d_path: Respin, Miklos Szeredi, (Fri Apr 20, 4:44 pm)
[d_path 4/7] Make getcwd() only return valid paths, Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
[d_path 5/7] Remove duplicate proc code, Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
[d_path 3/7] Add d_namespace_path() to compute namespace rel..., Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
Re: [d_path 3/7] Add d_namespace_path() to compute namespace..., Andreas Gruenbacher, (Sat Apr 21, 12:16 pm)
[d_path 1/7] Fix __d_path() for lazy unmounts and make it un..., Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
[d_path 7/7] Distinguish between connected and disconnected ..., Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)
[d_path 6/7] Filter out disconnected paths from /proc/mounts, Andreas Gruenbacher, (Thu Apr 19, 7:23 pm)