Changeset 2225
- Timestamp:
- 01/17/04 19:12:38 (9 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/lib/proc.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/lib/proc.c
r2211 r2225 18 18 */ 19 19 20 /* for open() */ 21 #include <sys/types.h> 22 #include <sys/stat.h> 23 #include <fcntl.h> 24 20 25 #include <stddef.h> 21 #ifdef DEBUG 22 #include <unistd.h> /* for getuid(), to be removed */ 23 #endif 26 #include <unistd.h> 24 27 #include <stdio.h> 25 28 #include <string.h> … … 294 297 const sensors_chip_feature *the_feature; 295 298 int buflen = BUF_LEN; 296 int mag, eepromoffset, i, ret=0;299 int mag, eepromoffset, fd, ret=0; 297 300 char n[NAME_MAX]; 298 301 FILE *f; … … 309 312 if (! strcmp(name.prefix, "eeprom")){ 310 313 strcat(n, "eeprom"); 311 if ((f = fopen(n, "r")) != NULL) { 314 /* we use unbuffered I/O to benefit from eeprom driver 315 optimization */ 316 if ((fd = open(n, O_RDONLY)) >= 0) { 312 317 eepromoffset = 313 318 (the_feature->offset / sizeof(long)) + 314 319 (16 * (the_feature->sysctl - EEPROM_SYSCTL1)); 315 for(i = 0; i <= eepromoffset; i++) 316 if(EOF == (ret = getc(f))) 317 break; 318 fclose(f); 319 if(ret == EOF) 320 if (lseek(fd, eepromoffset, SEEK_SET) < 0 321 || read(fd, &ret, 1) != 1) { 322 close(fd); 320 323 return -SENSORS_ERR_PROC; 324 } 325 close(fd); 321 326 *value = ret; 322 327 return 0;
