* _reliable_ way to get the dev for a mount point?
@ 2002-05-06 9:55 Pozsar Balazs
2002-05-06 17:38 ` Erik Andersen
0 siblings, 1 reply; 4+ messages in thread
From: Pozsar Balazs @ 2002-05-06 9:55 UTC (permalink / raw)
To: linux-kernel
Hi all!
I found that in a chrooted environment the /proc/mounts file is
messed up badly. For example, if I do a
chroot /path/to/somewhere
then in the chrooted environment's proc/mounts file will truncate
the /path/to/somewhere string from those mount point it can, and leaves
the rest as they are. (something like s|/path/to/somewhere|| )
Consequently you will have at least two devices showns as mounted to /.
But it can get worse (i know its extreme), if the directory of the
chrooted environment is overmounted.
For example, here's an output from inside the chroot environment:
# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw 0 0
none /dev devfs rw 0 0
none /proc proc rw 0 0
none /proc/bus/usb usbdevfs rw 0 0
none /root/chroot1/proc proc rw 0 0
/dev/cdrom / iso9660 ro 0 0
none /proc proc rw 0 0
/dev/hda2 / ext3 rw 0 0
As you can see, there are 3 devices shown as mounted to / (in reality,
only 2 in the chrooted env), and you cannot know from this which of these
3 is your real rootdir.
So, my question is there a way to get back the device for a directory,
_reliably_. (I want to know which devices holds the files my process sees
under an arbitrary /path/to/somewhere).
Thanks,
--
Balazs Pozsar
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: _reliable_ way to get the dev for a mount point?
2002-05-06 9:55 _reliable_ way to get the dev for a mount point? Pozsar Balazs
@ 2002-05-06 17:38 ` Erik Andersen
2002-05-06 18:10 ` Xavier Bestel
0 siblings, 1 reply; 4+ messages in thread
From: Erik Andersen @ 2002-05-06 17:38 UTC (permalink / raw)
To: Pozsar Balazs; +Cc: linux-kernel
On Mon May 06, 2002 at 11:55:38AM +0200, Pozsar Balazs wrote:
> So, my question is there a way to get back the device for a directory,
> _reliably_. (I want to know which devices holds the files my process sees
> under an arbitrary /path/to/somewhere).
stat(mnt_point, &statbuf); then walk through /dev and stat each
device, check that it is a block device and that st_rdev matches
the statbuf.st_rdev. When you get a match, you know a device
name for the directory.
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: _reliable_ way to get the dev for a mount point?
2002-05-06 17:38 ` Erik Andersen
@ 2002-05-06 18:10 ` Xavier Bestel
2002-05-08 10:28 ` Denis Vlasenko
0 siblings, 1 reply; 4+ messages in thread
From: Xavier Bestel @ 2002-05-06 18:10 UTC (permalink / raw)
To: andersen; +Cc: Pozsar Balazs, Linux Kernel Mailing List
Le lun 06/05/2002 à 19:38, Erik Andersen a écrit :
> On Mon May 06, 2002 at 11:55:38AM +0200, Pozsar Balazs wrote:
> > So, my question is there a way to get back the device for a directory,
> > _reliably_. (I want to know which devices holds the files my process sees
> > under an arbitrary /path/to/somewhere).
>
> stat(mnt_point, &statbuf); then walk through /dev and stat each
> device, check that it is a block device and that st_rdev matches
> the statbuf.st_rdev. When you get a match, you know a device
> name for the directory.
is devfs walkable ? I mean, no loops or infinite dynamically generated
directory ?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: _reliable_ way to get the dev for a mount point?
2002-05-06 18:10 ` Xavier Bestel
@ 2002-05-08 10:28 ` Denis Vlasenko
0 siblings, 0 replies; 4+ messages in thread
From: Denis Vlasenko @ 2002-05-08 10:28 UTC (permalink / raw)
To: Xavier Bestel; +Cc: Linux Kernel Mailing List
> > stat(mnt_point, &statbuf); then walk through /dev and stat each
> > device, check that it is a block device and that st_rdev matches
> > the statbuf.st_rdev. When you get a match, you know a device
> > name for the directory.
>
> is devfs walkable ? I mean, no loops or infinite dynamically generated
> directory ?
If not, you still can do that but walk method must be clever
(do 1-level deep search, then 2-level, etc)
--
vda
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-05-08 5:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-06 9:55 _reliable_ way to get the dev for a mount point? Pozsar Balazs
2002-05-06 17:38 ` Erik Andersen
2002-05-06 18:10 ` Xavier Bestel
2002-05-08 10:28 ` Denis Vlasenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox