|
|
04161d |
From 0f053de4bc3ca0cfd88a42d236881dfdddb10ee9 Mon Sep 17 00:00:00 2001
|
|
|
04161d |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
04161d |
Date: Wed, 30 Jun 2021 17:53:22 +0200
|
|
|
04161d |
Subject: [PATCH] df: fix duplicated remote entries due to bind mounts
|
|
|
04161d |
|
|
|
04161d |
As originally reported in <https://bugzilla.redhat.com/1962515>,
|
|
|
04161d |
df invoked without -a printed duplicated entries for NFS mounts
|
|
|
04161d |
of bind mounts. This is a regression from commit v8.25-54-g1c17f61ef99,
|
|
|
04161d |
which introduced the use of a hash table.
|
|
|
04161d |
|
|
|
04161d |
The proposed patch makes sure that the devlist entry seen the last time
|
|
|
04161d |
is used for comparison when eliminating duplicated mount entries. This
|
|
|
04161d |
way it worked before introducing the hash table.
|
|
|
04161d |
|
|
|
04161d |
Patch co-authored by Roberto Bergantinos.
|
|
|
04161d |
|
|
|
04161d |
* src/ls.c (struct devlist): Introduce the seen_last pointer.
|
|
|
04161d |
(devlist_for_dev): Return the devlist entry seen the last time if found.
|
|
|
04161d |
(filter_mount_list): Remember the devlist entry seen the last time for
|
|
|
04161d |
each hashed item.
|
|
|
04161d |
Fixes https://bugs.gnu.org/49298
|
|
|
04161d |
|
|
|
04161d |
Upstream-commit: d6125af095c9553f38cba0696f15158f5abe4ecc
|
|
|
04161d |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
04161d |
---
|
|
|
04161d |
src/df.c | 15 +++++++++++++--
|
|
|
04161d |
1 file changed, 13 insertions(+), 2 deletions(-)
|
|
|
04161d |
|
|
|
04161d |
diff --git a/src/df.c b/src/df.c
|
|
|
04161d |
index 7e01839..3e9247f 100644
|
|
|
04161d |
--- a/src/df.c
|
|
|
04161d |
+++ b/src/df.c
|
|
|
04161d |
@@ -54,6 +54,7 @@ struct devlist
|
|
|
04161d |
dev_t dev_num;
|
|
|
04161d |
struct mount_entry *me;
|
|
|
04161d |
struct devlist *next;
|
|
|
04161d |
+ struct devlist *seen_last; /* valid for hashed devlist entries only */
|
|
|
04161d |
};
|
|
|
04161d |
|
|
|
04161d |
/* Filled with device numbers of examined file systems to avoid
|
|
|
04161d |
@@ -689,7 +690,13 @@ devlist_for_dev (dev_t dev)
|
|
|
04161d |
return NULL;
|
|
|
04161d |
struct devlist dev_entry;
|
|
|
04161d |
dev_entry.dev_num = dev;
|
|
|
04161d |
- return hash_lookup (devlist_table, &dev_entry);
|
|
|
04161d |
+
|
|
|
04161d |
+ struct devlist *found = hash_lookup (devlist_table, &dev_entry);
|
|
|
04161d |
+ if (found == NULL)
|
|
|
04161d |
+ return NULL;
|
|
|
04161d |
+
|
|
|
04161d |
+ /* Return the last devlist entry we have seen with this dev_num */
|
|
|
04161d |
+ return found->seen_last;
|
|
|
04161d |
}
|
|
|
04161d |
|
|
|
04161d |
static void
|
|
|
04161d |
@@ -807,8 +814,12 @@ filter_mount_list (bool devices_only)
|
|
|
04161d |
devlist->dev_num = buf.st_dev;
|
|
|
04161d |
devlist->next = device_list;
|
|
|
04161d |
device_list = devlist;
|
|
|
04161d |
- if (hash_insert (devlist_table, devlist) == NULL)
|
|
|
04161d |
+
|
|
|
04161d |
+ struct devlist *hash_entry = hash_insert (devlist_table, devlist);
|
|
|
04161d |
+ if (hash_entry == NULL)
|
|
|
04161d |
xalloc_die ();
|
|
|
04161d |
+ /* Ensure lookups use this latest devlist. */
|
|
|
04161d |
+ hash_entry->seen_last = devlist;
|
|
|
04161d |
|
|
|
04161d |
me = me->me_next;
|
|
|
04161d |
}
|
|
|
04161d |
--
|
|
|
04161d |
2.31.1
|
|
|
04161d |
|