From 2071e3510abcb0d23655e9ec6f21ded8a0d7fa8a Mon Sep 17 00:00:00 2001 From: benl Date: Sat, 18 Jun 2011 13:56:33 +0000 Subject: Fix clang warnings. Approved by: philip (mentor) --- lib/libprocstat/libprocstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libprocstat/libprocstat.c') diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 384fe73..e1bdfcd 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -1283,7 +1283,7 @@ vntype2psfsttype(int type) static char * getmnton(kvm_t *kd, struct mount *m) { - static struct mount mnt; + struct mount mnt; static struct mtab { struct mtab *next; struct mount *m; @@ -1302,7 +1302,7 @@ getmnton(kvm_t *kd, struct mount *m) err(1, NULL); mt->m = m; bcopy(&mnt.mnt_stat.f_mntonname[0], &mt->mntonname[0], MNAMELEN); - mnt.mnt_stat.f_mntonname[MNAMELEN] = '\0'; + mt->mntonname[MNAMELEN] = '\0'; mt->next = mhead; mhead = mt; return (mt->mntonname); -- cgit v1.1 From 73191046d378fbbe794ef2df066a9449de5db18e Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 18 Jun 2011 21:29:25 +0000 Subject: libprocstat: Correct format for size_t (should be %zu, not %zd). --- lib/libprocstat/libprocstat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libprocstat/libprocstat.c') diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index e1bdfcd..7ddc560 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -191,7 +191,7 @@ procstat_getprocs(struct procstat *procstat, int what, int arg, len = *count * sizeof(*p); p = malloc(len); if (p == NULL) { - warnx("malloc(%zd)", len); + warnx("malloc(%zu)", len); goto fail; } bcopy(p0, p, len); @@ -213,7 +213,7 @@ procstat_getprocs(struct procstat *procstat, int what, int arg, } p = malloc(len); if (p == NULL) { - warnx("malloc(%zd)", len); + warnx("malloc(%zu)", len); goto fail; } error = sysctl(name, 4, p, &len, NULL, 0); @@ -426,7 +426,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap nfiles = filed.fd_lastfile + 1; ofiles = malloc(nfiles * sizeof(struct file *)); if (ofiles == NULL) { - warn("malloc(%zd)", nfiles * sizeof(struct file *)); + warn("malloc(%zu)", nfiles * sizeof(struct file *)); goto do_mmapped; } if (!kvm_read_all(kd, (unsigned long)filed.fd_ofiles, ofiles, -- cgit v1.1 From fe5611be569005f5729498cc32cce3f64cc1020e Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 18 Jun 2011 21:46:11 +0000 Subject: libprocstat: Remove spaces between function name and open parenthesis. --- lib/libprocstat/libprocstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libprocstat/libprocstat.c') diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 7ddc560..f8e5516 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -271,11 +271,11 @@ procstat_freefiles(struct procstat *procstat, struct filestat_list *head) } free(head); if (procstat->vmentries != NULL) { - free (procstat->vmentries); + free(procstat->vmentries); procstat->vmentries = NULL; } if (procstat->files != NULL) { - free (procstat->files); + free(procstat->files); procstat->files = NULL; } } -- cgit v1.1 From 54b5af424bef2b3351d9b0327ba4ecf12a46a9a7 Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 18 Jun 2011 22:16:55 +0000 Subject: libprocstat: Fix typo in error messages. --- lib/libprocstat/libprocstat.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/libprocstat/libprocstat.c') diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index f8e5516..65e170d 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -229,7 +229,7 @@ procstat_getprocs(struct procstat *procstat, int what, int arg, *count = len / sizeof(*p); return (p); } else { - warnx("unknown access method"); + warnx("unknown access method: %d", procstat->type); return (NULL); } fail: @@ -726,7 +726,7 @@ procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst, } else if (procstat->type == PROCSTAT_SYSCTL) { return (procstat_get_pipe_info_sysctl(fst, ps, errbuf)); } else { - warnx("unknow access method: %d", procstat->type); + warnx("unknown access method: %d", procstat->type); snprintf(errbuf, _POSIX2_LINE_MAX, "error"); return (1); } @@ -790,7 +790,7 @@ procstat_get_pts_info(struct procstat *procstat, struct filestat *fst, } else if (procstat->type == PROCSTAT_SYSCTL) { return (procstat_get_pts_info_sysctl(fst, pts, errbuf)); } else { - warnx("unknow access method: %d", procstat->type); + warnx("unknown access method: %d", procstat->type); snprintf(errbuf, _POSIX2_LINE_MAX, "error"); return (1); } @@ -852,7 +852,7 @@ procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst, } else if (procstat->type == PROCSTAT_SYSCTL) { return (procstat_get_vnode_info_sysctl(fst, vn, errbuf)); } else { - warnx("unknow access method: %d", procstat->type); + warnx("unknown access method: %d", procstat->type); snprintf(errbuf, _POSIX2_LINE_MAX, "error"); return (1); } @@ -1059,7 +1059,7 @@ procstat_get_socket_info(struct procstat *procstat, struct filestat *fst, } else if (procstat->type == PROCSTAT_SYSCTL) { return (procstat_get_socket_info_sysctl(fst, sock, errbuf)); } else { - warnx("unknow access method: %d", procstat->type); + warnx("unknown access method: %d", procstat->type); snprintf(errbuf, _POSIX2_LINE_MAX, "error"); return (1); } -- cgit v1.1 From 2c34fd40cf9b5ba7ec3d068fc410a06bc897665b Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 18 Jun 2011 23:01:26 +0000 Subject: 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. --- lib/libprocstat/libprocstat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libprocstat/libprocstat.c') diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 65e170d..22ca668 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; -- cgit v1.1