mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 22:35:23 +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:
3
CHANGES
3
CHANGES
@@ -13,6 +13,9 @@ ask CVS about it:
|
|||||||
for example:
|
for example:
|
||||||
cvs diff -r V2-0-0 -r V2-0-1 -u
|
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)
|
2.5.2 (20000709)
|
||||||
File sensors.conf.eg: Fix lm80 in8 calculation
|
File sensors.conf.eg: Fix lm80 in8 calculation
|
||||||
Module w83781d: W83783S no longer crashes on unloading
|
Module w83781d: W83783S no longer crashes on unloading
|
||||||
|
@@ -45,6 +45,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
int i,j,res,i2cbus,file;
|
int i,j,res,i2cbus,file;
|
||||||
|
int e1, e2;
|
||||||
char filename1[20];
|
char filename1[20];
|
||||||
char filename2[20];
|
char filename2[20];
|
||||||
char *filename;
|
char *filename;
|
||||||
@@ -71,9 +72,25 @@ int main(int argc, char *argv[])
|
|||||||
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
||||||
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
||||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||||
|
e1 = errno;
|
||||||
if ((file = open(filename2,O_RDWR)) < 0) {
|
if ((file = open(filename2,O_RDWR)) < 0) {
|
||||||
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",filename1,
|
e2 = errno;
|
||||||
filename2,strerror(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);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
filename = filename2;
|
filename = filename2;
|
||||||
|
@@ -45,6 +45,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
int i,j,res,i2cbus,address,size,file;
|
int i,j,res,i2cbus,address,size,file;
|
||||||
|
int e1, e2;
|
||||||
int bank = 0, bankreg = 0x4E;
|
int bank = 0, bankreg = 0x4E;
|
||||||
char filename1[20];
|
char filename1[20];
|
||||||
char filename2[20];
|
char filename2[20];
|
||||||
@@ -128,9 +129,25 @@ int main(int argc, char *argv[])
|
|||||||
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
||||||
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
||||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||||
|
e1 = errno;
|
||||||
if ((file = open(filename2,O_RDWR)) < 0) {
|
if ((file = open(filename2,O_RDWR)) < 0) {
|
||||||
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",filename1,
|
e2 = errno;
|
||||||
filename2,strerror(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);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
filename = filename2;
|
filename = filename2;
|
||||||
|
Reference in New Issue
Block a user