summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-04-27 14:43:46 (GMT)
committerErwan Velu <erwan.velu@free.fr>2009-04-27 14:43:46 (GMT)
commitdb265a9a03849966ec9183f675d539fc3b0d6ecd (patch)
treea739674690850133c3fbf3fe2b210faae812308e
parenta335437d0d97ad87db72a26fa4d4392853cd65d2 (diff)
downloadhdt-db265a9a03849966ec9183f675d539fc3b0d6ecd.zip
hdt-db265a9a03849966ec9183f675d539fc3b0d6ecd.tar.gz
hdt-db265a9a03849966ec9183f675d539fc3b0d6ecd.tar.bz2
hdt-db265a9a03849966ec9183f675d539fc3b0d6ecd.tar.xz
hdt: Adding modules.alias support
Impact: It is now possible to use modules.alias to search kernel modules. This commit rename modules= command line parameter to modules_pcimap= It introduce modules_alias= parameter to override the default "modules.alias" filename. Both methods (pcimap & alias) are tried when detecting hardware. A failure message will occurs only if both methods fails.
-rw-r--r--com32/hdt/hdt-cli-kernel.c5
-rw-r--r--com32/hdt/hdt-cli-pci.c27
-rw-r--r--com32/hdt/hdt-common.c20
-rw-r--r--com32/hdt/hdt-common.h2
-rw-r--r--com32/hdt/hdt-menu-kernel.c13
-rw-r--r--com32/hdt/hdt-menu.c3
6 files changed, 51 insertions, 19 deletions
diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c
index d9ba27f..41c80be 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -50,8 +50,9 @@ void main_show_kernel(int argc __unused, char **argv __unused,
// more_printf(" PCI device no: %d \n", p->pci_device_pos);
- if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
- more_printf(" modules.pcimap is missing\n");
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP)
+ && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ more_printf(" modules.pcimap and modules.alias files are missing\n");
return;
}
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index 39bc0fb..d130b7b 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -50,6 +50,8 @@ static void show_pci_device(int argc, char **argv,
int pcidev = -1;
bool nopciids = false;
bool nomodulespcimap = false;
+ bool nomodulesalias = false;
+ bool nomodulesfiles = false;
char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
MAX_KERNEL_MODULES_PER_PCI_DEVICE];
int bus = 0, slot = 0, func = 0;
@@ -75,7 +77,10 @@ static void show_pci_device(int argc, char **argv,
if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
nomodulespcimap = true;
}
-
+ if (hardware->modules_alias_return_code == -ENOMODULESALIAS) {
+ nomodulesalias = true;
+ }
+ nomodulesfiles=nomodulespcimap && nomodulesalias;
for_each_pci_func(temp_pci_device, hardware->pci_domain) {
i++;
if (i == pcidev) {
@@ -115,7 +120,7 @@ static void show_pci_device(int argc, char **argv,
pci_device->dev_info->class_name);
}
- if (nomodulespcimap == false) {
+ if (nomodulesfiles == false) {
printf("Kernel module : %s\n", kernel_modules);
}
@@ -152,6 +157,8 @@ static void show_pci_devices(int argc __unused, char **argv __unused,
MAX_KERNEL_MODULES_PER_PCI_DEVICE];
bool nopciids = false;
bool nomodulespcimap = false;
+ bool nomodulesalias = false;
+ bool nomodulesfile = false;
char first_line[81];
char second_line[81];
@@ -164,6 +171,11 @@ static void show_pci_devices(int argc __unused, char **argv __unused,
if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
nomodulespcimap = true;
}
+ if (hardware->modules_pcimap_return_code == -ENOMODULESALIAS) {
+ nomodulesalias = true;
+ }
+
+ nomodulesfile = nomodulespcimap && nomodulesalias;
/* For every detected pci device, compute its submenu */
for_each_pci_func(pci_device, hardware->pci_domain) {
@@ -186,7 +198,7 @@ static void show_pci_devices(int argc __unused, char **argv __unused,
"%02d: %s %s \n", i,
pci_device->dev_info->vendor_name,
pci_device->dev_info->product_name);
- if (nomodulespcimap == false)
+ if (nomodulesfile == false)
snprintf(second_line, sizeof(second_line),
" # %-25s # Kmod: %s\n",
pci_device->dev_info->class_name,
@@ -204,7 +216,7 @@ static void show_pci_devices(int argc __unused, char **argv __unused,
more_printf(second_line);
more_printf("\n");
} else if (nopciids == true) {
- if (nomodulespcimap == true) {
+ if (nomodulesfile == true) {
more_printf("%02d: %04x:%04x [%04x:%04x] \n",
i, pci_device->vendor,
pci_device->product,
@@ -299,10 +311,11 @@ void cli_detect_pci(struct s_hardware *hardware)
printf("Please put one in same dir as hdt\n");
error = true;
}
- if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
+ (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
printf
- ("The modules.pcimap file is missing, device names can't be computed.\n");
- printf("Please put one in same dir as hdt\n");
+ ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n");
+ printf("Please put one of them in same dir as hdt\n");
error = true;
}
if (error == true) {
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 0331bd1..987c5ae 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -56,14 +56,18 @@ void detect_parameters(const int argc, const char *argv[],
struct s_hardware *hardware)
{
for (int i = 1; i < argc; i++) {
- if (!strncmp(argv[i], "modules=", 8)) {
- strncpy(hardware->modules_pcimap_path, argv[i] + 8,
+ if (!strncmp(argv[i], "modules_pcimap=", 15)) {
+ strncpy(hardware->modules_pcimap_path, argv[i] + 15,
sizeof(hardware->modules_pcimap_path));
convert_isolinux_filename(hardware->modules_pcimap_path,hardware);
} else if (!strncmp(argv[i], "pciids=", 7)) {
strncpy(hardware->pciids_path, argv[i] + 7,
sizeof(hardware->pciids_path));
convert_isolinux_filename(hardware->pciids_path,hardware);
+ } else if (!strncmp(argv[i], "modules_alias=", 14)) {
+ strncpy(hardware->modules_alias_path, argv[i] + 14,
+ sizeof(hardware->modules_alias_path));
+ convert_isolinux_filename(hardware->modules_alias_path,hardware);
} else if (!strncmp(argv[i], "memtest=", 8)) {
strncpy(hardware->memtest_label, argv[i] + 8,
sizeof(hardware->memtest_label));
@@ -100,6 +104,7 @@ void init_hardware(struct s_hardware *hardware)
{
hardware->pci_ids_return_code = 0;
hardware->modules_pcimap_return_code = 0;
+ hardware->modules_alias_return_code = 0;
hardware->cpu_detection = false;
hardware->pci_detection = false;
hardware->disk_detection = false;
@@ -125,9 +130,12 @@ void init_hardware(struct s_hardware *hardware)
memset(hardware->pciids_path, 0, sizeof hardware->pciids_path);
memset(hardware->modules_pcimap_path, 0,
sizeof hardware->modules_pcimap_path);
+ memset(hardware->modules_alias_path, 0,
+ sizeof hardware->modules_alias_path);
memset(hardware->memtest_label, 0, sizeof hardware->memtest_label);
strcat(hardware->pciids_path, "pci.ids");
strcat(hardware->modules_pcimap_path, "modules.pcimap");
+ strcat(hardware->modules_alias_path, "modules.alias");
strcat(hardware->memtest_label, "memtest");
}
@@ -451,11 +459,17 @@ void detect_pci(struct s_hardware *hardware)
hardware->pciids_path);
printf("PCI: Resolving module names\n");
- /* Detecting which kernel module should match each device */
+ /* Detecting which kernel module should match each device using modules.pcimap*/
hardware->modules_pcimap_return_code =
get_module_name_from_pcimap(hardware->pci_domain,
hardware->modules_pcimap_path);
+ /* Detecting which kernel module should match each device using modules.alias*/
+ hardware->modules_alias_return_code =
+ get_module_name_from_alias(hardware->pci_domain,
+ hardware->modules_alias_path);
+
+
/* We try to detect the pxe stuff to populate the PXE: field of pci devices */
detect_pxe(hardware);
}
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 9fd8a56..5118dd6 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -117,6 +117,7 @@ struct s_hardware {
int pci_ids_return_code;
int modules_pcimap_return_code;
+ int modules_alias_return_code;
int nb_pci_devices;
bool is_dmi_valid;
bool is_pxe_valid;
@@ -134,6 +135,7 @@ struct s_hardware {
char syslinux_fs[22];
const struct syslinux_version *sv;
char modules_pcimap_path[255];
+ char modules_alias_path[255];
char pciids_path[255];
char memtest_label[255];
};
diff --git a/com32/hdt/hdt-menu-kernel.c b/com32/hdt/hdt-menu-kernel.c
index b94d1fe..7e2d6ca 100644
--- a/com32/hdt/hdt-menu-kernel.c
+++ b/com32/hdt/hdt-menu-kernel.c
@@ -41,13 +41,14 @@ void compute_kernel(struct s_my_menu *menu, struct s_hardware *hardware)
menu->items_count = 0;
set_menu_pos(SUBMENU_Y, SUBMENU_X);
- if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) {
- add_item("The modules.pcimap file is missing",
- "Missing modules.pcimap file", OPT_INACTIVE, NULL, 0);
+ if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) &&
+ (hardware->modules_alias_return_code == -ENOMODULESALIAS)) {
+ add_item("The modules.{pcimap|alias} file is missing",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
add_item("Kernel modules can't be computed.",
- "Missing modules.pcimap file", OPT_INACTIVE, NULL, 0);
- add_item("Please put one in same dir as hdt",
- "Missing modules.pcimap file", OPT_INACTIVE, NULL, 0);
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
+ add_item("Please put one of them in same dir as hdt",
+ "Missing modules.{pcimap|alias} file", OPT_INACTIVE, NULL, 0);
add_item("", "", OPT_SEP, "", 0);
} else {
/*
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index a699f72..2f4f120 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -263,7 +263,8 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
add_item("", "", OPT_SEP, "", 0);
#ifdef WITH_PCI
- if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
+ if ((hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) ||
+ (hardware->modules_alias_return_code != -ENOMODULESALIAS)) {
add_item("<K>ernel Modules", "Kernel Modules Menu", OPT_SUBMENU,
NULL, hdt_menu->kernel_menu.menu);
hdt_menu->main_menu.items_count++;