DragonFlyBSD update

- move some functions to file scope
- drop unused global variable
This commit is contained in:
Christian Göttsche 2020-12-20 18:32:04 +01:00
parent 8db8b9edac
commit 9a86577cf2
4 changed files with 18 additions and 28 deletions

View File

@ -18,17 +18,6 @@ in the source distribution for its full text.
#include <sys/syscall.h>
const ProcessClass DragonFlyBSDProcess_class = {
.super = {
.extends = Class(Process),
.display = Process_display,
.delete = Process_delete,
.compare = Process_compare
},
.writeField = DragonFlyBSDProcess_writeField,
.compareByKey = DragonFlyBSDProcess_compareByKey
};
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
@ -73,11 +62,11 @@ void Process_delete(Object* cast) {
free(this);
}
void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
static void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
const DragonFlyBSDProcess* fp = (const DragonFlyBSDProcess*) this;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
size_t n = sizeof(buffer) - 1;
switch (field) {
// add Platform-specific fields here
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, (fp->kernel ? -1 : this->pid)); break;
@ -97,7 +86,7 @@ void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, Proces
RichString_appendWide(str, attr, buffer);
}
long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) {
static long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key) {
const DragonFlyBSDProcess* p1 = (const DragonFlyBSDProcess*)v1;
const DragonFlyBSDProcess* p2 = (const DragonFlyBSDProcess*)v2;
@ -121,3 +110,14 @@ bool Process_isThread(const Process* this) {
return (Process_isUserlandThread(this));
}
}
const ProcessClass DragonFlyBSDProcess_class = {
.super = {
.extends = Class(Process),
.display = Process_display,
.delete = Process_delete,
.compare = Process_compare
},
.writeField = DragonFlyBSDProcess_writeField,
.compareByKey = DragonFlyBSDProcess_compareByKey
};

View File

@ -28,10 +28,6 @@ Process* DragonFlyBSDProcess_new(const Settings* settings);
void Process_delete(Object* cast);
void DragonFlyBSDProcess_writeField(const Process* this, RichString* str, ProcessField field);
long DragonFlyBSDProcess_compareByKey(const Process* v1, const Process* v2, ProcessField key);
bool Process_isThread(const Process* this);
#endif

View File

@ -262,7 +262,7 @@ static inline void DragonFlyBSDProcessList_scanMemoryInfo(ProcessList* pl) {
pl->usedSwap *= pageSizeKb;
}
char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) {
static char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, const struct kinfo_proc* kproc, int* basenameEnd) {
char** argv = kvm_getargv(kd, kproc, 0);
if (!argv) {
return xStrdup(kproc->kp_comm);
@ -343,7 +343,7 @@ retry:
free(jls);
}
char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) {
static char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid) {
char* hostname;
char* jname;
@ -373,10 +373,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
int count = 0;
// TODO Kernel Threads seem to be skipped, need to figure out the correct flag
struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count);
const struct kinfo_proc* kprocs = kvm_getprocs(dfpl->kd, KERN_PROC_ALL | (!hideUserlandThreads ? KERN_PROC_FLAG_LWP : 0), 0, &count);
for (int i = 0; i < count; i++) {
struct kinfo_proc* kproc = &kprocs[i];
const struct kinfo_proc* kproc = &kprocs[i];
bool preExisting = false;
bool ATTR_UNUSED isIdleProcess = false;

View File

@ -17,8 +17,6 @@ in the source distribution for its full text.
#include "Hashtable.h"
#include "DragonFlyBSDProcess.h"
#define JAIL_ERRMSGLEN 1024
extern char jail_errmsg[JAIL_ERRMSGLEN];
typedef struct CPUData_ {
double userPercent;
@ -53,10 +51,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, ui
void ProcessList_delete(ProcessList* this);
char* DragonFlyBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd);
char* DragonFlyBSDProcessList_readJailName(DragonFlyBSDProcessList* dfpl, int jailid);
void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate);
#endif