Skip to contentSkip to conversation

/etc/mtab and per-process namespaces

DISCUSSION David Leimbach 8 participants 13 messages Oct 2, 2005 – Oct 22, 2005

lore
Share & tools
lore
#0 lore raw

I've been just playing around with the v9fs work and private namespaces from yesterday's [October 1, 2005] top of tree from Linus' git archive and I was looking at /etc/mtab's reaction to having multiple namespaces with bind mounts.

I have a directory ("slash") and bind it to "/" in a new namespace created with a clone call. /etc/mtab then has a line appended to it for this bind.

/ /home/dave/slash none rw,bind 0 0

Then in the "global default" namespace I do the same thing. This adds yet another line to my /etc/mtab with exactly the same contents.

I then exited both shells and /etc/mtab is left with both lines:

/ /home/dave/slash none rw,bind 0 0
/ /home/dave/slash none rw,bind 0 0

Did I just "leak" a namespace or is mtab just way off from reality now?

Also, if I check the procfs it seems to have no record of either of these binds ever occurring. [/proc/mounts]

Also, does it make sense to even think about adding a pid column number for the "private" namespaces or perhaps just to mark it as "priv" or something to that effect.

It's not clear to me what the best way to deal with this would be. Right now it appears to be broken or at least very inconsistent.

I can think of a lot of ways to use private namespaces to avoid conflicts with software installations... much like the DragonFlyBSD folks use variant symlinks to have two-level data about what version of libx libx.so links to. I just think private namespaces make this a bit more elegant to handle, especially in the context of Xen and upcoming virtualization hardware from Intel and AMD. As such I find this feature of linux [and Plan 9/Inferno - where it came from] to be pretty important.

- Dave

#1 lore raw

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

I'm seriously hoping it's 3 :). 2 Is acceptable too of course. I think this is important and I want to know more about the innards anyway. 1 would make me sad as I think Linux can really show other Unix's what-for here when it comes to showing off how good the VFS can be.

Linux has always been a bit of DIY, so I guess I just need to accept that. It's not unlike the KDE development model. People who want certain things done either motivate others to help or make a run for it on their own, even in the face of adversity. Kind of more noble that way I guess.

Dave

#2 lore raw

I suspect not one cares about /etc/mtab. It's a pretty horrible interface. Use /proc/self/mounts if your care about the mount table for your current namespace, it's guranteed uptodate.

#3 lore raw
Quoted 3 lines · Christoph Hellwig

I suspect not one cares about /etc/mtab. It's a pretty horrible interface. Use /proc/self/mounts if your care about the mount table for your current namespace, it's guranteed uptodate.

Well, it's uptodate, but it isn't the same as mtab. Like:

/tmp/test on /mnt/test type ext2 (rw,loop=/dev/loop/0)
(mtab), vs
/dev/loop/0 /mnt/test ext2 rw 0 0

or:

tmpfs on /dev type tmpfs (rw,size=10M,mode=0755)
vs
tmpfs /dev tmpfs rw 0 0

ie, sometimes, mtab format is more useful. Also, with the above example with loop device, umount is able to delete the loop device for loop-mounts.

Another funky example:

losetup /dev/loop/0 /tmp/test
cd /dev/loop
mount 0 /mnt/test

now, mtab shows:

/dev/loop/0 /mnt/test ext2 rw 0 0

while /proc/mounts shows

0 /mnt/test ext2 rw 0 0

which is rather useless.

/mjt

#4 lore raw
In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig

I suspect not one cares about /etc/mtab. It's a pretty horrible interface. Use /proc/self/mounts if your care about the mount table for your current namespace, it's guranteed uptodate.

Hmmm that works pretty well, but it's lacking in some ways.

/dev/hdc3 /root/slash reiserfs rw 0 0
/dev/hdc3 /home/dave/blah resierfs rw 0 0

The above is not very descriptive.

/etc/mtab has:
/ /root/slash none rw,bind 0 0 /home/dave/public_html /home/dave/blah none rw,bind 0 0

Which tells me more about what I care about for 'bind' mounts.

However it does violate the "privacy" of the namespace by telling everyone on the system how I have my stuff mounted :).

/proc/self/mounts does a much better job respecting this privacy but doesn't give the information I really care about.

I think I'm looking for something like "ns" on Plan 9 or Inferno that dumps out how my current namespace is constructed. Each process with a private namespace should get different results for "ns".

Dave

#5 lore raw
In reply to David Leimbach
Quoted 8 lines · David Leimbach

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

4) If you insist on having /etc/mtab the same file in all namespaces, you obviously will have its contents not matching at least some of them. Either have it separate in each namespace where you want to see it, or simply use /proc/self/mounts instead.

BTW, "private" is an odd term - they are all on the same footing; "system" one is just the namespace of init (and those of its descendents that share the namespace with it). Nothing special about it...

#6 lore raw
Quoted 10 lines · Al Viro
Quoted 8 lines · David Leimbach

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

