Bug in mountpoint applet?
Michael Tokarev
mjt at tls.msk.ru
Tue Aug 14 12:42:49 UTC 2012
14.08.2012 16:33, Harald Becker wrote:
> Hi all,
>
> looks like there is a bug in Busybox mountpoint:
>
> $ mkdir m r
> $ mount -obind m r
> $ touch m/a touch m/b
> $ ls m/
> a b
> $ ls r/
> a b
> $ mountpoint r
> r is a mountpoint
> $ busybox mountpoint
> r is not a mountpoint !!!
>
> Looks that Busybox mountpoint ignore via bind mounted directories and
> illegally report them as not being a mounted point. Did not dig into
> source, just detected that bug.
If you can detect such a mountpoint somehow, without resorting to
parsing /proc/mounts, please let the world know.
Usual trick to detect a mountpoint is to stat(2) the directory
in question and the parent directory of it, and compare
st_rdev fields of the two (see man 2 stat). If they differ,
it is a mountpoint, if they're the same, it is not.
When you bind-mount one directory into another in the same
system, both will have the same st_rdev. So there's no known
way to detect such mountpoints, and parsing /proc/mounts is
at least slow and unreliable.
Note: you can also bind-mount a single _file_, not a directory.
This has the same issue.
This is a kernel interface problem, and is known since the day
bind mounts were introduced in 2.4 kernel.
Thanks,
/mjt
More information about the busybox
mailing list