]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl -k/-K match compressed .ko files
authorRoland McGrath <roland@redhat.com>
Tue, 6 Jan 2009 08:10:23 +0000 (00:10 -0800)
committerRoland McGrath <roland@redhat.com>
Tue, 6 Jan 2009 08:10:23 +0000 (00:10 -0800)
libdwfl/ChangeLog
libdwfl/linux-kernel-modules.c

index d925077d9d72dfd9ae27c10cad2755af501131b9..b3bf84e4a0a49900d84fe02768247b8cc5e46013 100644 (file)
@@ -1,3 +1,10 @@
+2009-01-06  Roland McGrath  <roland@redhat.com>
+
+       * linux-kernel-modules.c (is_ko): New function.
+       Match ".ko", ".ko.gz", and ".ko.bz2" suffixes.
+       (dwfl_linux_kernel_report_offline): Use it.
+       (dwfl_linux_kernel_find_elf): Likewise.
+
 2009-01-05  Roland McGrath  <roland@redhat.com>
 
        * argp-std.c (parse_opt): Use __libdw_open_file for core file.
index 5bbb384adeb920b1e265e5541d33805472ad0bca..7da33d81fb88060c2f71660a75ea45609e974527 100644 (file)
@@ -1,5 +1,5 @@
 /* Standard libdwfl callbacks for debugging the running Linux kernel.
-   Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
+   Copyright (C) 2005-2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -254,6 +254,27 @@ report_kernel_archive (Dwfl *dwfl, const char **release,
   return result;
 }
 
+static bool
+is_ko (const FTSENT *f, size_t namelen)
+{
+#define has_suffix(f, sfx, namelen)                                          \
+  ((namelen ? f->fts_namelen == namelen + sizeof sfx - 1                     \
+    : f->fts_namelen >= sizeof sfx)                                          \
+   && !memcmp (f->fts_name + f->fts_namelen - (sizeof sfx - 1),                      \
+              sfx, sizeof sfx))
+
+  return (has_suffix (f, ".ko", namelen)
+#if USE_ZLIB
+         || has_suffix (f, ".ko.gz", namelen)
+#endif
+#if USE_BZLIB
+         || has_suffix (f, ".ko.bz2", namelen)
+#endif
+         );
+
+#undef has_suffix
+}
+
 /* Report a kernel and all its modules found on disk, for offline use.
    If RELEASE starts with '/', it names a directory to look in;
    if not, it names a directory to find under /lib/modules/;
@@ -302,8 +323,7 @@ dwfl_linux_kernel_report_offline (Dwfl *dwfl, const char *release,
            case FTS_SL:
            case FTS_NSOK:
              /* See if this file name matches "*.ko".  */
-             if (f->fts_namelen > 3
-                 && !memcmp (f->fts_name + f->fts_namelen - 3, ".ko", 4))
+             if (is_ko (f, 0))
                {
                  /* We have a .ko file to report.  Following the algorithm
                     by which the kernel makefiles set KBUILD_MODNAME, we
@@ -667,8 +687,7 @@ dwfl_linux_kernel_find_elf (Dwfl_Module *mod,
        case FTS_SL:
        case FTS_NSOK:
          /* See if this file name is "MODULE_NAME.ko".  */
-         if (f->fts_namelen == namelen + 3
-             && !memcmp (f->fts_name + namelen, ".ko", 4)
+         if (is_ko (f, namelen)
              && (!memcmp (f->fts_name, module_name, namelen)
                  || !memcmp (f->fts_name, alternate_name, namelen)))
            {