From 8ac364315c153e546fbae9dd63c562b9a1e42d82 Mon Sep 17 00:00:00 2001 From: Babak Sarashki Date: Sun, 24 Jan 2021 13:46:20 -0500 Subject: [PATCH] Reject device configuration if not enabled Signed-off-by: Babak Sarashki --- config_app.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config_app.c b/config_app.c index fdad259..f1aa52b 100644 --- a/config_app.c +++ b/config_app.c @@ -114,6 +114,7 @@ static bool get_device_id(hw_device *device, const char *location) { unsigned long vendor_id = -1, device_id = -1; + unsigned int device_enabled = 0; struct dirent *dirent; DIR *dir; char pci_path[PATH_MAX]; @@ -139,6 +140,12 @@ get_device_id(hw_device *device, const char *location) snprintf(file_path, sizeof(file_path), "%s/%s", pci_path, dirent->d_name); + /* Is device enabled? */ + if (strncmp(dirent->d_name, "enable", + strlen(dirent->d_name)) == 0 && + dirent->d_type == DT_REG) + device_enabled = get_file_val(file_path); + /* Get Device ID */ if (strncmp(dirent->d_name, DEVICE_FILE, strlen(dirent->d_name)) == 0 && @@ -154,7 +161,8 @@ get_device_id(hw_device *device, const char *location) closedir(dir); /* Check if device is found */ - return (vendor_id == device->vendor_id && + return (device_enabled && + vendor_id == device->vendor_id && device_id == device->device_id); } -- 2.29.2