mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-13 17:00:15 +00:00
Drop the configuration file search path mechanism from sensord. It's
confusing and useless. We dropped it from sensors years ago. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4918 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
878333508c
commit
3a87a433fd
5 files changed
+18
-59
No files matched your search
+7
-7
@@ -30,10 +30,12 @@
|
||||
#include "lib/error.h"
|
||||
#include "version.h"
|
||||
|
||||
#define DEFAULT_CONFIG_FILE ETCDIR "/sensors.conf"
|
||||
|
||||
#define MAX_CHIP_NAMES 32
|
||||
|
||||
int isDaemon = 0;
|
||||
const char *sensorsCfgFile = "sensors.conf";
|
||||
const char *sensorsCfgFile = DEFAULT_CONFIG_FILE;
|
||||
const char *pidFile = "/var/run/sensord.pid";
|
||||
const char *rrdFile = NULL;
|
||||
const char *cgiDir = NULL;
|
||||
@@ -102,7 +104,7 @@ static const char *daemonSyntax =
|
||||
" -t, --rrd-interval <time> -- interval between updating RRD file (default 5m)\n"
|
||||
" -T, --rrd-no-average -- switch RRD in non-average mode\n"
|
||||
" -r, --rrd-file <file> -- RRD file (default <none>)\n"
|
||||
" -c, --config-file <file> -- configuration file (default sensors.conf)\n"
|
||||
" -c, --config-file <file> -- configuration file (default " DEFAULT_CONFIG_FILE ")\n"
|
||||
" -p, --pid-file <file> -- PID file (default /var/run/sensord.pid)\n"
|
||||
" -f, --syslog-facility <f> -- syslog facility to use (default local4)\n"
|
||||
" -g, --rrd-cgi <img-dir> -- output an RRD CGI script and exit\n"
|
||||
@@ -114,8 +116,7 @@ static const char *daemonSyntax =
|
||||
"Specify a value of 0 for any interval to disable that operation;\n"
|
||||
"for example, specify --log-interval 0 to only scan for alarms."
|
||||
"\n"
|
||||
"If no path is specified, a list of directories is examined for the config file;\n"
|
||||
"specify the filename `-' to read the config file from stdin.\n"
|
||||
"Specify the filename `-' to read the config file from stdin.\n"
|
||||
"\n"
|
||||
"If no chips are specified, all chip info will be printed.\n"
|
||||
"\n"
|
||||
@@ -128,13 +129,12 @@ static const char *appSyntax =
|
||||
" -a, --alarm-scan -- only scan for alarms\n"
|
||||
" -s, --set -- execute set statements (root only)\n"
|
||||
" -r, --rrd-file <file> -- only update RRD file\n"
|
||||
" -c, --config-file <file> -- configuration file (default sensors.conf)\n"
|
||||
" -c, --config-file <file> -- configuration file (default " DEFAULT_CONFIG_FILE ")\n"
|
||||
" -d, --debug -- display some debug information\n"
|
||||
" -v, --version -- display version and exit\n"
|
||||
" -h, --help -- display help and exit\n"
|
||||
"\n"
|
||||
"If no path is specified, a list of directories is examined for the config file;\n"
|
||||
"specify the filename `-' to read the config file from stdin.\n"
|
||||
"Specify the filename `-' to read the config file from stdin.\n"
|
||||
"\n"
|
||||
"If no chips are specified, all chip info will be printed.\n";
|
||||
|
||||
|
||||
+5
-41
@@ -31,47 +31,11 @@
|
||||
#include "sensord.h"
|
||||
#include "lib/error.h"
|
||||
|
||||
static const char *sensorsCfgPaths[] = {
|
||||
"/etc", "/usr/local/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib", "/usr/local/lib", NULL
|
||||
};
|
||||
|
||||
#define CFG_PATH_LEN 4096
|
||||
|
||||
static char cfgPath[CFG_PATH_LEN + 1];
|
||||
|
||||
static time_t cfgLastModified;
|
||||
|
||||
int
|
||||
initLib
|
||||
(void) {
|
||||
cfgPath[CFG_PATH_LEN] = '\0';
|
||||
if (!strcmp (sensorsCfgFile, "-")) {
|
||||
strncpy (cfgPath, sensorsCfgFile, CFG_PATH_LEN);
|
||||
} else if (sensorsCfgFile[0] == '/') {
|
||||
strncpy (cfgPath, sensorsCfgFile, CFG_PATH_LEN);
|
||||
} else if (strchr (sensorsCfgFile, '/')) {
|
||||
char *cwd = getcwd (NULL, 0);
|
||||
snprintf (cfgPath, CFG_PATH_LEN, "%s/%s", cwd, sensorsCfgFile);
|
||||
free (cwd);
|
||||
} else {
|
||||
int index0;
|
||||
struct stat stats;
|
||||
for (index0 = 0; sensorsCfgPaths[index0]; ++ index0) {
|
||||
snprintf (cfgPath, CFG_PATH_LEN, "%s/%s", sensorsCfgPaths[index0], sensorsCfgFile);
|
||||
if (stat (cfgPath, &stats) == 0)
|
||||
break;
|
||||
}
|
||||
if (!sensorsCfgPaths[index0]) {
|
||||
sensorLog (LOG_ERR, "Error locating sensors configuration file: %s", sensorsCfgFile);
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
loadConfig
|
||||
(int reload) {
|
||||
(const char *cfgPath, int reload) {
|
||||
struct stat stats;
|
||||
FILE *cfg = NULL;
|
||||
int ret = 0;
|
||||
@@ -111,9 +75,9 @@ loadConfig
|
||||
|
||||
int
|
||||
loadLib
|
||||
(void) {
|
||||
(const char *cfgPath) {
|
||||
int ret;
|
||||
ret = loadConfig (0);
|
||||
ret = loadConfig (cfgPath, 0);
|
||||
if (!ret)
|
||||
ret = initKnownChips ();
|
||||
return ret;
|
||||
@@ -121,10 +85,10 @@ loadLib
|
||||
|
||||
int
|
||||
reloadLib
|
||||
(void) {
|
||||
(const char *cfgPath) {
|
||||
int ret;
|
||||
freeKnownChips ();
|
||||
ret = loadConfig (1);
|
||||
ret = loadConfig (cfgPath, 1);
|
||||
if (!ret)
|
||||
ret = initKnownChips ();
|
||||
return ret;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
.\" Formatted or processed versions of this manual, if unaccompanied by
|
||||
.\" the source, must acknowledge the copyright and authors of this work.
|
||||
.\"
|
||||
.TH sensord 8 "October 23, 2002" "lm-sensors 3" "Linux System Administration"
|
||||
.TH sensord 8 "October 2007" "lm-sensors 3" "Linux System Administration"
|
||||
.SH NAME
|
||||
sensord \- Sensor information logging daemon.
|
||||
.SH SYNOPSIS
|
||||
@@ -84,12 +84,9 @@ below for more details.
|
||||
.IP "-c, --config-file file"
|
||||
Specify a
|
||||
.BR libsensors (3)
|
||||
configuration file. If no file is specified, the name `sensors.conf'
|
||||
configuration file. If no file is specified, the default configuration file
|
||||
is used.
|
||||
|
||||
If the sensors configuration name does not contain a directory separator,
|
||||
the following paths are searched for the file:
|
||||
`/etc', `/usr/lib/sensors', `/usr/local/lib/sensors', `/usr/lib', `/usr/local/lib'.
|
||||
.IP "-p, --pid-file file"
|
||||
Specify what PID file to write; the default is to write the file
|
||||
`/var/run/sensord.pid'. You should always specify an absolute path
|
||||
|
||||
@@ -87,7 +87,7 @@ sensord
|
||||
|
||||
while (!done && (ret == 0)) {
|
||||
if (ret == 0)
|
||||
ret = reloadLib ();
|
||||
ret = reloadLib (sensorsCfgFile);
|
||||
if ((ret == 0) && scanTime) { /* should I scan on the read cycle? */
|
||||
ret = scanChips ();
|
||||
if (scanValue <= 0)
|
||||
@@ -198,8 +198,7 @@ main
|
||||
parseChips (argc, argv))
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
if (initLib () ||
|
||||
loadLib ())
|
||||
if (loadLib (sensorsCfgFile))
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
if (isDaemon)
|
||||
|
||||
@@ -49,9 +49,8 @@ extern int parseChips (int argc, char **argv);
|
||||
|
||||
/* from lib.c */
|
||||
|
||||
extern int initLib (void);
|
||||
extern int loadLib (void);
|
||||
extern int reloadLib (void);
|
||||
extern int loadLib (const char *cfgPath);
|
||||
extern int reloadLib (const char *cfgPath);
|
||||
extern int unloadLib (void);
|
||||
|
||||
/* from sense.c */
|
||||
|
||||
Reference in new issue
Block a user