aboutsummaryrefslogtreecommitdiff
path: root/modutils/modprobe-small.c
diff options
context:
space:
mode:
Diffstat (limited to 'modutils/modprobe-small.c')
-rw-r--r--modutils/modprobe-small.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index f75dae8a3..1654cc52d 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -485,23 +485,19 @@ static module_info* find_alias(const char *alias)
485} 485}
486 486
487#if ENABLE_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED 487#if ENABLE_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED
488// TODO: open only once, invent config_rewind()
488static int already_loaded(const char *name) 489static int already_loaded(const char *name)
489{ 490{
490 int ret = 0; 491 int ret = 0;
491 int len = strlen(name); 492 char *s;
492 char *line; 493 parser_t *parser = config_open2("/proc/modules", xfopen_for_read);
493 FILE* modules; 494 while (config_read(parser, &s, 1, 1, "# \t", 0)) {
494 495 if (strcmp(s, name) == 0) {
495 modules = xfopen_for_read("/proc/modules");
496 while ((line = xmalloc_fgets(modules)) != NULL) {
497 if (strncmp(line, name, len) == 0 && line[len] == ' ') {
498 free(line);
499 ret = 1; 496 ret = 1;
500 break; 497 break;
501 } 498 }
502 free(line);
503 } 499 }
504 fclose(modules); 500 config_close(parser);
505 return ret; 501 return ret;
506} 502}
507#else 503#else