Changeset 4918
- Timestamp:
- 10/07/07 09:23:32 (1 year ago)
- Files:
-
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/args.c (modified) (4 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/lib.c (modified) (3 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.8 (modified) (2 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.c (modified) (2 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/args.c
r4816 r4918 31 31 #include "version.h" 32 32 33 #define DEFAULT_CONFIG_FILE ETCDIR "/sensors.conf" 34 33 35 #define MAX_CHIP_NAMES 32 34 36 35 37 int isDaemon = 0; 36 const char *sensorsCfgFile = "sensors.conf";38 const char *sensorsCfgFile = DEFAULT_CONFIG_FILE; 37 39 const char *pidFile = "/var/run/sensord.pid"; 38 40 const char *rrdFile = NULL; … … 103 105 " -T, --rrd-no-average -- switch RRD in non-average mode\n" 104 106 " -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" 106 108 " -p, --pid-file <file> -- PID file (default /var/run/sensord.pid)\n" 107 109 " -f, --syslog-facility <f> -- syslog facility to use (default local4)\n" … … 115 117 "for example, specify --log-interval 0 to only scan for alarms." 116 118 "\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" 119 120 "\n" 120 121 "If no chips are specified, all chip info will be printed.\n" … … 129 130 " -s, --set -- execute set statements (root only)\n" 130 131 " -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" 132 133 " -d, --debug -- display some debug information\n" 133 134 " -v, --version -- display version and exit\n" 134 135 " -h, --help -- display help and exit\n" 135 136 "\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" 138 138 "\n" 139 139 "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 32 32 #include "lib/error.h" 33 33 34 static const char *sensorsCfgPaths[] = {35 "/etc", "/usr/local/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib", "/usr/local/lib", NULL36 };37 38 #define CFG_PATH_LEN 409639 40 static char cfgPath[CFG_PATH_LEN + 1];41 42 34 static time_t cfgLastModified; 43 44 int45 initLib46 (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 }71 35 72 36 static int 73 37 loadConfig 74 ( int reload) {38 (const char *cfgPath, int reload) { 75 39 struct stat stats; 76 40 FILE *cfg = NULL; … … 112 76 int 113 77 loadLib 114 ( void) {78 (const char *cfgPath) { 115 79 int ret; 116 ret = loadConfig ( 0);80 ret = loadConfig (cfgPath, 0); 117 81 if (!ret) 118 82 ret = initKnownChips (); … … 122 86 int 123 87 reloadLib 124 ( void) {88 (const char *cfgPath) { 125 89 int ret; 126 90 freeKnownChips (); 127 ret = loadConfig ( 1);91 ret = loadConfig (cfgPath, 1); 128 92 if (!ret) 129 93 ret = initKnownChips (); lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.8
r4914 r4918 22 22 .\" the source, must acknowledge the copyright and authors of this work. 23 23 .\" 24 .TH sensord 8 "October 2 3, 2002" "lm-sensors 3" "Linux System Administration"24 .TH sensord 8 "October 2007" "lm-sensors 3" "Linux System Administration" 25 25 .SH NAME 26 26 sensord \- Sensor information logging daemon. … … 85 85 Specify a 86 86 .BR libsensors (3) 87 configuration file. If no file is specified, the name `sensors.conf'87 configuration file. If no file is specified, the default configuration file 88 88 is used. 89 89 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'.93 90 .IP "-p, --pid-file file" 94 91 Specify 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 88 88 while (!done && (ret == 0)) { 89 89 if (ret == 0) 90 ret = reloadLib ( );90 ret = reloadLib (sensorsCfgFile); 91 91 if ((ret == 0) && scanTime) { /* should I scan on the read cycle? */ 92 92 ret = scanChips (); … … 199 199 exit (EXIT_FAILURE); 200 200 201 if (initLib () || 202 loadLib ()) 201 if (loadLib (sensorsCfgFile)) 203 202 exit (EXIT_FAILURE); 204 203 lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sensord.h
r4834 r4918 50 50 /* from lib.c */ 51 51 52 extern int initLib (void); 53 extern int loadLib (void); 54 extern int reloadLib (void); 52 extern int loadLib (const char *cfgPath); 53 extern int reloadLib (const char *cfgPath); 55 54 extern int unloadLib (void); 56 55
