aboutsummaryrefslogtreecommitdiff
path: root/lib/libpmcstat
diff options
context:
space:
mode:
authorRyan Moeller <freqlabs@FreeBSD.org>2020-03-12 23:04:40 +0000
committerRyan Moeller <freqlabs@FreeBSD.org>2020-03-12 23:04:40 +0000
commit797711a84f0b6c3466afaaf32ae387cb70d95c14 (patch)
treea2e49ed9f313a8266e333c7c0cde226109b341c8 /lib/libpmcstat
parent7a119578a40a3f958f996b24c8acd25e5f6cd140 (diff)
downloadsrc-797711a84f0b6c3466afaaf32ae387cb70d95c14.tar.gz
src-797711a84f0b6c3466afaaf32ae387cb70d95c14.zip
libpmcstat: Try /boot/modules if module not found
Modules from ports/pkg are commonly installed to /boot/modules rather than to the same directory the kernel resides in. Look there if a module is not found next to the kernel. Submitted by: mmacy Reported by: Nick Principe <nap@iXsystems.com> Approved by: mmacy (mentor) MFC after: 2 weeks Sponsored by: iXsystems, Inc.
Notes
Notes: svn path=/head/; revision=358923
Diffstat (limited to 'lib/libpmcstat')
-rw-r--r--lib/libpmcstat/libpmcstat_image.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/libpmcstat/libpmcstat_image.c b/lib/libpmcstat/libpmcstat_image.c
index 068200462187..94d103228d28 100644
--- a/lib/libpmcstat/libpmcstat_image.c
+++ b/lib/libpmcstat/libpmcstat_image.c
@@ -278,6 +278,7 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image,
GElf_Shdr sh;
enum pmcstat_image_type image_type;
char buffer[PATH_MAX];
+ char buffer_modules[PATH_MAX];
assert(image->pi_type == PMCSTAT_IMAGE_UNKNOWN);
@@ -292,23 +293,32 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image,
assert(path != NULL);
/*
- * Look for kernel modules under FSROOT/KERNELPATH/NAME,
- * and user mode executable objects under FSROOT/PATHNAME.
+ * Look for kernel modules under FSROOT/KERNELPATH/NAME and
+ * FSROOT/boot/modules/NAME, and user mode executable objects
+ * under FSROOT/PATHNAME.
*/
- if (image->pi_iskernelmodule)
+ if (image->pi_iskernelmodule) {
(void) snprintf(buffer, sizeof(buffer), "%s%s/%s",
args->pa_fsroot, args->pa_kernel, path);
- else
+ (void) snprintf(buffer_modules, sizeof(buffer_modules),
+ "%s/boot/modules/%s", args->pa_fsroot, path);
+ } else {
(void) snprintf(buffer, sizeof(buffer), "%s%s",
args->pa_fsroot, path);
+ }
e = NULL;
- if ((fd = open(buffer, O_RDONLY, 0)) < 0) {
+ fd = open(buffer, O_RDONLY, 0);
+ if (fd < 0 && !image->pi_iskernelmodule) {
warnx("WARNING: Cannot open \"%s\".",
buffer);
goto done;
}
-
+ if (fd < 0 && (fd = open(buffer_modules, O_RDONLY, 0)) < 0) {
+ warnx("WARNING: Cannot open \"%s\" or \"%s\".",
+ buffer, buffer_modules);
+ goto done;
+ }
if (elf_version(EV_CURRENT) == EV_NONE) {
warnx("WARNING: failed to init elf\n");
goto done;