FreeBSD: update ProcessList

This commit is contained in:
Christian Göttsche 2020-10-21 19:11:19 +02:00 committed by cgzones
parent c2fdfd99eb
commit 97ea45ca9a
2 changed files with 8 additions and 12 deletions

View File

@ -16,19 +16,19 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <sys/types.h>
#include <sys/user.h> #include <sys/user.h>
#include <unistd.h>
#include "CRT.h" #include "CRT.h"
#include "FreeBSDProcess.h" #include "FreeBSDProcess.h"
#include "Macros.h" #include "Macros.h"
#include "ProcessList.h" #include "ProcessList.h"
#include "XUtils.h"
#include "zfs/ZfsArcStats.h" #include "zfs/ZfsArcStats.h"
#include "zfs/openzfs_sysctl.h" #include "zfs/openzfs_sysctl.h"
#include "XUtils.h"
char jail_errmsg[JAIL_ERRMSGLEN]; char jail_errmsg[JAIL_ERRMSGLEN];
@ -383,7 +383,7 @@ err2:
} }
} }
char* FreeBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) { static char* FreeBSDProcessList_readProcessName(kvm_t* kd, const struct kinfo_proc* kproc, int* basenameEnd) {
char** argv = kvm_getargv(kd, kproc, 0); char** argv = kvm_getargv(kd, kproc, 0);
if (!argv) { if (!argv) {
return xStrdup(kproc->ki_comm); return xStrdup(kproc->ki_comm);
@ -408,7 +408,7 @@ char* FreeBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, in
return comm; return comm;
} }
char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc) { static char* FreeBSDProcessList_readJailName(const struct kinfo_proc* kproc) {
int jid; int jid;
struct iovec jiov[6]; struct iovec jiov[6];
char* jname; char* jname;
@ -419,7 +419,7 @@ char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc) {
IGNORE_WCASTQUAL_BEGIN IGNORE_WCASTQUAL_BEGIN
*(const void **)&jiov[0].iov_base = "jid"; *(const void **)&jiov[0].iov_base = "jid";
jiov[0].iov_len = sizeof("jid"); jiov[0].iov_len = sizeof("jid");
jiov[1].iov_base = &kproc->ki_jid; jiov[1].iov_base = (void*) &kproc->ki_jid;
jiov[1].iov_len = sizeof(kproc->ki_jid); jiov[1].iov_len = sizeof(kproc->ki_jid);
*(const void **)&jiov[2].iov_base = "name"; *(const void **)&jiov[2].iov_base = "name";
jiov[2].iov_len = sizeof("name"); jiov[2].iov_len = sizeof("name");

View File

@ -8,10 +8,10 @@ in the source distribution for its full text.
*/ */
#include <kvm.h> #include <kvm.h>
#include <sys/param.h> #include <sys/param.h> // needs to be included before <sys/jail.h> for MAXPATHLEN
#include <sys/jail.h> #include <sys/jail.h>
#include <sys/uio.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/uio.h>
#include "FreeBSDProcess.h" #include "FreeBSDProcess.h"
#include "Hashtable.h" #include "Hashtable.h"
@ -60,10 +60,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
void ProcessList_delete(ProcessList* this); void ProcessList_delete(ProcessList* this);
char* FreeBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd);
char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate); void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
#endif #endif