sysfs open should fail with -EACCES not -EPERM

From: Paul Larson (plars@linuxtestproject.org)
Date: Tue Dec 03 2002 - 15:47:24 EST


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;
 }



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Dec 07 2002 - 22:00:17 EST