sysfs open should fail with -EACCES not -EPERM

Paul Larson (plars@linuxtestproject.org)
03 Dec 2002 14:47:24 -0600


--=-WQFPa0tyvE8GQfB2MnZT
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

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/ino=
de.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) {
=20
- if (!(inode->i_mode & S_IWUGO))
- goto Eperm;
- if (!ops->store)
+ if (!(inode->i_mode & S_IWUGO) || !ops->store)
goto Eaccess;
=20
}
@@ -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;
}
=20
@@ -308,9 +304,6 @@
goto Done;
Eaccess:
error =3D -EACCES;
- goto Done;
- Eperm:
- error =3D -EPERM;
Done:
return error;
}

--=-WQFPa0tyvE8GQfB2MnZT
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEABECAAYFAj3tGFsACgkQbkpggQiFDqfKZACghneg9cKFA1As2T0esQrZKhz3
pQoAmwetFWprlX6xjQhQ6xmw3exfIfNP
=9lAr
-----END PGP SIGNATURE-----

--=-WQFPa0tyvE8GQfB2MnZT--

-
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/