From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 5 00:56:48 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 9249E16A41F for ; Thu, 5 Jul 2007 00:56:48 +0000 (UTC) (envelope-from ighighi@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by mx1.freebsd.org (Postfix) with ESMTP id 2DA4013C4AD for ; Thu, 5 Jul 2007 00:56:47 +0000 (UTC) (envelope-from ighighi@gmail.com) Received: by ug-out-1314.google.com with SMTP id o4so439079uge for ; Wed, 04 Jul 2007 17:56:47 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=MmqpdP/AIpboY5hlEO6nFH8AvblJJ/IU9LVuUVydh2Hv5hV599usMH8HqAYYA9HUW5H6x2lxfqALugX8b6cPwnwTjjAeoy6XHcgoUSSkIj84eAYDm2G1unmUsIPpAmX9ozig8QONeImm5q+Rq8VdqC7sDHBrxrYReZhtk4QY1rY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=lipHlhUo0gYym/wPhzpWvCBwLnVpWSXu/0Talu1d+Sk6DtQ/dwCXxF+n7yQa3iK73DSb1mTFQpfBwAspY7sil6STQ0rasuYaPaQ/OVYH6c3VeOKVxV7hIYjMp8V7rmdrZmpwvNepq84rQPeg1bOEuf0LS0/TG9o7CEuCoA6QA40= Received: by 10.78.140.17 with SMTP id n17mr4436704hud.1183595269263; Wed, 04 Jul 2007 17:27:49 -0700 (PDT) Received: by 10.78.51.18 with HTTP; Wed, 4 Jul 2007 17:27:49 -0700 (PDT) Message-ID: Date: Wed, 4 Jul 2007 20:27:49 -0400 From: "Ighighi Ighighi" To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mailman-Approved-At: Thu, 05 Jul 2007 01:56:39 +0000 Subject: 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: Thu, 05 Jul 2007 00:56:48 -0000 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. These 2 fcntl would be cool to have in FreeBSD: F_CLOSEM Close all file descriptors greater than or equal to fd. F_MAXFD Return the maximum file descriptor number currently open by the process. I know that by using kern.file sysctl I could implement both, but it'd be nice if the whole closefrom() is done in kernel space. Another problem with using kern.file is that "struct xfile" may change... By checking http://fxr.watson.org/fxr/ident?v=NETBSD4;i=F_MAXFD I see that it's fairly straightforward to add the F_MAXFD bit. For the F_CLOSEM fcntl, which call is the best to replace the fdrelease() used by NetBSD in kern/kern_descrip.c ? Can someone add these to FreeBSD ? NetBSD's fcntl(2): http://www.freebsd.org/cgi/man.cgi?query=fcntl&apropos=0&sektion=0&manpath=NetBSD+3.0&format=html NetBSD's & Solaris' closefrom(3): http://www.freebsd.org/cgi/man.cgi?query=closefrom&apropos=0&sektion=0&manpath=NetBSD+3.0&format=html http://www.freebsd.org/cgi/man.cgi?query=closefrom&apropos=0&sektion=0&manpath=SunOS+5.9&format=html Cheers, Igh.