From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 9 18:49:45 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 7DEE316A403 for ; Mon, 9 Apr 2007 18:49:45 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout4.cac.washington.edu (mxout4.cac.washington.edu [140.142.33.19]) by mx1.freebsd.org (Postfix) with ESMTP id 5EE1C13C4C1 for ; Mon, 9 Apr 2007 18:49:45 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from hymn09.u.washington.edu (hymn09.u.washington.edu [140.142.12.183]) by mxout4.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l39InffJ024385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 9 Apr 2007 11:49:42 -0700 Received: from localhost (localhost [127.0.0.1]) by hymn09.u.washington.edu (8.13.7+UW06.06/8.13.7+UW07.03) with ESMTP id l39InfvI003783 for ; Mon, 9 Apr 2007 11:49:41 -0700 X-Auth-Received: from [134.134.136.2] by hymn09.u.washington.edu via HTTP; Mon, 09 Apr 2007 11:49:41 PDT Date: Mon, 9 Apr 2007 11:49:41 -0700 (PDT) From: youshi10@u.washington.edu To: freebsd-hackers@freebsd.org In-Reply-To: <20070409152956.GB93087@dan.emsphone.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-PMX-Version: 5.3.0.289146, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.4.9.113833 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='NO_REAL_NAME 0, __CT 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0' Subject: Re: Discovering list of open files from "kernel level" without using utils like lsof 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: Mon, 09 Apr 2007 18:49:45 -0000 On Mon, 9 Apr 2007, Dan Nelson wrote: > In the last episode (Apr 08), Garrett Cooper said: >> I'm trying to see whether it's possible to grab the list of >> files open from a kernel level on FreeBSD, using a userland library >> interface as opposed to lsof. >> I'm trying to see if there's a simple tool that I could code in >> C/C++ if necessary to spin down disks automatically to save power and >> disk life. Plus, I think that lsof actually would probe the devices >> and 'wake them up' instead of keeping them as-is. However, I could be >> wrong so if I am please let me know. > > Take a look at how /usr/bin/fstat does it. There is apparently a > "kern.file" sysctl that holds the open file table, but fstat digs > through kernel memory. > > -- > Dan Nelson > dnelson@allantgroup.com Ok, excellent. Thanks for more info. I'm thinking of changing "spinning down" to "adjusting acoustics level", i.e. reduce spindle speed to avoid pricey spin-downs, which may cause long-term serious damage to disks. Trying to keep my electric bills down and keep my disk life up :). -Garrett