summaryrefslogtreecommitdiff
path: root/libdwfl/linux-kernel-modules.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2009-01-06 00:10:23 -0800
committerRoland McGrath <roland@redhat.com>2009-01-06 00:10:23 -0800
commit60205c962289f2e3a1545f18711f2ae4ea53ab96 (patch)
tree2e1e766ea1aba2be4d5396f7740422fba68b4821 /libdwfl/linux-kernel-modules.c
parentbca43152aa0bcb31b9442c407bf2b86379761c50 (diff)
downloadelfutils-60205c962289f2e3a1545f18711f2ae4ea53ab96.tar.gz
libdwfl -k/-K match compressed .ko files
Diffstat (limited to 'libdwfl/linux-kernel-modules.c')
-rw-r--r--libdwfl/linux-kernel-modules.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index 5bbb384a..7da33d81 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -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)))
{