User: Password:
|
|
Subscribe / Log in / New account

Re: Syslets, Threadlets, generic AIO support, v6

From:  Linus Torvalds <torvalds-AT-linux-foundation.org>
To:  Davide Libenzi <davidel-AT-xmailserver.org>
Subject:  Re: Syslets, Threadlets, generic AIO support, v6
Date:  Wed, 30 May 2007 13:00:30 -0700 (PDT)
Cc:  Ingo Molnar <mingo-AT-elte.hu>, Ulrich Drepper <drepper-AT-redhat.com>, Jeff Garzik <jeff-AT-garzik.org>, Zach Brown <zach.brown-AT-oracle.com>, Linux Kernel Mailing List <linux-kernel-AT-vger.kernel.org>, Arjan van de Ven <arjan-AT-infradead.org>, Christoph Hellwig <hch-AT-infradead.org>, Andrew Morton <akpm-AT-zip.com.au>, Alan Cox <alan-AT-lxorguk.ukuu.org.uk>, Evgeniy Polyakov <johnpol-AT-2ka.mipt.ru>, "David S. Miller" <davem-AT-davemloft.net>, Suparna Bhattacharya <suparna-AT-in.ibm.com>, Jens Axboe <jens.axboe-AT-oracle.com>, Thomas Gleixner <tglx-AT-linutronix.de>
Archive-link:  Article, Thread



On Wed, 30 May 2007, Davide Libenzi wrote:
> 
> Here I think we are forgetting that glibc is userspace and there's no 
> separation between the application code and glibc code. An application 
> linking to glibc can break glibc in thousand ways, indipendently from fds 
> or not fds. Like complaining that glibc is broken because printf() 
> suddendly does not work anymore ;)

No, Davide, the problem is that some applications depend on getting 
_specific_ file descriptors.

For example, if you do

	close(0);
	.. something else ..
	if (open("myfile", O_RDONLY) < 0)
		exit(1);

you can (and should) depend on the open returning zero.

So library routines *must not* open file descriptors in the normal space.

(The same is true of real applications doing the equivalent of

	for (i = 0; i < NR_OPEN; i++)
		close(i);

to clean up all file descriptors before doing something new. And yes, I 
think it was bash that used to *literally* do something like that a long 
time ago.

Another example of the same thing: people open file descriptors and know 
that they'll be "dense" in the result, and then use "select()" on them.

So it's true that file descriptors can't be used randomly by the standard 
libraries - they'd need to have some kind of separate "private space".

Which *could* be something as simple as saying "bit 30 in the file 
descriptor specifies a separate fd space" along with some flags to make 
open and friends return those separate fd's. That makes them useless for 
"select()" (which assumes a flat address space, of course), but would be 
useful for just about anything else.

		Linus


(Log in to post comments)


Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds