2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 22:05:11 +00:00

(mds) fix error reporting when you don't have permission to open

/dev/i2c-x and /dev/i2cx doesn't exist.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@847 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark D. Studebaker
2000-07-16 22:54:41 +00:00
parent 7922fece0c
commit 86d41cfc96
3 changed files with 41 additions and 4 deletions

View File

@@ -13,6 +13,9 @@ ask CVS about it:
for example:
cvs diff -r V2-0-0 -r V2-0-1 -u
2.5.3 (2000????)
Programs i2cdetect, i2cdump: Improve error reporting
2.5.2 (20000709)
File sensors.conf.eg: Fix lm80 in8 calculation
Module w83781d: W83783S no longer crashes on unloading

View File

@@ -45,6 +45,7 @@ int main(int argc, char *argv[])
{
char *end;
int i,j,res,i2cbus,file;
int e1, e2;
char filename1[20];
char filename2[20];
char *filename;
@@ -71,9 +72,25 @@ int main(int argc, char *argv[])
sprintf(filename1,"/dev/i2c-%d",i2cbus);
sprintf(filename2,"/dev/i2c%d",i2cbus);
if ((file = open(filename1,O_RDWR)) < 0) {
e1 = errno;
if ((file = open(filename2,O_RDWR)) < 0) {
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",filename1,
filename2,strerror(errno));
e2 = errno;
if(e1 == ENOENT && e2 == ENOENT) {
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",
filename1,filename2,strerror(ENOENT));
}
if (e1 != ENOENT) {
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
filename1,strerror(e1));
if(e1 == EACCES)
fprintf(stderr,"Run as root?\n");
}
if (e2 != ENOENT) {
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
filename2,strerror(e2));
if(e2 == EACCES)
fprintf(stderr,"Run as root?\n");
}
exit(1);
} else {
filename = filename2;

View File

@@ -45,6 +45,7 @@ int main(int argc, char *argv[])
{
char *end;
int i,j,res,i2cbus,address,size,file;
int e1, e2;
int bank = 0, bankreg = 0x4E;
char filename1[20];
char filename2[20];
@@ -128,9 +129,25 @@ int main(int argc, char *argv[])
sprintf(filename1,"/dev/i2c-%d",i2cbus);
sprintf(filename2,"/dev/i2c%d",i2cbus);
if ((file = open(filename1,O_RDWR)) < 0) {
e1 = errno;
if ((file = open(filename2,O_RDWR)) < 0) {
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",filename1,
filename2,strerror(errno));
e2 = errno;
if(e1 == ENOENT && e2 == ENOENT) {
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",
filename1,filename2,strerror(ENOENT));
}
if (e1 != ENOENT) {
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
filename1,strerror(e1));
if(e1 == EACCES)
fprintf(stderr,"Run as root?\n");
}
if (e2 != ENOENT) {
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
filename2,strerror(e2));
if(e2 == EACCES)
fprintf(stderr,"Run as root?\n");
}
exit(1);
} else {
filename = filename2;