From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 6 11:50:18 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4988116A41F for ; Fri, 6 Jul 2007 11:50:18 +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 2412F13C457 for ; Fri, 6 Jul 2007 11:50:18 +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 89D394830D; Fri, 6 Jul 2007 07:50:17 -0400 (EDT) Date: Fri, 6 Jul 2007 12:50:17 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: d@delphij.net In-Reply-To: <468E16E6.6030608@delphij.net> Message-ID: <20070706124407.T9997@fledge.watson.org> References: <20070705122650.GE1302@britannica.bec.de> <468E16E6.6030608@delphij.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org Subject: Re: add closefrom() call X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jul 2007 11:50:18 -0000 On Fri, 6 Jul 2007, LI Xin wrote: > Joerg Sonnenberger wrote: > >> On Wed, Jul 04, 2007 at 08:27:49PM -0400, Ighighi Ighighi wrote: >> >>> The closefrom() call, available in Solaris, is present in NetBSD since >>> version 3.0. It is implemented with the F_CLOSEM fcntl() available since >>> version 2.0. >> >> You could also add a system call like it was done in DragonFly. That might >> be even simpler to implement. > > Here is my implementation for FreeBSD. Some difference between my and > DragonFly's implementation: > > - closefrom(-1) would be no-op on DragonFly, my version would close all > open files (From my understanding of OpenSolaris's userland > implementation, this is Solaris's behavior). > - my version closefrom(very_big_fd) would result in EBADF. I am not > very sure whether this is correct, but it does not hurt for applications > that thinks closefrom() would return void. > > To RW: I have not found a suitable audit event for this, should I create a > new event? Solaris side-steps this issue by simply auditing the individual close() system calls. My preference would be that we implement this in user space also, which would likewise generate a series of audit events, one for each system call. The procfs optimization they use (I wonder -- is it really an optimization?) won't work for us, however. Do you think that there's a strong motivation to provide a closefrom(2) system call, rather than a closefrom(3) library call? This would let us neatly avoid the question you've posed :-). Robert N M Watson Computer Laboratory University of Cambridge