From owner-cvs-src@FreeBSD.ORG Sat Aug 9 11:08:43 2008 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 590E51065683; Sat, 9 Aug 2008 11:08:43 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 2777E8FC1A; Sat, 9 Aug 2008 11:08:43 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id B0F9A46BA5; Sat, 9 Aug 2008 07:08:42 -0400 (EDT) Date: Sat, 9 Aug 2008 12:08:42 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Kostik Belousov In-Reply-To: <20080809103338.GN97161@deviant.kiev.zoral.com.ua> Message-ID: References: <200808081343.m78DhwYE068477@repoman.freebsd.org> <200808081226.32089.jhb@freebsd.org> <20080809001256.GL64458@server.vk2pj.dyndns.org> <20080809103338.GN97161@deviant.kiev.zoral.com.ua> User-Agent: Alpine 1.10 (BSF 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: src-committers@freebsd.org, John Baldwin , Peter Jeremy , Ed Schouten , cvs-all@freebsd.org, cvs-src@freebsd.org Subject: Re: cvs commit: src/sys/dev/io iodev.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Aug 2008 11:08:43 -0000 On Sat, 9 Aug 2008, Kostik Belousov wrote: > On Sat, Aug 09, 2008 at 11:27:58AM +0100, Robert Watson wrote: >> >> On Sat, 9 Aug 2008, Peter Jeremy wrote: >> >>> On 2008-Aug-08 12:26:31 -0400, John Baldwin wrote: >>>> It should be setting D_TRACKCLOSE though so that close() reliably clears >>>> the flag even in single-threaded processes. You can still get odd >>>> behavior if you explicitly open it twice in an app and then close one of >>>> the two fd's. You will no longer have IO permission even though you still >>>> have one fd open. However, if you do that I think you deserve what you >>>> asked for. :) >>> >>> That behaviour may be legitimate: Your code links with libraries foo and >>> bar that each independently open /dev/io so they can frob different things >>> in IO space. libfoo needs ongoing access to device foo and so keeps its >>> descriptor open. libbar only needs once-off access to device bar and so >>> closes /dev/io once it's finished its initialisation. Libraries foo and >>> bar are completely independent and shouldn't need to know anything about >>> each other and your app shouldn't need to know that libraries it's using >>> frob around in IO space. >> >> If that's the view, there should probably be a per-process counter, >> although this is all a bit tricky anyway since file descriptors and >> processes have a tenuous relationship. > > Another interesting issue is the close on exec, esp. for /dev/io. > > It seems that Linux recently grown full new API to handle FD_CLOEXEC races, > see http://udrepper.livejournal.com/20407.html While /dev/io appeals to the UNIX "everything is a file" sensibility, I think the system calls we have for this on i386 are more conceptually coherent. Robert N M Watson Computer Laboratory University of Cambridge