aboutsummaryrefslogtreecommitdiff
path: root/miscutils/devfsd.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-06-07 03:47:00 +0000
committerRob Landley <rob@landley.net>2005-06-07 03:47:00 +0000
commit06813d066b379ce74801a6c125213a03104fc4e1 (patch)
treef5cb60ba6610e76630b09aede67bea3188d12c91 /miscutils/devfsd.c
parent16cd02e01ed66758935250d8d7c0bee90608807c (diff)
downloadbusybox-06813d066b379ce74801a6c125213a03104fc4e1.tar.gz
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.
Diffstat (limited to 'miscutils/devfsd.c')
-rw-r--r--miscutils/devfsd.c59
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
#ifdef CONFIG_DEBUG
msg_logger( NO_DIE, LOG_INFO, "read_config_file(): %s\n", path);
#endif
- if (stat (path, &statbuf) != 0 || statbuf.st_size == 0 )
- goto read_config_file_err;
-
- if ( S_ISDIR (statbuf.st_mode) )
- {
- /* strip last / from dirname so we don't need to check for it later */
- while( path && path[1]!='\0' && path[strlen(path)-1] == '/')
- path[strlen(path) -1] = '\0';
-
- dir_operation(READ_CONFIG, path, 0, event_mask);
- return;
- }
-
- if ( ( fp = fopen (path, "r") ) != NULL )
+ if (stat (path, &statbuf) == 0 )
{
- while (fgets (buf, STRING_LENGTH, fp) != NULL)
+ /* Don't read 0 length files: ignored */
+ /*if( statbuf.st_size == 0 )
+ return;*/
+ if ( S_ISDIR (statbuf.st_mode) )
{
- /* GETS(3) Linux Programmer's Manual
- fgets() reads in at most one less than size characters from stream and
- stores them into the buffer pointed to by s. Reading stops after an
- EOF or a newline. If a newline is read, it is stored into the buffer.
- A '\0' is stored after the last character in the buffer.
- */
- /*buf[strlen (buf) - 1] = '\0';*/
- /* Skip whitespace */
- for (line = buf; isspace (*line); ++line)
- /*VOID*/;
- if (line[0] == '\0' || line[0] == '#' )
- continue;
- process_config_line (line, event_mask);
+ /* strip last / from dirname so we don't need to check for it later */
+ while( path && path[1]!='\0' && path[strlen(path)-1] == '/')
+ path[strlen(path) -1] = '\0';
+
+ dir_operation(READ_CONFIG, path, 0, event_mask);
+ return;
}
- fclose (fp);
- errno=0;
- }
+ if ( ( fp = fopen (path, "r") ) != NULL )
+ {
+ while (fgets (buf, STRING_LENGTH, fp) != NULL)
+ {
+ /* Skip whitespace */
+ for (line = buf; isspace (*line); ++line)
+ /*VOID*/;
+ if (line[0] == '\0' || line[0] == '#' )
+ continue;
+ process_config_line (line, event_mask);
+ }
+ fclose (fp);
+ } else {
+ goto read_config_file_err;
+ }
+ } else {
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);
@@ -607,6 +603,7 @@ read_config_file_err:
if(optional == 0 && errno == ENOENT)
exit(EXIT_FAILURE);
#endif
+ }
return;
} /* End Function read_config_file */