Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Jun 2011 23:01:26 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r223279 - head/lib/libprocstat
Message-ID:  <201106182301.p5IN1QQY062308@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106182301.p5IN1QQY062308>