aboutsummaryrefslogtreecommitdiff
path: root/lib/libprocstat/libprocstat.c
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2011-06-18 23:01:26 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2011-06-18 23:01:26 +0000
commit279a233d0ced525687e1289d88540d68fb207ace (patch)
tree7c00d02027dc5e6f7f889633ba3cc51cb0639dec /lib/libprocstat/libprocstat.c
parent7fc6a8aef660c6cc1c6a5b371cbda61b9cca46ec (diff)
downloadsrc-279a233d0ced525687e1289d88540d68fb207ace.tar.gz
src-279a233d0ced525687e1289d88540d68fb207ace.zip
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.
Notes
Notes: svn path=/head/; revision=223279
Diffstat (limited to 'lib/libprocstat/libprocstat.c')
-rw-r--r--lib/libprocstat/libprocstat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index 65e170de7280..22ca668e4b3a 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -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 *procstat, struct kinfo_proc *kp, int m
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;