Changeset 4918

Show
Ignore:
Timestamp:
10/07/07 09:23:32 (1 year ago)
Author:
khali
Message:

Drop the configuration file search path mechanism from sensord. It's
confusing and useless. We dropped it from sensors years ago.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/args.c

    r4816 r4918  
    3131#include "version.h" 
    3232 
     33#define DEFAULT_CONFIG_FILE     ETCDIR "/sensors.conf" 
     34 
    3335#define MAX_CHIP_NAMES 32 
    3436 
    3537int isDaemon = 0; 
    36 const char *sensorsCfgFile = "sensors.conf"
     38const char *sensorsCfgFile = DEFAULT_CONFIG_FILE
    3739const char *pidFile = "/var/run/sensord.pid"; 
    3840const char *rrdFile = NULL; 
     
    103105  "  -T, --rrd-no-average      -- switch RRD in non-average mode\n" 
    104106  "  -r, --rrd-file <file>     -- RRD file (default <none>)\n" 
    105   "  -c, --config-file <file>  -- configuration file (default sensors.conf)\n" 
     107  "  -c, --config-file <file>  -- configuration file (default " DEFAULT_CONFIG_FILE ")\n" 
    106108  "  -p, --pid-file <file>     -- PID file (default /var/run/sensord.pid)\n" 
    107109  "  -f, --syslog-facility <f> -- syslog facility to use (default local4)\n" 
     
    115117  "for example, specify --log-interval 0 to only scan for alarms." 
    116118  "\n" 
    117   "If no path is specified, a list of directories is examined for the config file;\n" 
    118   "specify the filename `-' to read the config file from stdin.\n" 
     119  "Specify the filename `-' to read the config file from stdin.\n" 
    119120  "\n" 
    120121  "If no chips are specified, all chip info will be printed.\n" 
     
    129130  "  -s, --set                 -- execute set statements (root only)\n" 
    130131  "  -r, --rrd-file <file>     -- only update RRD file\n" 
    131   "  -c, --config-file <file>  -- configuration file (default sensors.conf)\n" 
     132  "  -c, --config-file <file>  -- configuration file (default " DEFAULT_CONFIG_FILE ")\n" 
    132133  "  -d, --debug               -- display some debug information\n" 
    133134  "  -v, --version             -- display version and exit\n" 
    134135  "  -h, --help                -- display help and exit\n" 
    135136  "\n" 
    136   "If no path is specified, a list of directories is examined for the config file;\n" 
    137   "specify the filename `-' to read the config file from stdin.\n" 
     137  "Specify the filename `-' to read the config file from stdin.\n" 
    138138  "\n" 
    139139  "If no chips are specified, all chip info will be printed.\n"; 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/lib.c

    r4853 r4918  
    3232#include "lib/error.h" 
    3333 
    34 static const char *sensorsCfgPaths[] = { 
    35   "/etc", "/usr/local/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib", "/usr/local/lib", NULL 
    36 }; 
    37  
    38 #define CFG_PATH_LEN 4096 
    39  
    40 static char cfgPath[CFG_PATH_LEN + 1]; 
    41  
    4234static time_t cfgLastModified; 
    43  
    44 int 
    45 initLib 
    46 (void) { 
    47   cfgPath[CFG_PATH_LEN] = '\0'; 
    48   if (!strcmp (sensorsCfgFile, "-")) { 
    49     strncpy (cfgPath, sensorsCfgFile, CFG_PATH_LEN); 
    50   } else if (sensorsCfgFile[0] == '/') { 
    51     strncpy (cfgPath, sensorsCfgFile, CFG_PATH_LEN); 
    52   } else if (strchr (sensorsCfgFile, '/')) { 
    53     char *cwd = getcwd (NULL, 0); 
    54     snprintf (cfgPath, CFG_PATH_LEN, "%s/%s", cwd, sensorsCfgFile); 
    55     free (cwd); 
    56   } else { 
    57     int index0; 
    58     struct stat stats; 
    59     for (index0 = 0; sensorsCfgPaths[index0]; ++ index0) { 
    60       snprintf (cfgPath, CFG_PATH_LEN, "%s/%s", sensorsCfgPaths[index0], sensorsCfgFile); 
    61       if (stat (cfgPath, &stats) == 0) 
    62         break; 
    63     } 
    64     if (!sensorsCfgPaths[index0]) { 
    65       sensorLog (LOG_ERR, "Error locating sensors configuration file: %s", sensorsCfgFile); 
    66       return 9; 
    67     } 
    68   } 
    69   return 0; 
    70 } 
    7135 
    7236static int 
    7337loadConfig 
    74 (int reload) { 
     38(const char *cfgPath, int reload) { 
    7539  struct stat stats; 
    7640  FILE *cfg = NULL; 
     
    11276int 
    11377loadLib 
    114 (void) { 
     78(const char *cfgPath) { 
    11579  int ret; 
    116   ret = loadConfig (0); 
     80  ret = loadConfig (cfgPath, 0); 
    11781  if (!ret) 
    11882    ret = initKnownChips (); 
     
    12286int 
    12387reloadLib 
    124 (void) { 
     88(const char *cfgPath) { 
    12589  int ret; 
    12690  freeKnownChips (); 
    127   ret = loadConfig (1); 
     91  ret = loadConfig (cfgPath, 1); 
    12892  if (!ret) 
    12993    ret = initKnownChips (); 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.8

    r4914 r4918  
    2222.\" the source, must acknowledge the copyright and authors of this work. 
    2323.\" 
    24 .TH sensord 8  "October 23, 2002" "lm-sensors 3" "Linux System Administration" 
     24.TH sensord 8  "October 2007" "lm-sensors 3" "Linux System Administration" 
    2525.SH NAME 
    2626sensord \- Sensor information logging daemon. 
     
    8585Specify a 
    8686.BR libsensors (3) 
    87 configuration file. If no file is specified, the name `sensors.conf' 
     87configuration file. If no file is specified, the default configuration file 
    8888is used. 
    8989 
    90 If the sensors configuration name does not contain a directory separator, 
    91 the following paths are searched for the file: 
    92 `/etc', `/usr/lib/sensors', `/usr/local/lib/sensors', `/usr/lib', `/usr/local/lib'. 
    9390.IP "-p, --pid-file file" 
    9491Specify what PID file to write; the default is to write the file 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.c

    r4888 r4918  
    8888  while (!done && (ret == 0)) { 
    8989    if (ret == 0) 
    90       ret = reloadLib (); 
     90      ret = reloadLib (sensorsCfgFile); 
    9191    if ((ret == 0) && scanTime) { /* should I scan on the read cycle? */ 
    9292      ret = scanChips (); 
     
    199199    exit (EXIT_FAILURE); 
    200200   
    201   if (initLib () || 
    202       loadLib ()) 
     201  if (loadLib (sensorsCfgFile)) 
    203202    exit (EXIT_FAILURE); 
    204203 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.h

    r4834 r4918  
    5050/* from lib.c */ 
    5151 
    52 extern int initLib (void); 
    53 extern int loadLib (void); 
    54 extern int reloadLib (void); 
     52extern int loadLib (const char *cfgPath); 
     53extern int reloadLib (const char *cfgPath); 
    5554extern int unloadLib (void); 
    5655