diff options
author | Rob Landley <rob@landley.net> | 2005-06-07 03:47:00 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-06-07 03:47:00 +0000 |
commit | 06813d066b379ce74801a6c125213a03104fc4e1 (patch) | |
tree | f5cb60ba6610e76630b09aede67bea3188d12c91 | |
parent | 16cd02e01ed66758935250d8d7c0bee90608807c (diff) | |
download | busybox-w32-06813d066b379ce74801a6c125213a03104fc4e1.tar.gz busybox-w32-06813d066b379ce74801a6c125213a03104fc4e1.tar.bz2 busybox-w32-06813d066b379ce74801a6c125213a03104fc4e1.zip |
Tito posted a devfsd error message fix. It's highly deprecated and will
presumably be removed eventually (use udev), but as long as it's in there.
Tito says:
The sense of this patch is to call:
read_config_file_err:
#ifdef CONFIG_DEVFSD_VERBOSE
msg_logger(((optional == 0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path);
#else
if(optional == 0 && errno == ENOENT)
exit(EXIT_FAILURE);
#endif
just after the failure of the call that set errno ( stat and fopen)
to avoid false error messages.
-rw-r--r-- | miscutils/devfsd.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 5e183e61f..34945c7b2 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -566,40 +566,36 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas | |||
566 | #ifdef CONFIG_DEBUG | 566 | #ifdef CONFIG_DEBUG |
567 | msg_logger( NO_DIE, LOG_INFO, "read_config_file(): %s\n", path); | 567 | msg_logger( NO_DIE, LOG_INFO, "read_config_file(): %s\n", path); |
568 | #endif | 568 | #endif |
569 | if (stat (path, &statbuf) != 0 || statbuf.st_size == 0 ) | 569 | if (stat (path, &statbuf) == 0 ) |
570 | goto read_config_file_err; | ||
571 | |||
572 | if ( S_ISDIR (statbuf.st_mode) ) | ||
573 | { | ||
574 | /* strip last / from dirname so we don't need to check for it later */ | ||
575 | while( path && path[1]!='\0' && path[strlen(path)-1] == '/') | ||
576 | path[strlen(path) -1] = '\0'; | ||
577 | |||
578 | dir_operation(READ_CONFIG, path, 0, event_mask); | ||
579 | return; | ||
580 | } | ||
581 | |||
582 | if ( ( fp = fopen (path, "r") ) != NULL ) | ||
583 | { | 570 | { |
584 | while (fgets (buf, STRING_LENGTH, fp) != NULL) | 571 | /* Don't read 0 length files: ignored */ |
572 | /*if( statbuf.st_size == 0 ) | ||
573 | return;*/ | ||
574 | if ( S_ISDIR (statbuf.st_mode) ) | ||
585 | { | 575 | { |
586 | /* GETS(3) Linux Programmer's Manual | 576 | /* strip last / from dirname so we don't need to check for it later */ |
587 | fgets() reads in at most one less than size characters from stream and | 577 | while( path && path[1]!='\0' && path[strlen(path)-1] == '/') |
588 | stores them into the buffer pointed to by s. Reading stops after an | 578 | path[strlen(path) -1] = '\0'; |
589 | EOF or a newline. If a newline is read, it is stored into the buffer. | 579 | |
590 | A '\0' is stored after the last character in the buffer. | 580 | dir_operation(READ_CONFIG, path, 0, event_mask); |
591 | */ | 581 | return; |
592 | /*buf[strlen (buf) - 1] = '\0';*/ | ||
593 | /* Skip whitespace */ | ||
594 | for (line = buf; isspace (*line); ++line) | ||
595 | /*VOID*/; | ||
596 | if (line[0] == '\0' || line[0] == '#' ) | ||
597 | continue; | ||
598 | process_config_line (line, event_mask); | ||
599 | } | 582 | } |
600 | fclose (fp); | 583 | if ( ( fp = fopen (path, "r") ) != NULL ) |
601 | errno=0; | 584 | { |
602 | } | 585 | while (fgets (buf, STRING_LENGTH, fp) != NULL) |
586 | { | ||
587 | /* Skip whitespace */ | ||
588 | for (line = buf; isspace (*line); ++line) | ||
589 | /*VOID*/; | ||
590 | if (line[0] == '\0' || line[0] == '#' ) | ||
591 | continue; | ||
592 | process_config_line (line, event_mask); | ||
593 | } | ||
594 | fclose (fp); | ||
595 | } else { | ||
596 | goto read_config_file_err; | ||
597 | } | ||
598 | } else { | ||
603 | read_config_file_err: | 599 | read_config_file_err: |
604 | #ifdef CONFIG_DEVFSD_VERBOSE | 600 | #ifdef CONFIG_DEVFSD_VERBOSE |
605 | msg_logger(((optional == 0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path); | 601 | msg_logger(((optional == 0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path); |
@@ -607,6 +603,7 @@ read_config_file_err: | |||
607 | if(optional == 0 && errno == ENOENT) | 603 | if(optional == 0 && errno == ENOENT) |
608 | exit(EXIT_FAILURE); | 604 | exit(EXIT_FAILURE); |
609 | #endif | 605 | #endif |
606 | } | ||
610 | return; | 607 | return; |
611 | } /* End Function read_config_file */ | 608 | } /* End Function read_config_file */ |
612 | 609 | ||