Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762080AbXFJFHx (ORCPT ); Sun, 10 Jun 2007 01:07:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756909AbXFJFHo (ORCPT ); Sun, 10 Jun 2007 01:07:44 -0400 Received: from smtp2.linux-foundation.org ([207.189.120.14]:50380 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbXFJFHo (ORCPT ); Sun, 10 Jun 2007 01:07:44 -0400 Date: Sat, 9 Jun 2007 22:06:27 -0700 (PDT) From: Linus Torvalds To: dean gaudet cc: Al Viro , Kyle Moffett , Ulrich Drepper , Davide Libenzi , Alan Cox , Theodore Tso , Eric Dumazet , Linux Kernel Mailing List , Andrew Morton , Ingo Molnar Subject: Re: [patch 7/8] fdmap v2 - implement sys_socket2 In-Reply-To: Message-ID: References: <20070609014140.GC4095@ftp.linux.org.uk> <466A0BFB.3070908@redhat.com> <20070609151521.GD4095@ftp.linux.org.uk> <466AD4BA.80407@redhat.com> <20070609165454.GE4095@ftp.linux.org.uk> <466ADEAB.7080202@redhat.com> <20070609172429.GF4095@ftp.linux.org.uk> <2E51520E-EC73-457F-809A-4749ED9A3C97@mac.com> <20070609200645.GG4095@ftp.linux.org.uk> <20070610031922.GC21478@ftp.linux.org.uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1289 Lines: 30 On Sat, 9 Jun 2007, dean gaudet wrote: > > for an example of a library wanting to cache an open fd ... and failing > miserably at protecting itself from the application closing its fd read: Heh. Why the hell doesn't that thing just do an "fstat()" on the thing, and compare the inode number? Not that I would guarantee that it works either for a socket, but it would seem to make more sense than what it apparently does now, and I think it should work at least on Linux. (Ie linux will give fake "st_ino" numbers to sockets. Whether anybody else will do that, I have no friggin clue. And you probably shouldn't depend on it even under Linux, but damn, despite all of those issues, it's likely better and more logical than what libnss-ldap apparently does now ;) Doing a "fstat()" call is how you generally test if two fd's point to the same file. Doing the same thing for sockets would at least be half-way sane, and even if the OS doesn't give new sockets individual st_ino numbers, they probably won't be *changing*. Linus - 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/