Re: [RFC] File flags handling - proposal for API.

Simon Richter (geier@phobos.fachschaften.tu-muenchen.de)
Fri, 2 Jul 1999 15:39:55 +0200 (CEST)


On Fri, 25 Jun 1999, Linus Torvalds wrote:

> in a directory that has subdirectories? It will open the directory
> (because right now we allow it to happen even without O_DIRECTORY), but
> then when it reads it will get an error and will print out

Introducing default files will break fstat(2).

> grep: yyyy: Is a directory
>
> which is obviously just not what the user meant.

Interesting to note how stupid grep really is:

open("acpi", O_RDONLY) = 4
fstat(4, {st_mode=S_IFDIR|0775, st_size=1024, ...}) = 0
read(4, 0x8060000, 32768) = -1 EISDIR (Is a directory)

[lstat() returns file, file is exchanged by a directory until the open()
happens]

> So what's the problem? You expected to open a file, and you opened a file.
> that can happen today. The fact that somebody renamed something from under
> you meant that you got a different file than the one you thought you'd
> get, but that is exactly the behaviour you have today.

A real problem, however, is that fstat() does not allow you to check
whether you just opened a link. Maybe a solution would be to add an
O_NOLINK flag that makes open refuse to open a symlink (that is not root
owned?)?

Simon

PGP public key available from ftp://phobos.fs.tum.de/pub/pgp/geier.asc
Fingerprint: 10 62 F6 F5 C0 5D 9E D8 47 05 1B 8A 22 E5 4E C1
GEEK code block available from ftp://phobos.fs.tum.de/pub/gcb/geier.asc
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!
1:45pm up 12 days, 18:58, 4 users, load average: 1.16, 1.09, 1.04

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