tools-utils: Do not skip symbolic links when analyzing a linux tree

Message ID 20210824213012.2486940-1-maennich@google.com
State New
Headers
Series tools-utils: Do not skip symbolic links when analyzing a linux tree |

Commit Message

Matthias Männich Aug. 24, 2021, 9:30 p.m. UTC
  For various reasons, (parts of) a linux kernel tree containing vmlinux
and kernel modules might be organized using symbolic links. One reason
is that those binaries physically reside on a different storage and are
linked into place. To support such scenarios by allowing to traverse
symbolic links when discovering linux kernel binaries.

I could not see a reason why this was disabled in the first place.
Ignoring symbolic links had been the default since the inception of the
kernel mode.

Hence, allow valid symbolic links and that is what this patch does.

	* src/abg-tools-utils.cc (find_vmlinux_and_module_paths): Do not
	skip valid symbolic links.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-tools-utils.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Dodji Seketeli Sept. 1, 2021, 8:53 a.m. UTC | #1
Hello Matthias,

Matthias Maennich <maennich@google.com> a écrit:

> For various reasons, (parts of) a linux kernel tree containing vmlinux
> and kernel modules might be organized using symbolic links. One reason
> is that those binaries physically reside on a different storage and are
> linked into place. To support such scenarios by allowing to traverse
> symbolic links when discovering linux kernel binaries.
>
> I could not see a reason why this was disabled in the first place.
> Ignoring symbolic links had been the default since the inception of the
> kernel mode.

Following symbolic link is disabled because there can be cases where the
link points to a directory of the kernel tree, causing cycles in the
tree.  In that case, fts_read can return the same file several times.

I seem to remember that it had noticeable performance impacts on the
tests I did with our kernels.

So to support symbolic link, we'd need to properly handle (avoid?) those
cycles, probably by taking into account the FTS_DC bit of the
FTSENT::fts_info data member.  I haven't looked into it in details,
though.

Have you seen the same think in those cases?

Thanks.

[...]
  

Patch

diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index 2fb20c6e9e2c..cc9a23ea3497 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -2298,8 +2298,8 @@  find_vmlinux_and_module_paths(const string&	from,
   FTSENT *entry;
   while ((entry = fts_read(file_hierarchy)))
     {
-      // Skip descendents of symbolic links.
-      if (entry->fts_info == FTS_SL || entry->fts_info == FTS_SLNONE)
+      // Skip descendents of dead symbolic links.
+      if (entry->fts_info == FTS_SLNONE)
 	{
 	  fts_set(file_hierarchy, entry, FTS_SKIP);
 	  continue;