Quoted 4 lines

4) If you insist on having /etc/mtab the same file in all namespaces, you obviously will have its contents not matching at least some of them. Either have it separate in each namespace where you want to see it, or simply use /proc/self/mounts instead.

Well I guess it's my fault to some extent with the subject line. I don't really care about /etc/mtab so much except that I'd like it to be consistent if it is going to be there. I'd rather it do one of two things. Show me my current process's namespace accurately or just the stuff that's global to all namespaces. Right now it's kind of in between.

Also since when I type "mount" it just spits out what's in "mtab" it seems like that should be made more accurate... not /proc/self/mounts.

(it looks like you can just edit the file and stick whatever you want in there... I just stuck the line:
"blah blah blah"
in there and got:
"blah on blah type blah ()"
from "mount" with no arguments)

Quoted 5 lines

BTW, "private" is an odd term - they are all on the same footing; "system" one is just the namespace of init (and those of its descendents that share the namespace with it). Nothing special about it...

It's actually a bit more like "protected" I suppose [in an OO inheritance sense]. If I use clone with the right flags my new process has a namespace that doesn't get reflected in the other process's. Sure I still inherit the parent's namespace, but I'm free to bind to my hearts content in ways that other processes will not see [unless they are children of the currently clone'd process].

Even in this "protected" namespace other processes can clearly see what I'm doing via /etc/mtab. It seems there will always be a way to sniff out this information though since all the files of the form /proc/<pid>/mounts are read accessible by everyone.

Dave

#7 lore raw
Quoted 16 lines · David Leimbach
Quoted 10 lines · Al Viro
Quoted 8 lines · David Leimbach

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

Quoted 4 lines

4) If you insist on having /etc/mtab the same file in all namespaces, you obviously will have its contents not matching at least some of them. Either have it separate in each namespace where you want to see it, or simply use /proc/self/mounts instead.

Quoted 6 lines

Well I guess it's my fault to some extent with the subject line. I don't really care about /etc/mtab so much except that I'd like it to be consistent if it is going to be there. I'd rather it do one of two things. Show me my current process's namespace accurately or just the stuff that's global to all namespaces. Right now it's kind of in between.

/etc/mtab is just a regular file; no more, no less. It's a place used by mount(8) and several other programs. Kernel has nothing to do with it...

Obns: that can get tough. Note that Plan 9 one is an approximation that works well enough for most uses; if you play with mounting/unmounting/renaming in sufficiently perverted ways, you'll get unusable /proc/<pid>/ns. The trouble being, they are luckier - they don't have to deal with many classes of perversion we do, so their soluition wouldn't work well for Linux.

#8 lore raw
In reply to David Leimbach
Quoted 9 lines · David Leimbach

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

Quoted 5 lines

I'm seriously hoping it's 3 :). 2 Is acceptable too of course. I think this is important and I want to know more about the innards anyway. 1 would make me sad as I think Linux can really show other Unix's what-for here when it comes to showing off how good the VFS can be.

This becomes even more intresting when sharedsubtree gets added to the equation. One would like to know all the mounts in its namesapace and than all the mounts it propagates to which could include mounts in other namespaces too..

I guess some interface that meets the following needs would eventually be needed:

1. what are all the mounts in my namespace ?
A. what are the attributes of each of the mounts?
a. where is it mounted
b. who is its parent
c. what is it mounted from
d. what are the attributes of its mount
e. what are its peer mounts (I suspect some kind
of identifier has
to be associated with each mount)
f. if it has a master mount where is it
g. what are its slave mounts.at
(note: e, f, g can point to mounts in other namespaces)
2. what are the attributes of my namespace?
a. what is the parent namespace? ( I suspect some kind
of identifier has to associated
with each namespace, pid of the cloned process?)
b. what are my children namespace?

3. which processes can access my namespace?

And I don't think /etc/mtab can do a decent job with this, because it would not know where all the mounts propagate, when it attempts a mount. Only the kernel would know, and hence all the commands who depend on /etc/mtab may have to depend on some /proc or maybe /sysfs interface to do a descent job.

RP

Quoted 13 lines

Linux has always been a bit of DIY, so I guess I just need to accept that. It's not unlike the KDE development model. People who want certain things done either motivate others to help or make a run for it on their own, even in the face of adversity. Kind of more noble that way I guess.

Dave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw
Quoted 43 lines · Ram
Quoted 9 lines · David Leimbach

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

Quoted 5 lines

I'm seriously hoping it's 3 :). 2 Is acceptable too of course. I think this is important and I want to know more about the innards anyway. 1 would make me sad as I think Linux can really show other Unix's what-for here when it comes to showing off how good the VFS can be.

This becomes even more intresting when sharedsubtree gets added to the equation. One would like to know all the mounts in its namesapace and than all the mounts it propagates to which could include mounts in other namespaces too..

