sysfs open should fail with -EACCES not -EPERM
I noticed that opening a file for write on sysfs that doesn't support it returns -EPERM. After checking the SuS, I believe the correct behavior is to return -EACCES.
-Paul Larson
fs/sysfs/inode.c +2 -9
@@ -279,9 +279,7 @@*/ if (file->f_mode &FMODE_WRITE ) { -if (!(inode->i_mode &S_IWUGO )) - goto Eperm; -if (!ops->store) +if (!(inode->i_mode &S_IWUGO ) || !ops->store) goto Eaccess; }
@@ -291,9 +289,7 @@* must be a show method for it. */ if (file->f_mode &FMODE_READ ) { -if (!(inode->i_mode &S_IRUGO )) - goto Eperm; -if (!ops->show) +if (!(inode->i_mode &S_IRUGO ) || !ops->show) goto Eaccess; }
@@ -308,9 +304,6 @@ goto Done; Eaccess: error = -EACCES ; - goto Done; - Eperm: - error = -EPERM ; Done:return error; }