diff options
author | James Youngman <jay@gnu.org> | 2011-06-01 11:11:20 +0100 |
---|---|---|
committer | James Youngman <jay@gnu.org> | 2011-06-04 00:17:58 +0100 |
commit | 1d37a22a7f1d3b08c086430b96071c293c02e6d0 (patch) | |
tree | 176cda8518b5d3f41752ab00fda4bf21ff3fef98 | |
parent | f3d4ac9bb470775df8ceb371b689825a69d8a7fb (diff) | |
download | findutils-1d37a22a7f1d3b08c086430b96071c293c02e6d0.tar.gz |
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.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | find/fstype.c | 16 |
3 files changed, 31 insertions, 3 deletions
@@ -1,3 +1,14 @@ +2011-06-01 James Youngman <jay@gnu.org> + + 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-02 James Youngman <jay@gnu.org> Remove unnecessary header checks and include guards. @@ -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 cac2d28e..e9230fb9 100644 --- a/find/fstype.c +++ b/find/fstype.c @@ -213,7 +213,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; @@ -226,6 +226,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) { @@ -237,11 +238,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. */ |