public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Edgar Toernig <froese@gmx.de>
To: Daniel Phillips <phillips@bonn-fries.net>
Cc: Oliver Xymoron <oxymoron@waste.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: Why side-effects on open(2) are evil. (was Re: [RFD  w/info-PATCH]device arguments from lookup)
Date: Thu, 24 May 2001 02:23:27 +0200	[thread overview]
Message-ID: <3B0C547F.DE9E9214@gmx.de> (raw)
In-Reply-To: <Pine.LNX.4.30.0105220957400.19818-100000@waste.org> <0105221851200C.06233@starship> <3B0B3A4C.FD7143F9@gmx.de> <0105231550390K.06233@starship>

Daniel Phillips wrote:
> On Wednesday 23 May 2001 06:19, Edgar Toernig wrote:
> > Daniel Phillips wrote:
> > > On Tuesday 22 May 2001 17:24, Oliver Xymoron wrote:
> > > > On Mon, 21 May 2001, Daniel Phillips wrote:
> > > > > On Monday 21 May 2001 19:16, Oliver Xymoron wrote:
> > > > > > What I'd like to see:
> > > > > >
> > > > > > - An interface for registering an array of related devices
> > > > > > (almost always two: raw and ctl) and their legacy device
> > > > > > numbers with a single userspace callout that does whatever
> > > > > > /dev/ creation needs to be done. Thus, naming and permissions
> > > > > > live in user space. No "device node is also a directory"
> > > > > > weirdness...
> > > > >
> > > > > Could you be specific about what is weird about it?
> > > >
> > > > *boggle*
> > > >
> > > >[general sense of unease]
> >
> > I fully agree with Oliver.  It's an abomination.
> 
> We are, or at least, I am, investigating this question purely on
> technical grounds - name calling is a noop.

Right.  But sometimes new ideas raise these kind of feelings ;)

> > > It's going to be marked 'd', it's a directory, not a file.
> >
> > Aha.  So you lose the S_ISCHR/BLK attribute.
> 
> Readdir fills in a directory type, so ls sees it as a directory and does
> the right thing.  On the other hand, we know we're on a device
> filesystem so we will next open the name as a regular file, and find
> ISCHR or ISBLK: good.

??? The kernel may know it, but the app?  Or do you really want to
give different stat data on stat(2) and fstat(2)?  These flags are
currently used by archive/backup prgs.  It's a hint that these files
are not regular files and shouldn't be opened for reading.
Having a 'd' would mean that they would really try to enter the
directory and save it's contents.  Don't know what happens in this
case to your "special" files ;-)

> The rule for this filesystem is: if you open with O_DIRECTORY then
> directory operations are permitted, nothing else.  If you open without
> O_DIRECTORY then directory operations are forbidden (as
> usual) and normal device semantics apply.

As usual?  I think you've just changed the rules for O_DIRECTORY.  Up
to now it's only a flag that tells open it should fail if the name
does not refer to a directory.  Nothing else.  It was introduced to
remove a race condition in user space applications.  Especially it
is optional - everything works the same whether you give the flag
or not (except the race avoidance of course).  And there are a lot
of programs that do not use O_DIRECTORY (it's a Linux private flag,
not even mentioned in POSIX).  Every program that does:

	fd = open(foo, O_RDONLY);
	fchdir(fd);
	x = opendir(".")

will break.  And that is POSIX conform.  And I know that there are
programs that use this when recursively scanning directories (avoids
name mangling and repeated name lookups of the directory on later
stat calls).

> > Directories are not allowed to be read from/written to.  The VFS may
> > support it, but it's not (current) UNIX.
> 
> Here, we obey this rule: if you open it with O_DIRECTORY then you
> can't read from or write to it.

IMHO you've just invented opendir(2).

> Nothing breaks here, ls works as it always did.
> 
> This is what ls does:
> 
> open("foobar", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
> fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> fcntl64(0x3, 0x2, 0x1, 0x2)             = -1 ENOSYS (Function not implemented)
> fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
> brk(0x805b000)                          = 0x805b000
> getdents64(0x3, 0x8058270, 0x1000, 0x26) = -1 ENOSYS (Function not implemented)
> getdents(3, /* 2 entries */, 2980)      = 28
> getdents(3, /* 0 entries */, 2980)      = 0
> close(3)                                = 0
> 
> Note that ls doesn't do anything as inconvenient as opening
> foobar as a normal file first, expecting that operation to fail.

Well, your ls does not work "as it always did".  Here's an strace of
my libc5 system ls:

open(".", O_RDONLY)                     = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
getdents(3, /* 64 entries */, 4096)     = 1216
getdents(3, /* 9 entries */, 4096)      = 168
getdents(3, /* 0 entries */, 4096)      = 0
close(3)                                = 0

And my find(1) does:

open(".", O_RDONLY)                     = 3
[scan all dirs]
fchdir(3)                               = 0

to return to its initial dir.  Will break too.

> No, you would get side effects only if you open as a regular file.

IMHO your assumption that opening a dir _requires_ O_DIRECTORY is
wrong.  You've put in a new semantic that has not been there and
that will break programs and POSIX conformance.

> Please, if you know something that actually breaks, tell me.

Yeah, see above ;)

