All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Larson <plars@linuxtestproject.org>
To: mochel@osdl.org
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: sysfs open should fail with -EACCES not -EPERM
Date: 03 Dec 2002 14:47:24 -0600	[thread overview]
Message-ID: <1038948444.545.59.camel@plars> (raw)

[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]

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


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 240 bytes --]

                 reply	other threads:[~2002-12-03 20:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1038948444.545.59.camel@plars \
    --to=plars@linuxtestproject.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.