Skip to contentSkip to conversation

sysfs open should fail with -EACCES not -EPERM

PATCH Paul Larson 1 participant 1 message Dec 3, 2002 Driver core

lore
Share & tools
lore
#0 lore raw

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
diff -Naur linux-2.5.50/fs/sysfs/inode.c linux-2.5.50-sysfsfix/fs/sysfs/inode.c
@@ -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;
 }