Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(userspace/libscap): use proper module name in sysfs paths #1674

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ if(NOT WIN32)
set(PROBE_NAME "sysdig-probe")
endif()

string(REGEX REPLACE "[,-]" "_" SYSFS_NAME ${PROBE_NAME})

if(NOT DEFINED PROBE_DEVICE_NAME)
set(PROBE_DEVICE_NAME "sysdig")
endif()
Expand Down
2 changes: 2 additions & 0 deletions driver/driver_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ or GPL2.txt for full copies of the license.
#define PROBE_NAME "${PROBE_NAME}"

#define PROBE_DEVICE_NAME "${PROBE_DEVICE_NAME}"

#define SYSFS_NAME "${SYSFS_NAME}"
4 changes: 2 additions & 2 deletions userspace/libscap/scap.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ scap_t* scap_open_live_int(char *error, int32_t *rc,
static uint32_t get_max_consumers()
{
uint32_t max;
FILE *pfile = fopen("/sys/module/" PROBE_DEVICE_NAME "_probe/parameters/max_consumers", "r");
FILE *pfile = fopen("/sys/module/" SYSFS_NAME "/parameters/max_consumers", "r");
if(pfile != NULL)
{
int w = fscanf(pfile, "%"PRIu32, &max);
Expand Down Expand Up @@ -328,7 +328,7 @@ scap_t* scap_open_live_int(char *error, int32_t *rc,
else if(errno == EBUSY)
{
uint32_t curr_max_consumers = get_max_consumers();
snprintf(error, SCAP_LASTERR_SIZE, "Too many sysdig instances attached to device %s. Current value for /sys/module/" PROBE_DEVICE_NAME "_probe/parameters/max_consumers is '%"PRIu32"'.", filename, curr_max_consumers);
snprintf(error, SCAP_LASTERR_SIZE, "Too many sysdig instances attached to device %s. Current value for /sys/module/" SYSFS_NAME "/parameters/max_consumers is '%"PRIu32"'.", filename, curr_max_consumers);
}
else
{
Expand Down