[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Take the last matching entry in /etc/mtab, not the first.
From: |
James Youngman |
Subject: |
[PATCH] Take the last matching entry in /etc/mtab, not the first. |
Date: |
Wed, 1 Jun 2011 11:29:27 +0100 |
* find/fstype.c (file_system_type_uncached): Instead of taking the
first match, take the last match. This deals better with mtab
implementations in which there can be duplicate entries, for
example Linux-based systems in which /etc/mtab is a symlink to
/proc/mounts) can have duplicate entries in the file system list.
This happens most frequently for /.
* NEWS: Mention this change.
---
ChangeLog | 11 +++++++++++
NEWS | 7 +++++++
find/fstype.c | 16 +++++++++++++---
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dd8e341..bec1b7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-06-01 James Youngman <address@hidden>
+ Take the last matching entry in /etc/mtab, not the first.
+ * find/fstype.c (file_system_type_uncached): Instead of taking the
+ first match, take the last match. This deals better with mtab
+ implementations in which there can be duplicate entries, for
+ example Linux-based systems in which /etc/mtab is a symlink to
+ /proc/mounts) can have duplicate entries in the file system list.
+ This happens most frequently for /.
+ * NEWS: Mention this change.
+
+2011-06-01 James Youngman <address@hidden>
+
Better error handling for the result of set_fstype_devno.
* find/fstype.c (file_system_type_uncached): If set_fstype_devno
fails for an entry (that is, the device number stays at -1) don't
diff --git a/NEWS b/NEWS
index ee0792f..9912045 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,13 @@ are re-used, but no executing child process will have the
same value
as another executing child process. This wishlist item was Savannah
bug #29512.
+** Functional Changes to find
+
+When expanding "-printf '%F'", find reads /etc/mtab. We now take the
+last match found in this file, rather than the first, to better deal
+with implementations which have duplicate entries (for example
+/proc/mounts on systems running the Linux kernel).
+
* Major changes in release 4.5.10, 2011-05-11
** Documentation Changes
diff --git a/find/fstype.c b/find/fstype.c
index fc8c09c..acf607f 100644
--- a/find/fstype.c
+++ b/find/fstype.c
@@ -215,7 +215,7 @@ must_read_fs_list (bool need_fs_type)
static char *
file_system_type_uncached (const struct stat *statp, const char *path)
{
- struct mount_entry *entries, *entry;
+ struct mount_entry *entries, *entry, *best;
char *type;
(void) path;
@@ -228,6 +228,7 @@ file_system_type_uncached (const struct stat *statp, const
char *path)
}
#endif
+ best = NULL;
entries = must_read_fs_list (true);
for (type=NULL, entry=entries; entry; entry=entry->me_next)
{
@@ -239,11 +240,20 @@ file_system_type_uncached (const struct stat *statp,
const char *path)
{
if (entry->me_dev == statp->st_dev)
{
- type = xstrdup (entry->me_type);
- break;
+ best = entry;
+ /* Don't exit the loop, because some systems (for
+ example Linux-based systems in which /etc/mtab is a
+ symlink to /proc/mounts) can have duplicate entries
+ in the filesystem list. This happens most frequently
+ for /.
+ */
}
}
}
+ if (best)
+ {
+ type = xstrdup (best->me_type);
+ }
free_file_system_list (entries);
/* Don't cache unknown values. */
--
1.7.2.5