[Toybox] [PATCH] df: -a should even show mounts we couldn't stat.

Rob Landley rob at landley.net
Wed Feb 17 13:36:14 PST 2021


On 2/16/21 2:52 PM, Yi-yo Chiang wrote:
> There is still one weird case left in df, albeit not related to previous issues, 
> $ adb shell df
> Filesystem                    1K-blocks    Used Available Use% Mounted on
> /dev/block/dm-1                  964296  961376      2920 100% /
> tmpfs                           2004636    1060   2003576   1% /dev
> $ adb shell df /dev/block/dm-1
> Filesystem     1K-blocks Used Available Use% Mounted on
> tmpfs            2004636 1060   2003576   1% /dev
> 
> This is due to the st_dev of /dev/block/dm-1 equals to that of /dev.

Because the node lives in /dev so it's showing that filesystem.

> However /dev/block/dm-1 is a special device, so df should be checking its
> st_rdev, not st_dev.
> Only when /dev/block/dm-1 is not mounted, should we check its st_dev... 😵

There's actually code for it:

            if (st.st_dev == mt->stat.st_dev
                || (st.st_rdev && (st.st_rdev == mt->stat.st_dev)))

The problem is since I wrote that devtmpfs showed up, and that means /dev is
mounted as its own file system more recently that whatever's mounted on / and it
traverses the list from end to front to find the most recent matching mount
(because overmounts are sequenced that way)...

Sounds like if (rdev) it should _always_ check rdev? Only check st_dev when rdev
is zero? (Is rdev reliably zero the rest of the time...?)

Rob


More information about the Toybox mailing list