96{
97 char path[PATH_MAX],filename[PATH_MAX];
103 DIR *dir,*d;
106 struct dirent *hwmonx;
108 int retlen;
109
110#define NUM_PATHS 2
112 "device","."
113 };
114
115
116 dir = opendir(base_dir);
117 if ( dir == NULL ) {
118 SUBDBG(
"Can't find %s, are you sure the coretemp module is loaded?\n",
119 base_dir);
120 return 0;
121 }
122
123
124 while( (hwmonx = readdir(dir) ) ) {
125 if ( !strncmp("hwmon", hwmonx->d_name, 5) ) {
126
127
128
129
130 for(pathnum=0;pathnum<
NUM_PATHS;pathnum++) {
131
132 retlen = snprintf(path, PATH_MAX, "%s/%s/%s",
133 base_dir, hwmonx->d_name,paths[pathnum]);
134 if (retlen <= 0 || PATH_MAX <= retlen) {
135 SUBDBG(
"Path length is too long.\n");
137 }
138 SUBDBG(
"Trying to open %s\n",path);
139 d = opendir(path);
140 if (d==NULL) {
141 continue;
142 }
143
144
145
148 SUBDBG(
"Module name too long.\n");
150 }
151 fff=fopen(filename,
"r");
154 } else {
156 modulename[strlen(modulename)-1]='\0';
157 }
159 }
160
161 SUBDBG(
"Found module %s\n",modulename);
162
163
164
165
166
167
168
169
170
171
173
174
178 SUBDBG(
"Failed to construct location label.\n");
180 }
181 fff=fopen(filename,
"r");
184 }
185 else {
188 }
190 }
191
192
196 SUBDBG(
"Failed input temperature string.\n");
198 }
199 fff=fopen(filename,
"r");
200 if (
fff==NULL)
continue;
202
205 SUBDBG(
"Unable to generate name %s:in%i_input\n", hwmonx->d_name,
i);
206 closedir(dir);
207 closedir(d);
209 }
210
216 SUBDBG(
"snprintf failed.\n");
218 }
219
221 goto done_error;
222 }
223
225
226 }
227
228
229
230
231
233
234
238 SUBDBG(
"Location label string failed.\n");
240 }
241 fff=fopen(filename,
"r");
244 }
245 else {
248 }
250 }
251
252
256 SUBDBG(
"Input temperature string failed.\n");
258 }
259 fff=fopen(filename,
"r");
260 if (
fff==NULL)
continue;
262
265 SUBDBG(
"Unable to generate name %s:temp%i_input\n", hwmonx->d_name,
i);
266 closedir(d);
267 closedir(dir);
269 }
270
276 SUBDBG(
"snprintf failed.\n");
278 }
279
281 goto done_error;
282 }
283
285 }
286
287
288
289
290
292
293
297 SUBDBG(
"Failed to write fan label string.\n");
299 }
300 fff=fopen(filename,
"r");
303 }
304 else {
307 }
309 }
310
311
314 SUBDBG(
"Unable to generate filename %s/fan%d_input\n", path,
i);
315 closedir(d);
316 closedir(dir);
318 }
319
320 fff=fopen(filename,
"r");
321 if (
fff==NULL)
continue;
323
326 SUBDBG(
"Unable to generate name %s:fan%i_input\n", hwmonx->d_name,
i);
327 closedir(d);
328 closedir(dir);
330 }
331
337 SUBDBG(
"snprintf failed.\n");
339 }
340
342 goto done_error;
343 }
344
346
347 }
348 closedir(d);
349 }
350 }
351 }
352
353 closedir(dir);
355
356done_error:
357 closedir(d);
358 closedir(dir);
360}
static int insert_in_list(char *name, char *units, char *description, char *filename)
#define SUBDBG(format, args...)
int fclose(FILE *__stream)