summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2013-04-20 07:58:20 +0000
committertrociny <trociny@FreeBSD.org>2013-04-20 07:58:20 +0000
commitaa81fb93633764124c74da7a38b7d2b9bdfda651 (patch)
tree7dc2090ea86281285d03ec56e2cefb6aa5957b18 /usr.bin
parent4ca5694006e8d330e2b4a960e40fa851768f4958 (diff)
downloadFreeBSD-src-aa81fb93633764124c74da7a38b7d2b9bdfda651.zip
FreeBSD-src-aa81fb93633764124c74da7a38b7d2b9bdfda651.tar.gz
Use procstat_getumask(3) for retrieving umaks information instead of
direct sysctl. MFC after: 1 month
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/procstat/procstat_cred.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/usr.bin/procstat/procstat_cred.c b/usr.bin/procstat/procstat_cred.c
index c294868..f9a2241 100644
--- a/usr.bin/procstat/procstat_cred.c
+++ b/usr.bin/procstat/procstat_cred.c
@@ -38,7 +38,8 @@
#include "procstat.h"
-static const char *get_umask(struct kinfo_proc *kipp);
+static const char *get_umask(struct procstat *procstat,
+ struct kinfo_proc *kipp);
void
procstat_cred(struct procstat *procstat, struct kinfo_proc *kipp)
@@ -59,7 +60,7 @@ procstat_cred(struct procstat *procstat, struct kinfo_proc *kipp)
printf("%5d ", kipp->ki_groups[0]);
printf("%5d ", kipp->ki_rgid);
printf("%5d ", kipp->ki_svgid);
- printf("%5s ", get_umask(kipp));
+ printf("%5s ", get_umask(procstat, kipp));
printf("%s", kipp->ki_cr_flags & CRED_FLAG_CAPMODE ? "C" : "-");
printf(" ");
@@ -84,21 +85,12 @@ procstat_cred(struct procstat *procstat, struct kinfo_proc *kipp)
}
static const char *
-get_umask(struct kinfo_proc *kipp)
+get_umask(struct procstat *procstat, struct kinfo_proc *kipp)
{
- int error;
- int mib[4];
- size_t len;
u_short fd_cmask;
static char umask[4];
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_UMASK;
- mib[3] = kipp->ki_pid;
- len = sizeof(fd_cmask);
- error = sysctl(mib, 4, &fd_cmask, &len, NULL, 0);
- if (error == 0) {
+ if (procstat_getumask(procstat, kipp, &fd_cmask) == 0) {
snprintf(umask, 4, "%03o", fd_cmask);
return (umask);
} else {
OpenPOWER on IntegriCloud