Ciao, ET.


  parent reply	other threads:[~2001-05-24  0:54 UTC|newest]

Thread overview: 161+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-19  6:23 [RFD w/info-PATCH] device arguments from lookup, partion code in userspace Ben LaHaise
2001-05-19  6:57 ` [RFD w/info-PATCH] device arguments from lookup, partion code inuserspace Andrew Clausen
2001-05-19  7:04   ` Alexander Viro
2001-05-19  7:23     ` Andrew Clausen
2001-05-19  8:30       ` Alexander Viro
2001-05-19 10:13         ` Andrew Clausen
2001-05-19 14:02         ` [RFD w/info-PATCH] device arguments from lookup, partion code Alan Cox
2001-05-19 16:48           ` Erik Mouw
2001-05-19 17:45             ` Aaron Lehmann
2001-05-19 19:38               ` Erik Mouw
2001-05-19 20:53                 ` Steven Walter
2001-05-19 18:51           ` Richard Gooch
2001-05-20  2:18             ` Matthew Wilcox
2001-05-20  2:22               ` Richard Gooch
2001-05-20  2:34                 ` Matthew Wilcox
2001-05-20  2:48                   ` Richard Gooch
2001-05-20  3:26                     ` Linus Torvalds
2001-05-20 10:23                       ` Russell King
2001-05-20 10:35                         ` Alexander Viro
2001-05-20 18:46                         ` Linus Torvalds
2001-05-20 18:57                           ` Russell King
2001-05-20 19:10                             ` Linus Torvalds
2001-05-20 19:42                               ` Alexander Viro
2001-05-20 20:07                                 ` Alan Cox
2001-05-20 20:33                                   ` Alexander Viro
2001-05-20 23:59                                   ` Paul Fulghum
2001-05-21  0:36                                     ` Alexander Viro
2001-05-21  3:08                                       ` Paul Fulghum
2001-05-20 20:07                                 ` Alan Cox
2001-05-20 23:46                                 ` Ingo Molnar
2001-05-21  0:32                                   ` Alexander Viro
2001-05-21  3:12                                   ` Linus Torvalds
2001-05-21 19:32                                     ` Kai Henningsen
2001-05-23  1:15                                     ` Albert D. Cahalan
2001-05-20  2:36                 ` Alexander Viro
2001-05-20  2:51                   ` Richard Gooch
2001-05-20 21:13                     ` Pavel Machek
2001-05-21 20:20                       ` Alan Cox
2001-05-21 20:41                         ` Alexander Viro
2001-05-21 21:29                           ` Alan Cox
2001-05-21 21:51                             ` Alexander Viro
2001-05-21 21:56                               ` Alan Cox
2001-05-21 22:10                                 ` Linus Torvalds
2001-05-21 22:22                                   ` Alexander Viro
2001-05-22  2:28                                     ` Paul Mackerras
2001-05-22 15:41                                     ` Oliver Xymoron
2001-05-22 13:33                                   ` Jan Harkes
2001-05-22 16:30                                     ` Linus Torvalds
2001-05-22  0:22                               ` Ingo Oeser
2001-05-22  0:57                                 ` Matthew Wilcox
2001-05-22  1:13                                   ` Linus Torvalds
2001-05-22  1:18                                     ` Matthew Wilcox
2001-05-22  7:49                                       ` Alan Cox
2001-05-22 15:31                                         ` Matthew Wilcox
2001-05-22 15:31                                           ` Alan Cox
2001-05-22 15:38                                             ` Matthew Wilcox
2001-05-22 15:42                                               ` Alan Cox
2001-05-20  2:31             ` Alexander Viro
2001-05-20 16:57             ` David Woodhouse
2001-05-20 19:02               ` Linus Torvalds
2001-05-20 19:11                 ` Alexander Viro
2001-05-20 19:18                   ` Matthew Wilcox
2001-05-20 19:24                     ` Alexander Viro
2001-05-20 19:34                       ` Linus Torvalds
2001-05-20 19:27                   ` Linus Torvalds
2001-05-20 19:33                     ` Alexander Viro
2001-05-20 19:38                       ` Linus Torvalds
2001-05-20 19:57                 ` David Woodhouse
2001-05-21 13:57                 ` Ingo Oeser
2001-05-19  9:11     ` [RFD w/info-PATCH] device arguments from lookup, partion code inuserspace Andrew Morton
2001-05-19  9:20       ` Alexander Viro
2001-05-19  7:58   ` Ben LaHaise
2001-05-19  8:10     ` Alexander Viro
2001-05-19  8:16       ` Ben LaHaise
2001-05-19  8:32         ` Alexander Viro
2001-05-19  9:42 ` [RFD w/info-PATCH] device arguments from lookup, partion code in userspace Christer Weinigel
2001-05-19  9:51 ` Christer Weinigel
2001-05-19 11:37 ` Eric W. Biederman
2001-05-19 14:25   ` Daniel Phillips
2001-05-21  8:14     ` Lars Marowsky-Bree
2001-05-22  9:07       ` Daniel Phillips
2001-05-19 13:53 ` Daniel Phillips
2001-05-19 13:57 ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH] device arguments from lookup) Alexander Viro
2001-05-19 15:10   ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device " Abramo Bagnara
2001-05-19 15:18     ` Alexander Viro
2001-05-19 16:01     ` Willem Konynenberg
2001-05-20 20:52       ` Pavel Machek
2001-05-20 20:53       ` Pavel Machek
2001-05-19 18:13   ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH] device " Linus Torvalds
2001-05-19 23:19     ` Alexander Viro
2001-05-19 23:31       ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device " Jeff Garzik
2001-05-19 23:32         ` Jeff Garzik
2001-05-19 23:39         ` Alexander Viro
2001-05-20 15:47           ` F_CTRLFD (was Re: Why side-effects on open(2) are evil.) Edgar Toernig
2001-05-20 16:20             ` Alexander Viro
2001-05-20 19:01               ` Edgar Toernig
2001-05-20 19:30                 ` Alexander Viro
2001-05-21 17:16           ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device arguments from lookup) Oliver Xymoron
2001-05-21 16:26             ` David Lang
2001-05-21 18:04               ` Oliver Xymoron
2001-05-21 20:14             ` Daniel Phillips
2001-05-22 15:24               ` Oliver Xymoron
2001-05-22 16:51                 ` Daniel Phillips
2001-05-22 17:49                   ` Oliver Xymoron
2001-05-22 20:22                     ` Daniel Phillips
2001-05-23  4:19                   ` Edgar Toernig
2001-05-23  4:50                     ` Alexander Viro
2001-05-23 13:50                     ` Daniel Phillips
2001-05-23 13:50                     ` Daniel Phillips
2001-05-23 15:58                       ` Oliver Xymoron
2001-05-24  0:23                       ` Edgar Toernig [this message]
2001-05-24  7:47                         ` Marko Kreen
2001-05-24 14:39                           ` Oliver Xymoron
2001-05-24 15:20                             ` CHR/BLK needed? was: Re: Why side-effects on open Marko Kreen
2001-05-24 17:12                             ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device Albert D. Cahalan
2001-05-24 17:25                         ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device arguments from lookup) Daniel Phillips
2001-05-24 20:59                           ` Edgar Toernig
2001-05-24 21:26                             ` Alexander Viro
2001-05-25  1:03                               ` Daniel Phillips
2001-05-25 11:00                             ` Daniel Phillips
2001-05-26  3:07                               ` Edgar Toernig
2001-05-26 22:36                                 ` Daniel Phillips
2001-05-27 13:32                                   ` Edgar Toernig
2001-05-27 20:40                                     ` Ben LaHaise
2001-05-27 20:45                                     ` Daniel Phillips
2001-05-27 21:50                                       ` Marko Kreen
2001-05-28  1:26                                       ` Horst von Brand
2001-05-29 10:54                                         ` Daniel Phillips
2001-05-29 13:54                                           ` Horst von Brand
2001-05-19 23:52   ` Edgar Toernig
2001-05-20  0:18     ` Alexander Viro
2001-05-20  0:32       ` Linus Torvalds
2001-05-20  0:52         ` Jeff Garzik
2001-05-20  1:03         ` Jeff Garzik
2001-05-20 19:41           ` Why side-effects on open(2) are evil. (was Re: [RFD Alan Cox
2001-05-21  9:45           ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH]device arguments from lookup) Andrew Clausen
2001-05-21 17:22           ` Oliver Xymoron
2001-05-22 18:53           ` Andreas Dilger
2001-05-24  9:20             ` Malcolm Beattie
2001-05-24 19:15               ` Andreas Dilger
2001-05-22 18:41         ` Andreas Dilger
2001-05-22 19:06           ` Linus Torvalds
2001-05-22 19:16             ` Peter J. Braam
2001-05-22 20:10               ` Andreas Dilger
2001-05-22 20:59                 ` Peter J. Braam
2001-05-23  9:23                   ` Stephen C. Tweedie
2001-05-24 21:07                 ` Daniel Phillips
2001-05-24 22:00                   ` Hans Reiser
2001-05-25 10:56                     ` Daniel Phillips
2001-06-01  3:24                       ` [reiserfs-list] " Hans Reiser
2001-05-23  9:13               ` Stephen C. Tweedie
2001-05-20 20:23   ` Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH] device " Pavel Machek
2001-05-21 20:38     ` Alexander Viro
2001-05-19 18:31 ` [RFD w/info-PATCH] device arguments from lookup, partion code in userspace Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2001-05-19 14:19 Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH] device arguments from lookup) Andries.Brouwer
2001-05-19 14:58 ` Alexander Viro
2001-05-19 16:41 Andries.Brouwer
2001-05-19 16:51 ` Alexander Viro
2001-05-19 17:14   ` Matthew Wilcox
2001-05-19 23:24     ` Alexander Viro
2001-05-20 11:18 ` Matthew Kirkwood

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=3B0C547F.DE9E9214@gmx.de \
    --to=froese@gmx.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oxymoron@waste.org \
    --cc=phillips@bonn-fries.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox