diff options
Diffstat (limited to 'modutils')
-rw-r--r-- | modutils/modprobe.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 3a2d893ee..01f8bb89b 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -280,18 +280,18 @@ static int FAST_FUNC include_conf_file_act(const char *filename, | |||
280 | struct dep_t **first = &conf->first; | 280 | struct dep_t **first = &conf->first; |
281 | struct dep_t **current = &conf->current; | 281 | struct dep_t **current = &conf->current; |
282 | int continuation_line = 0; | 282 | int continuation_line = 0; |
283 | int fd; | 283 | FILE *f; |
284 | 284 | ||
285 | if (bb_basename(filename)[0] == '.') | 285 | if (bb_basename(filename)[0] == '.') |
286 | return TRUE; | 286 | return TRUE; |
287 | 287 | ||
288 | fd = open(filename, O_RDONLY); | 288 | f = fopen_for_read(filename); |
289 | if (fd < 0) | 289 | if (f == NULL) |
290 | return FALSE; | 290 | return FALSE; |
291 | 291 | ||
292 | // alias parsing is not 100% correct (no correct handling of continuation lines within an alias)! | 292 | // alias parsing is not 100% correct (no correct handling of continuation lines within an alias)! |
293 | 293 | ||
294 | while (reads(fd, line_buffer, sizeof(line_buffer))) { | 294 | while (fgets(line_buffer, sizeof(line_buffer), f)) { |
295 | int l; | 295 | int l; |
296 | 296 | ||
297 | *strchrnul(line_buffer, '#') = '\0'; | 297 | *strchrnul(line_buffer, '#') = '\0'; |
@@ -376,9 +376,9 @@ static int FAST_FUNC include_conf_file_act(const char *filename, | |||
376 | if (dt) | 376 | if (dt) |
377 | dt->m_isblacklisted = 1; | 377 | dt->m_isblacklisted = 1; |
378 | } | 378 | } |
379 | } /* while (reads(...)) */ | 379 | } /* while (fgets(...)) */ |
380 | 380 | ||
381 | close(fd); | 381 | fclose(f); |
382 | return TRUE; | 382 | return TRUE; |
383 | } | 383 | } |
384 | 384 | ||
@@ -403,7 +403,7 @@ static int include_conf_file2(struct include_conf_t *conf, | |||
403 | */ | 403 | */ |
404 | static struct dep_t *build_dep(void) | 404 | static struct dep_t *build_dep(void) |
405 | { | 405 | { |
406 | int fd; | 406 | FILE *f; |
407 | struct utsname un; | 407 | struct utsname un; |
408 | struct include_conf_t conf = { NULL, NULL }; | 408 | struct include_conf_t conf = { NULL, NULL }; |
409 | char *filename; | 409 | char *filename; |
@@ -419,18 +419,18 @@ static struct dep_t *build_dep(void) | |||
419 | } | 419 | } |
420 | 420 | ||
421 | filename = xasprintf(CONFIG_DEFAULT_MODULES_DIR"/%s/"CONFIG_DEFAULT_DEPMOD_FILE, un.release); | 421 | filename = xasprintf(CONFIG_DEFAULT_MODULES_DIR"/%s/"CONFIG_DEFAULT_DEPMOD_FILE, un.release); |
422 | fd = open(filename, O_RDONLY); | 422 | f = fopen_for_read(filename); |
423 | if (ENABLE_FEATURE_CLEAN_UP) | 423 | if (ENABLE_FEATURE_CLEAN_UP) |
424 | free(filename); | 424 | free(filename); |
425 | if (fd < 0) { | 425 | if (f == NULL) { |
426 | /* Ok, that didn't work. Fall back to looking in /lib/modules */ | 426 | /* Ok, that didn't work. Fall back to looking in /lib/modules */ |
427 | fd = open(CONFIG_DEFAULT_MODULES_DIR"/"CONFIG_DEFAULT_DEPMOD_FILE, O_RDONLY); | 427 | f = fopen_for_read(CONFIG_DEFAULT_MODULES_DIR"/"CONFIG_DEFAULT_DEPMOD_FILE); |
428 | if (fd < 0) { | 428 | if (f == NULL) { |
429 | bb_error_msg_and_die("cannot parse " CONFIG_DEFAULT_DEPMOD_FILE); | 429 | bb_error_msg_and_die("cannot parse " CONFIG_DEFAULT_DEPMOD_FILE); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | while (reads(fd, line_buffer, sizeof(line_buffer))) { | 433 | while (fgets(line_buffer, sizeof(line_buffer), f)) { |
434 | int l = strlen(line_buffer); | 434 | int l = strlen(line_buffer); |
435 | char *p = 0; | 435 | char *p = 0; |
436 | 436 | ||
@@ -545,8 +545,8 @@ static struct dep_t *build_dep(void) | |||
545 | 545 | ||
546 | /* is there other dependable module(s) ? */ | 546 | /* is there other dependable module(s) ? */ |
547 | continuation_line = (line_buffer[l-1] == '\\'); | 547 | continuation_line = (line_buffer[l-1] == '\\'); |
548 | } /* while (reads(...)) */ | 548 | } /* while (fgets(...)) */ |
549 | close(fd); | 549 | fclose(f); |
550 | 550 | ||
551 | /* | 551 | /* |
552 | * First parse system-specific options and aliases | 552 | * First parse system-specific options and aliases |
@@ -594,13 +594,14 @@ static struct dep_t *build_dep(void) | |||
594 | /* return 1 = loaded, 0 = not loaded, -1 = can't tell */ | 594 | /* return 1 = loaded, 0 = not loaded, -1 = can't tell */ |
595 | static int already_loaded(const char *name) | 595 | static int already_loaded(const char *name) |
596 | { | 596 | { |
597 | int fd, ret = 0; | 597 | FILE *f; |
598 | int ret = 0; | ||
598 | 599 | ||
599 | fd = open("/proc/modules", O_RDONLY); | 600 | f = fopen_for_read("/proc/modules"); |
600 | if (fd < 0) | 601 | if (f == NULL) |
601 | return -1; | 602 | return -1; |
602 | 603 | ||
603 | while (reads(fd, line_buffer, sizeof(line_buffer))) { | 604 | while (fgets(line_buffer, sizeof(line_buffer), f)) { |
604 | char *p; | 605 | char *p; |
605 | 606 | ||
606 | p = strchr(line_buffer, ' '); | 607 | p = strchr(line_buffer, ' '); |
@@ -627,7 +628,7 @@ static int already_loaded(const char *name) | |||
627 | } | 628 | } |
628 | } | 629 | } |
629 | done: | 630 | done: |
630 | close(fd); | 631 | fclose(f); |
631 | return ret; | 632 | return ret; |
632 | } | 633 | } |
633 | 634 | ||