I guess some interface that meets the following needs would eventually be needed:

1. what are all the mounts in my namespace ?
A. what are the attributes of each of the mounts?
a. where is it mounted
b. who is its parent
c. what is it mounted from
d. what are the attributes of its mount
e. what are its peer mounts (I suspect some kind
of identifier has
to be associated with each mount)
f. if it has a master mount where is it
g. what are its slave mounts.at
(note: e, f, g can point to mounts in other namespaces)
2. what are the attributes of my namespace?
a. what is the parent namespace? ( I suspect some kind
of identifier has to associated
with each namespace, pid of the cloned process?)
b. what are my children namespace?

Quoted 9 lines

3. which processes can access my namespace?

And I don't think /etc/mtab can do a decent job with this, because it would not know where all the mounts propagate, when it attempts a mount. Only the kernel would know, and hence all the commands who depend on /etc/mtab may have to depend on some /proc or maybe /sysfs interface to do a descent job.

Or, you bite the bullet and fix /proc/mounts and let distributions bind mount /proc/mounts over /etc/mtab.

Sun recognized this as a problem a long time ago and /etc/mnttab has been magic for quite some time now.

Add to this the fact that a textfile /etc/mtab is busted because it's whitespace seperated and pieces blows up and you do things like:

mount filer:/export/mikew "/home/Mike Waychison"

Mike Waychison

#10 lore raw
Quoted 56 lines · Mike Waychison
Quoted 45 lines · Ram
Quoted 9 lines · David Leimbach

Hmm no responses on this thread a couple days now. I guess:

1) No one cares about private namespaces or the fact that they make /etc/mtab totally inconsistent.
2) Private Namespaces aren't important to anyone and will never be robust unless someone who cares, like me, takes it over somehow.
3) Everyone is busy with their own shit and doesn't want to deal with me or mine right now.

Quoted 5 lines

I'm seriously hoping it's 3 :). 2 Is acceptable too of course. I think this is important and I want to know more about the innards anyway. 1 would make me sad as I think Linux can really show other Unix's what-for here when it comes to showing off how good the VFS can be.

This becomes even more intresting when sharedsubtree gets added to the equation. One would like to know all the mounts in its namesapace and than all the mounts it propagates to which could include mounts in other namespaces too..

I guess some interface that meets the following needs would eventually be needed:

1. what are all the mounts in my namespace ?
A. what are the attributes of each of the mounts?
a. where is it mounted
b. who is its parent
c. what is it mounted from
d. what are the attributes of its mount
e. what are its peer mounts (I suspect some kind
of identifier has
to be associated with each mount)
f. if it has a master mount where is it
g. what are its slave mounts.at
(note: e, f, g can point to mounts in other namespaces)
2. what are the attributes of my namespace?
a. what is the parent namespace? ( I suspect some kind
of identifier has to associated
with each namespace, pid of the cloned process?)
b. what are my children namespace?

Quoted 9 lines

3. which processes can access my namespace?

And I don't think /etc/mtab can do a decent job with this, because it would not know where all the mounts propagate, when it attempts a mount. Only the kernel would know, and hence all the commands who depend on /etc/mtab may have to depend on some /proc or maybe /sysfs interface to do a descent job.

Quoted 5 lines

Or, you bite the bullet and fix /proc/mounts and let distributions bind mount /proc/mounts over /etc/mtab.

Sun recognized this as a problem a long time ago and /etc/mnttab has been magic for quite some time now.

Don't forget to update mount as well.

Ian

#11 lore raw
Quoted 9 lines · Ian Kent
Quoted 5 lines

Or, you bite the bullet and fix /proc/mounts and let distributions bind mount /proc/mounts over /etc/mtab.

Sun recognized this as a problem a long time ago and /etc/mnttab has been magic for quite some time now.

Don't forget to update mount as well.

Ian

I'm the maintainer of the busybox mount command. We've had /etc/mtab support be optional (you can configure it out) for a while now.

There was some fancy footwork trying to get umount to automatically free loop devices and such, but as far as I know that's all resolved in subversion and if we can ever get a 1.1 release out, it should all just work...

Rob

#12 lore raw
In reply to David Leimbach
Quoted 4 lines · David Leimbach

I've been just playing around with the v9fs work and private namespaces from yesterday's [October 1, 2005] top of tree from Linus' git archive and I was looking at /etc/mtab's reaction to having multiple namespaces with bind mounts.

Oh you don't need namespaces to hork mtab. Do a mount from a chroot environment. Or try to use --bind or --move mounts (at all) and watch it beg for mercy. (I accidentally ran UserMode Linux as root once, using a hostfs root filesystem to borrow the existing Linux's root filesystem, and its' mounts edited the parent system's /etc/mtab. Yeah, that was user error on my part, but it's also the _only_ gotcha I've found when doing that.)

/etc/mtab is simply brittle. Personally, on systems I build, I ln -s /proc/mounts /etc/mtab

Rob