lkml.org 
[lkml]   [2000]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: access() says EROFS even for device files if /dev is mounted RO
On Sun, Nov 26, 2000 at 11:35:22PM -0400, Peter Cordes wrote:

> While doing some hdparm hacking, after booting with init=/bin/sh, I noticed
> that open(1) doesn't work when / is mounted read only.

Already long ago open(1) was renamed to openvt(1), so it may be that
have a very old version. See a recent kbd or console-tools.

> access("/dev/tty2", R_OK|W_OK) = -1 EROFS (Read-only file system)

> However, this is wrong. You _can_ write to device files on read-only
> filesystems. (open shouldn't bother calling access(), but the kernel should
> definitely give the right answer!)

You misunderstand the function of access(). The standard says

[EROFS] write access shall fail if write access is requested
for a file on a read-only file system

It does not look at whether you ask write access to a directory
or a special device file (and whether the filesystem was mounted nodev or not).

So, probably you found a flaw in openvt: the use of access is almost always
a bug - it doesnt tell you what you want to know. You may send me a patch
if you want to.

On the other hand, on recent kernels access() doesnt fail in this situation.
That is a kernel bug, I suppose. Will investigate later.

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

\
 
 \ /
  Last update: 2005-03-22 12:47    [W:0.068 / U:8.380 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site