From owner-freebsd-fs@FreeBSD.ORG Wed Feb 23 15:24:25 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4628106566B for ; Wed, 23 Feb 2011 15:24:25 +0000 (UTC) (envelope-from martin@lispworks.com) Received: from lwfs1-cam.cam.lispworks.com (mail.lispworks.com [193.34.186.230]) by mx1.freebsd.org (Postfix) with ESMTP id 7180E8FC12 for ; Wed, 23 Feb 2011 15:24:25 +0000 (UTC) Received: from higson.cam.lispworks.com (higson [192.168.1.7]) by lwfs1-cam.cam.lispworks.com (8.14.3/8.14.3) with ESMTP id p1NFDOcI021374; Wed, 23 Feb 2011 15:13:24 GMT (envelope-from martin@lispworks.com) Received: from higson.cam.lispworks.com (localhost.localdomain [127.0.0.1]) by higson.cam.lispworks.com (8.14.4) id p1NFDO4u031047; Wed, 23 Feb 2011 15:13:24 GMT Received: (from martin@localhost) by higson.cam.lispworks.com (8.14.4/8.14.4/Submit) id p1NFDOw4031044; Wed, 23 Feb 2011 15:13:24 GMT Date: Wed, 23 Feb 2011 15:13:24 GMT Message-Id: <201102231513.p1NFDOw4031044@higson.cam.lispworks.com> From: Martin Simmons To: freebsd-fs@freebsd.org In-reply-to: <20110222211444.GD78089@deviant.kiev.zoral.com.ua> (message from Kostik Belousov on Tue, 22 Feb 2011 23:14:44 +0200) References: <201102211707.p1LH7c8n075660@lurza.secnetix.de> <476667.58379.qm@web121516.mail.ne1.yahoo.com> <20110222095211.GA96223@icarus.home.lan> <201102220931.17733.jhb@freebsd.org> <20110222211444.GD78089@deviant.kiev.zoral.com.ua> Subject: Re: Why is procfs deprecated in favor of procstat? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2011 15:24:25 -0000 >>>>> On Tue, 22 Feb 2011 23:14:44 +0200, Kostik Belousov said: > > On Tue, Feb 22, 2011 at 01:10:57PM -0600, Bob Friesenhahn wrote: > > On Tue, 22 Feb 2011, John Baldwin wrote: > > > > > >Actually, the replacement for procfs is not sysctl, but ptrace(2), and > > >there > > > > I have been following this discussion with my jaw agape. It seems > > that the many men standing around this elephant are all perceiving > > completely different things based on their own interests and > > experiences. > > > > My own software is using procfs to efficiently determine the path to > > the currently running executable. I am sure that other software does > > the same since Linux procfs (and probably OS X) supports the same > > mechanism. It is difficult to imagine how this would be done via > > ptrace(2). > Look at the PT_VM_TIMESTAMP + PT_VM_ENTRY. You would iterate over > the the mappings in the address space and look at the binaries at > pve_path, if any. The one that is elf object f the ET_EXEC type > is the binary. It is somewhat clumsy but the end result is the same > as if reading /proc//file. > > Or, you use sysctl kern.proc.vmmap and get essentially the same data. > PT_VM_ENTRY was added long after the sysctl, I did not objected exactly > because ptrace(2) looked more logical. > > The advantage of using procfs or sysctl instead of ptrace(2) is that > you do not need to attach as debugger, causing the issues with signal > delivery for the debugee. Another advantage I find of (linux) procfs is that you always get a textual version of it, which can be useful in shell scripts and debugging situations. /sbin/sysctl kern.proc.vmmap isn't usable because the command has no way to specify the pid. /usr/bin/procstat gives access to only part of the procfs and sysctl namespace. __Martin