From owner-freebsd-arch@FreeBSD.ORG Mon Mar 26 15:10:55 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0632106566B for ; Mon, 26 Mar 2012 15:10:55 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B531D8FC08 for ; Mon, 26 Mar 2012 15:10:55 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 6CC7546B09 for ; Mon, 26 Mar 2012 11:10:55 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 031A5B93B for ; Mon, 26 Mar 2012 11:10:55 -0400 (EDT) From: John Baldwin To: arch@freebsd.org Date: Mon, 26 Mar 2012 11:10:54 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201203261110.54527.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 26 Mar 2012 11:10:55 -0400 (EDT) Cc: Subject: [PATCH] Teach procstat/fstat about details of a shm_open() object X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2012 15:10:56 -0000 This patch changes the kernel to export a few details (mode, size, and path) of an object created via shm_open() to userland via the kinfo_file structure. It then updates fstat and procstat to parse these details. A few questions I had: 1) Rather than creating a new sub-structure in kinfo_file for shm objects, I just populate two of the fields in the existing kf_file. 2) For the non-path details I just ran fo_stat() on the shm and used the returned buffer. In hindsight, it seems it might have been nice to make kinfo_file just include a 'struct stat' and use fo_stat() to populate it for each fd. Would have reduced the need for some of the current type-specific logic I think. 3) I think we should probably change procstat to always try to print the path if it is set (so make the current VNODE|SHM, etc. case the "default" case). 4) I made fstat print out the pathname of the shm in the "MOUNT" field. Not sure how to document this sanely in the fstat manpage though. 5) I make anonymous objects created with SHM_ANON report a path of "SHM_ANON". They could just as easily report a path of "-" like an unlinked shm, I just made this different so I could tell them apart. However, perhaps that is too weird and they should report an empty path instead (like an unlinked shm or unlinked file). http://www.FreeBSD.org/~jhb/patches/shm_info.patch I did not bother doing this for in-kernel POSIX semaphores since they are deprecated. -- John Baldwin