#include "stdio.h"
#include "string.h"
main() {
int n = 0;
int size = 0;
char *comment;
char module[1024];
char blacklist[200][1024];
FILE *stream;
if((stream = fopen ("/etc/hotplug/blacklist", "r")) != (FILE *)0) {
while((fgets(module, 1023, stream)) != (char *)0 ) {
comment = strchr(module, '#');
if (comment != 0) *comment = '\0';
comment = strchr(module, '\n');
if (comment != 0) *comment = '\0';
size = strlen(module);
if (size < 2) continue;
strcat (module , " \0");
strcpy(blacklist[n] , module);
n++;
fprintf(stderr, module);
}
}
else {
fprintf(stderr, "file does not exist");
}
return 0;
}
now that ad-hoc implementation got transformed into this patch.. yet to be tested.
Ok I fixed the segfault.. AFAIK this should be usable. Thanks Uniball for helping, but I didn't use your code. I think this is simpler.
diff -Naur hwsetup-1.0/hwsetup.c hwsetup-1.0-patched/hwsetup.c
--- hwsetup-1.0/hwsetup.c 2003-06-02 22:01:28.000000000 +0300
+++ hwsetup-1.0-patched/hwsetup.c 2005-05-28 15:41:36.000000000 +0300
@@ -42,8 +42,35 @@
/* Do not, under any circumstances, load these modules automatically, */
/* even if in pcitable. (libkudzu may ignore this, and the KNOPPIX */
/* autoconfig scripts may probe them, too) */
-const char *blacklist[] = { "apm","agpgart","yenta_socket","i82092","i82365","tcic",
+char blacklist[200][1024] = { "apm","agpgart","yenta_socket","i82092","i82365","tcic",
"pcmcia_core","ds","ohci1394" };
+int blacklistsize = 9;
+
+void gen_blacklist(){
+ int n = 9;
+ int size = 0;
+ char *comment;
+ char module[1024];
+ FILE *stream;
+
+ if((stream = fopen ("/etc/hotplug/blacklist", "r")) != (FILE *)0) {
+ while((fgets(module, 1023, stream)) != (char *)0 ) {
+
+ comment = strchr(module, '#');
+ if (comment != 0) *comment = '\0';
+ comment = strchr(module, '\n');
+ if (comment != 0) *comment = '\0';
+ size = strlen(module);
+ if (size < 2) continue;
+ strcat (module , " \0");
+ strcpy(blacklist[n] , module);
+ n++;
+ //printf(module);
+ }
+ blacklistsize = n;
+ }
+}
+
#endif
/* These need to be global, so we can kill them in case of problems */
@@ -349,7 +376,7 @@
pid_t mpid;
if((m==NULL)||(!strcmp("unknown",m))||(!strcmp("ignore",m))) return 0;
#ifdef BLACKLIST
- for(i=0;i<(sizeof(blacklist)/sizeof(char*));i++)
+ for(i=0;i