From owner-svn-src-head@FreeBSD.ORG Sat Jun 18 23:01:26 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CA59106566C; Sat, 18 Jun 2011 23:01:26 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C1968FC0C; Sat, 18 Jun 2011 23:01:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5IN1Q82062310; Sat, 18 Jun 2011 23:01:26 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5IN1QQY062308; Sat, 18 Jun 2011 23:01:26 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201106182301.p5IN1QQY062308@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 18 Jun 2011 23:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223279 - head/lib/libprocstat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2011 23:01:26 -0000 Author: jilles Date: Sat Jun 18 23:01:26 2011 New Revision: 223279 URL: http://svn.freebsd.org/changeset/base/223279 Log: libprocstat: For MAP_PRIVATE, do not consider the file open for writing. If a file is mapped with with MAP_PRIVATE, no write permission is required and changes do not end up in the file. Therefore, tools like fuser and fstat should not show the file as open for writing. The protection as displayed by procstat -v still includes write in this case, and shows 'C' for copy-on-write. Modified: head/lib/libprocstat/libprocstat.c Modified: head/lib/libprocstat/libprocstat.c ============================================================================== --- head/lib/libprocstat/libprocstat.c Sat Jun 18 22:32:55 2011 (r223278) +++ head/lib/libprocstat/libprocstat.c Sat Jun 18 23:01:26 2011 (r223279) @@ -522,7 +522,8 @@ do_mmapped: fflags = 0; if (prot & VM_PROT_READ) fflags = PS_FST_FFLAG_READ; - if (prot & VM_PROT_WRITE) + if ((vmentry.eflags & MAP_ENTRY_COW) == 0 && + prot & VM_PROT_WRITE) fflags |= PS_FST_FFLAG_WRITE; /* @@ -696,7 +697,8 @@ procstat_getfiles_sysctl(struct procstat fflags = 0; if (kve->kve_protection & KVME_PROT_READ) fflags = PS_FST_FFLAG_READ; - if (kve->kve_protection & KVME_PROT_WRITE) + if ((kve->kve_flags & KVME_FLAG_COW) == 0 && + kve->kve_protection & KVME_PROT_WRITE) fflags |= PS_FST_FFLAG_WRITE; offset = kve->kve_offset; refcount = kve->kve_ref_count;