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.
This commit is contained in:
parent
7a119578a4
commit
797711a84f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358923
@ -278,6 +278,7 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image,
|
|||||||
GElf_Shdr sh;
|
GElf_Shdr sh;
|
||||||
enum pmcstat_image_type image_type;
|
enum pmcstat_image_type image_type;
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
|
char buffer_modules[PATH_MAX];
|
||||||
|
|
||||||
assert(image->pi_type == PMCSTAT_IMAGE_UNKNOWN);
|
assert(image->pi_type == PMCSTAT_IMAGE_UNKNOWN);
|
||||||
|
|
||||||
@ -292,23 +293,32 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image,
|
|||||||
assert(path != NULL);
|
assert(path != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for kernel modules under FSROOT/KERNELPATH/NAME,
|
* Look for kernel modules under FSROOT/KERNELPATH/NAME and
|
||||||
* and user mode executable objects under FSROOT/PATHNAME.
|
* 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",
|
(void) snprintf(buffer, sizeof(buffer), "%s%s/%s",
|
||||||
args->pa_fsroot, args->pa_kernel, path);
|
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",
|
(void) snprintf(buffer, sizeof(buffer), "%s%s",
|
||||||
args->pa_fsroot, path);
|
args->pa_fsroot, path);
|
||||||
|
}
|
||||||
|
|
||||||
e = NULL;
|
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\".",
|
warnx("WARNING: Cannot open \"%s\".",
|
||||||
buffer);
|
buffer);
|
||||||
goto done;
|
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) {
|
if (elf_version(EV_CURRENT) == EV_NONE) {
|
||||||
warnx("WARNING: failed to init elf\n");
|
warnx("WARNING: failed to init elf\n");
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -309,6 +309,8 @@ should look for the kernel and its modules.
|
|||||||
The default is to use the path of the running kernel obtained from the
|
The default is to use the path of the running kernel obtained from the
|
||||||
.Va kern.bootfile
|
.Va kern.bootfile
|
||||||
sysctl.
|
sysctl.
|
||||||
|
Modules will also be searched for in /boot/modules if not found in
|
||||||
|
.Ar kerneldir .
|
||||||
.It Fl l Ar secs
|
.It Fl l Ar secs
|
||||||
Set system-wide performance measurement duration for
|
Set system-wide performance measurement duration for
|
||||||
.Ar secs
|
.Ar secs
|
||||||
|
Loading…
Reference in New Issue
Block a user