Subject: bug#16539: More details on df command output for you

From: Pádraig Brady <[email-masked]>
Date: Wed, 18 Jun 2014 13:09:56 +0100

On 06/18/2014 02:19 AM, Bernhard Voelker wrote:
> On 06/17/2014 06:03 PM, Pádraig Brady wrote:
>> From 0a4b8027049f6746a237c9fc34a0e0a4afdcfc62 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
>> Date: Wed, 4 Jun 2014 00:09:11 +0100
>> Subject: [PATCH] df: output placeholder values for inaccessible mount points

I agree with all your suggested tweaks here.

> Finally, I have an edge case on my PC which is not yet covered:
> I have a backup partition mounted on /root/backup (which is not
> accessible by a normal user), and a read-only bind-mount of it:
> 
>   $ mount /dev/sda1 /root/backup
>   $ mount --bind    /root/backup /media/backup
>   $ mount -o ro,remount,bind     /media/backup
> 
> (The 3rd command is just there for setting the read-only flag).
> 
> df-8.21 perfectly skipped the inaccessible entry and went ahead
> with the read-only copy
> 
>   $ /usr/bin/df /dev/sda3
>   Filesystem     1K-blocks      Used Available Use% Mounted on
>   /dev/sda3      155396036 124425132  23054156  85% /media/backup
> 
> while the latest one from git plus these 2 patches is falling over:
> 
>   $ src/df /dev/sda3
>   src/df: ‘/root/backup’: Permission denied
> 
> This is a little regression.
> Thus said, I'm not 100% happy with the filtering yet.

The above is a separate case actually, triggered in 8.22 with:
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=2091f449
Note that only triggers the issue when the last mount point for a device
is accessible. If the /proc/mounts order was different, then you'd get the issue anyway.
I'll fix this by adding a stat() to the selection criteria in get_disk().

Thanks for the excellent review.

Pádraig.