On 10/27/2014 05:21 PM, Michael Stone wrote:
> On Mon, Oct 27, 2014 at 11:54:57AM +0000, Pádraig Brady wrote:
>> On 10/27/2014 08:36 AM, Harald Dunkel wrote:
>>> On 10/24/14 18:24, Pádraig Brady wrote:
>>>>
>>>> Note /home doesn't seem to be accessible above
>>>> which is another reason to prefer /data here.
>>>>
>>>
>>> What do you mean by "not accessible"? Both /home and
>>> /data work fine.
>>
>> I was referring to the fact that "-" was shown for the /home entry:
>>
>> nfs-home:/space/home - - - - /home
>> nfs-home:/space/data 13390666752 10768854016 1941581824 85% /data
>
> That's df's doing. Potentially something like this would get the suggested
> behavior:
>
> --- src/df.c.orig 2014-10-27 12:14:39.633167418 -0400
> +++ src/df.c 2014-10-27 13:16:54.524752800 -0400
> @@ -631,6 +631,10 @@
> /* Stat failed - add ME to be able to complain about it later. */
> buf.st_dev = me->me_dev;
> }
> + else if (me->me_remote)
> + {
> + /* ignore duplicate network mounts */
> + }
> else
> {
> /* If we've already seen this device... */
Still not convinced about that hunk.
> @@ -928,7 +932,7 @@
> if (stat (stat_file, &sb) == 0)
> {
> char const * devname = devname_for_dev (sb.st_dev);
> - if (devname && ! STREQ (devname, disk))
> + if (devname && ! STREQ (devname, disk) && !me_remote)
> {
> fstype = "-";
> fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree =
>
>
> The question then being whether making this case work breaks other cases, and
> whether making it that much harder to explain the logic of what df displays
> is worth it to avoid explaining why a particular set of mounts is captured by
> the current logic. :)
I agree that the "-" placeholders above should not have been output.
The attached patch is just a more general version of the hunk above.
thanks!
Pádraig.
>From 19c3646e1fd2964539fbb4240710e2262582c8d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Mon, 27 Oct 2014 23:37:08 +0000
Subject: [PATCH] df: ensure -a shows all remote file system entries
commit v8.22-125-g9d736f8 printed placeholder "-" values
for device names that didn't match the preferred device name
for a particular mount point. However that was seen to erroneously
suppress values for aliased host names or exports, common with
remote file systems.
* src/df.c (me_for_dev): Rename from devname_for_dev() so that
we can determine the remoteness as well as the name for the
preferred mount entry.
(get_dev): Don't output place holder values when both
current and preferred mount entries are remote.
Reported in http://bugs.debian.org/737399
---
src/df.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/df.c b/src/df.c
index 5231676..a52afc4 100644
--- a/src/df.c
+++ b/src/df.c
@@ -703,17 +703,17 @@ filter_mount_list (bool devices_only)
}
/* Search a mount entry list for device id DEV.
- Return the corresponding device name if found or NULL if not. */
+ Return the corresponding mount entry if found or NULL if not. */
-static char const * _GL_ATTRIBUTE_PURE
-devname_for_dev (dev_t dev)
+static struct mount_entry const * _GL_ATTRIBUTE_PURE
+me_for_dev (dev_t dev)
{
struct devlist *dl = device_list;
while (dl)
{
if (dl->dev_num == dev)
- return dl->me->me_devname;
+ return dl->me;
dl = dl->next;
}
@@ -928,12 +928,15 @@ get_dev (char const *disk, char const *mount_point, char const* file,
else if (process_all && show_all_fs)
{
/* Ensure we don't output incorrect stats for over-mounted directories.
- Discard stats when the device name doesn't match. */
+ Discard stats when the device name doesn't match. Though don't
+ discard when used and current mount entries are both remote due
+ to the possibility of aliased host names or exports. */
struct stat sb;
if (stat (stat_file, &sb) == 0)
{
- char const * devname = devname_for_dev (sb.st_dev);
- if (devname && ! STREQ (devname, disk))
+ struct mount_entry const * dev_me = me_for_dev (sb.st_dev);
+ if (dev_me && ! STREQ (dev_me->me_devname, disk)
+ && (! dev_me->me_remote || ! me_remote))
{
fstype = "-";
fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree =
--
1.7.7.6