[Toybox] [PATCH] df, stat: query mount stats lazily instead of eagerly in xgetmountlist

Rob Landley rob at landley.net
Mon Aug 24 17:58:48 UTC 2026


On 8/23/26 23:42, Thiébaud Weksteen wrote:
> The main issue we observe is these extra verbose logs from SELinux.
> Basically, in our tests we are validating the space available on the
> device /data directory (`df /data`), which triggers many denial logs
> when trying to access other mount points.
> I extrapolated the issue for any slow/blocking device, but you're
> right, it can be handled with O_NONBLOCK.

Does O_NONBLOCK avoid the log spam?

If the stat() of all mounted filesystems is expensive, then restricting 
activity to just the listed locations on the command line makes sense. 
Except finding "mounted on" can be nonobvious, and even chasing ".." to 
find where the major/minor changes can miss bind mounts:

$ mkdir sub2
$ sudo mount --bind sub sub2
$ cd sub2
$ df .
Filesystem      1K-blocks       Used Available Use% Mounted on
/dev/sda1      1905210712 1507957720 300399796  84% /home/landley/sub2

Rob

If we do add O_NONBLOCK, there's still a need to do a blocking one when 
a device _does_ need to be spun up to get information. That can 
presumably go in the display function, I'm just not sure what info the 
nonblock stat would return vs the blocking stat. (It doesn't know free 
space, but should presumably know major/minor of filesystem? Have to 
experiment...)


More information about the Toybox mailing list