aboutsummaryrefslogtreecommitdiff
path: root/modutils/modprobe-small.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-24 23:38:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-24 23:38:04 +0000
commit0f99d49ae680e675809428deace3c4fe839d323c (patch)
tree712afab828ee4fb02493bc60e1a37f1142231263 /modutils/modprobe-small.c
parent22f741484391c3b2fd94881fd41c8c0df9749e95 (diff)
downloadbusybox-0f99d49ae680e675809428deace3c4fe839d323c.tar.gz
*: conversion to config parser
function old new delta config_read 540 597 +57 config_open2 41 44 +3 rtnl_rtprot_initialize 70 66 -4 rtnl_rttable_initialize 78 73 -5 rtnl_rtscope_initialize 88 83 -5 rtnl_rtrealm_initialize 48 43 -5 rtnl_rtdsfield_initialize 48 43 -5 process_module 566 560 -6 bbunpack 391 383 -8 rtnl_tab_initialize 279 121 -158 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/8 up/down: 60/-196) Total: -136 bytes
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)
}
#if ENABLE_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED
+// TODO: open only once, invent config_rewind()
static int already_loaded(const char *name)
{
int ret = 0;
- int len = strlen(name);
- char *line;
- FILE* modules;
-
- modules = xfopen_for_read("/proc/modules");
- while ((line = xmalloc_fgets(modules)) != NULL) {
- if (strncmp(line, name, len) == 0 && line[len] == ' ') {
- free(line);
+ char *s;
+ parser_t *parser = config_open2("/proc/modules", xfopen_for_read);
+ while (config_read(parser, &s, 1, 1, "# \t", 0)) {
+ if (strcmp(s, name) == 0) {
ret = 1;
break;
}
- free(line);
}
- fclose(modules);
+ config_close(parser);
return ret;
}
#else