2002-12-03 20:48:10

by Paul Larson

[permalink] [raw]
Subject: 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

diff -Naur linux-2.5.50/fs/sysfs/inode.c linux-2.5.50-sysfsfix/fs/sysfs/inode.c
--- linux-2.5.50/fs/sysfs/inode.c Wed Nov 27 16:36:17 2002
+++ linux-2.5.50-sysfsfix/fs/sysfs/inode.c Tue Dec 3 14:07:19 2002
@@ -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;
}


Attachments:
signature.asc (240.00 B)
This is a digitally signed message part