Changeset 5647
- Timestamp:
- 02/15/09 18:22:38 (4 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 4 modified
-
CHANGES (modified) (1 diff)
-
lib/init.c (modified) (6 diffs)
-
lib/libsensors.3 (modified) (4 diffs)
-
lib/sensors.conf.5 (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r5645 r5647 13 13 Exit the configuration file parser sooner 14 14 Free bus statements from the configuration file sooner 15 Read extra configuration files from /etc/sensors.d 15 16 lm_sensors.init: Support new format of /etc/sysconfig/lm_sensors (#2246) 16 17 Drop support for kernels 2.4 and earlier -
lm-sensors/trunk/lib/init.c
r5646 r5647 2 2 init.c - Part of libsensors, a Linux library for reading sensor data. 3 3 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>4 Copyright (C) 2007, 2009 Jean Delvare <khali@linux-fr.org> 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 20 20 */ 21 21 22 /* Needed for scandir() and alphasort() */ 23 #define _BSD_SOURCE 24 25 #include <sys/types.h> 22 26 #include <locale.h> 23 27 #include <stdlib.h> … … 25 29 #include <string.h> 26 30 #include <errno.h> 31 #include <dirent.h> 27 32 #include "sensors.h" 28 33 #include "data.h" … … 36 41 #define DEFAULT_CONFIG_FILE ETCDIR "/sensors3.conf" 37 42 #define ALT_CONFIG_FILE ETCDIR "/sensors.conf" 43 #define DEFAULT_CONFIG_DIR ETCDIR "/sensors.d" 38 44 39 45 /* Wrapper around sensors_yyparse(), which clears the locale so that … … 98 104 free_config_busses(); 99 105 return err; 106 } 107 108 static int config_file_filter(const struct dirent *entry) 109 { 110 return (entry->d_type == DT_REG || entry->d_type == DT_LNK) 111 && entry->d_name[0] != '.'; /* Skip hidden files */ 112 } 113 114 static int add_config_from_dir(const char *dir) 115 { 116 int count, res, i; 117 struct dirent **namelist; 118 119 count = scandir(dir, &namelist, config_file_filter, alphasort); 120 if (count < 0) { 121 sensors_parse_error(strerror(errno), 0); 122 return -SENSORS_ERR_PARSE; 123 } 124 125 for (res = 0, i = 0; !res && i < count; i++) { 126 int len; 127 char path[PATH_MAX]; 128 FILE *input; 129 130 len = snprintf(path, sizeof(path), "%s/%s", dir, 131 namelist[i]->d_name); 132 if (len < 0 || len >= (int)sizeof(path)) { 133 res = -SENSORS_ERR_PARSE; 134 continue; 135 } 136 137 input = fopen(path, "r"); 138 if (input) { 139 res = parse_config(input); 140 fclose(input); 141 } else { 142 res = -SENSORS_ERR_PARSE; 143 sensors_parse_error(strerror(errno), 0); 144 } 145 } 146 147 /* Free memory allocated by scandir() */ 148 for (i = 0; i < count; i++) 149 free(namelist[i]); 150 free(namelist); 151 152 return res; 100 153 } 101 154 … … 130 183 goto exit_cleanup; 131 184 } 185 186 /* Also check for files in default directory */ 187 res = add_config_from_dir(DEFAULT_CONFIG_DIR); 188 if (res) 189 goto exit_cleanup; 132 190 } 133 191 -
lm-sensors/trunk/lib/libsensors.3
r4990 r5647 1 .\" Copyright 1998, 1999 Adrian Baugh <adrian.baugh@keble.ox.ac.uk> 1 .\" Copyright (C) 1998, 1999 Adrian Baugh <adrian.baugh@keble.ox.ac.uk> 2 .\" Copyright (C) 2007, 2009 Jean Delvare <khali@linux-fr.org> 2 3 .\" based on sensors.h, part of libsensors by Frodo Looijaard 3 4 .\" libsensors is distributed under the GPL … … 25 26 .\" References consulted: 26 27 .\" libsensors source code 27 .TH libsensors 3 " October 2007" "lm-sensors 3" "Linux Programmer's Manual"28 .TH libsensors 3 "February 2009" "lm-sensors 3" "Linux Programmer's Manual" 28 29 .SH NAME 29 30 libsensors \- publicly accessible functions provided by the sensors library … … 58 59 sensors_cleanup() below before calling sensors_init() again. 59 60 60 If FILE is NULL, the default configuration file isused (see the FILES61 If FILE is NULL, the default configuration files are used (see the FILES 61 62 section below). Most applications will want to do that. 62 63 … … 181 182 configuration file. /etc/sensors3.conf is tried first, and if it doesn't exist, 182 183 /etc/sensors.conf is used instead. 184 .RE 185 186 .I /etc/sensors.d 187 .RS 188 A directory where you can put additional libsensors configuration files. 189 Files found in this directory will be processed in alphabetical order after 190 the default configuration file. Files with names that start with a dot are 191 ignored. 192 .RE 183 193 184 194 .SH SEE ALSO -
lm-sensors/trunk/lib/sensors.conf.5
r5536 r5647 1 1 .\" Copyright (C) 1998, 1999 Adrian Baugh <adrian.baugh@keble.ox.ac.uk> and 2 2 .\" Frodo Looijaard <frodol@dds.nl> 3 .\" Copyright (C) 2008 Jean Delvare <khali@linux-fr.org>3 .\" Copyright (C) 2008, 2009 Jean Delvare <khali@linux-fr.org> 4 4 .\" 5 5 .\" Permission is granted to make and distribute verbatim copies of this … … 22 22 .\" References consulted: 23 23 .\" sensors.conf.eg by Frodo Looijaard 24 .TH sensors.conf 5 " December 2008" "lm-sensors 3" "Linux User's Manual"24 .TH sensors.conf 5 "February 2009" "lm-sensors 3" "Linux User's Manual" 25 25 .SH NAME 26 26 sensors.conf \- libsensors configuration file … … 275 275 will generate these lines for you. 276 276 277 In the case where multiple configuration files are used, the scope 278 of each 279 .I bus 280 statement is the configuration file it was defined in. This makes it 281 possible to have bus statements in all configuration files which will 282 not unexpectedly interfere with each other. 283 277 284 .SS STATEMENT ORDER 278 285 … … 534 541 configuration file. /etc/sensors3.conf is tried first, and if it doesn't exist, 535 542 /etc/sensors.conf is used instead. 543 .RE 544 545 .I /etc/sensors.d 546 .RS 547 A directory where you can put additional libsensors configuration files. 548 Files found in this directory will be processed in alphabetical order after 549 the default configuration file. Files with names that start with a dot are 550 ignored. 551 .RE 536 552 537 553 .SH SEE ALSO
