summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorMichael Klein <michael.klein@puffin.lb.shuttle.de>2016-01-06 22:39:57 +0100
committerMichael Klein <michael.klein@puffin.lb.shuttle.de>2016-01-06 22:39:57 +0100
commitb10e54cdee3d964ae8c1962989bc9bc0e804f19b (patch)
tree1af98b120f75583459e83ff8c281fa348c30ff1c /linux
parentcc23d13f87e74d4dc2cc781da28ddc07f3860b63 (diff)
parentfc4c9757b01676e7cc16a50f04a3be25c00abbf0 (diff)
Merge remote-tracking branch 'upstream/master' into envscreen
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxCRT.c2
-rw-r--r--linux/LinuxProcessList.c32
-rw-r--r--linux/LinuxProcessList.h4
3 files changed, 23 insertions, 15 deletions
diff --git a/linux/LinuxCRT.c b/linux/LinuxCRT.c
index e0a12821..5b2a21fd 100644
--- a/linux/LinuxCRT.c
+++ b/linux/LinuxCRT.c
@@ -30,7 +30,7 @@ void CRT_handleSIGSEGV(int sgn) {
#endif
#else
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
- fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
+ fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
#endif
abort();
}
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index e939b4a9..9387dbd4 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -78,6 +78,10 @@ typedef struct LinuxProcessList_ {
#define PROCMEMINFOFILE PROCDIR "/meminfo"
#endif
+#ifndef PROC_LINE_LENGTH
+#define PROC_LINE_LENGTH 512
+#endif
+
}*/
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
@@ -90,11 +94,11 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
if (file == NULL) {
CRT_fatalError("Cannot open " PROCSTATFILE);
}
- char buffer[256];
+ char buffer[PROC_LINE_LENGTH + 1];
int cpus = -1;
do {
cpus++;
- char * s = fgets(buffer, 255, file);
+ char * s = fgets(buffer, PROC_LINE_LENGTH, file);
(void) s;
} while (String_startsWith(buffer, "cpu"));
fclose(file);
@@ -306,8 +310,8 @@ static bool LinuxProcessList_readStatmFile(LinuxProcess* process, const char* di
int fd = open(filename, O_RDONLY);
if (fd == -1)
return false;
- char buf[256];
- ssize_t rres = xread(fd, buf, 255);
+ char buf[PROC_LINE_LENGTH + 1];
+ ssize_t rres = xread(fd, buf, PROC_LINE_LENGTH);
close(fd);
if (rres < 1) return false;
@@ -361,13 +365,13 @@ static void LinuxProcessList_readCGroupFile(LinuxProcess* process, const char* d
process->cgroup = strdup("");
return;
}
- char output[256];
+ char output[PROC_LINE_LENGTH + 1];
output[0] = '\0';
char* at = output;
- int left = 255;
+ int left = PROC_LINE_LENGTH;
while (!feof(file) && left > 0) {
- char buffer[256];
- char *ok = fgets(buffer, 255, file);
+ char buffer[PROC_LINE_LENGTH + 1];
+ char *ok = fgets(buffer, PROC_LINE_LENGTH, file);
if (!ok) break;
char* group = strchr(buffer, ':');
if (!group) break;
@@ -394,9 +398,9 @@ static void LinuxProcessList_readVServerData(LinuxProcess* process, const char*
FILE* file = fopen(filename, "r");
if (!file)
return;
- char buffer[256];
+ char buffer[PROC_LINE_LENGTH + 1];
process->vxid = 0;
- while (fgets(buffer, 255, file)) {
+ while (fgets(buffer, PROC_LINE_LENGTH, file)) {
if (String_startsWith(buffer, "VxID:")) {
int vxid;
int ok = sscanf(buffer, "VxID:\t%32d", &vxid);
@@ -425,8 +429,8 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
FILE* file = fopen(filename, "r");
if (!file)
return;
- char buffer[256];
- if (fgets(buffer, 255, file)) {
+ char buffer[PROC_LINE_LENGTH + 1];
+ if (fgets(buffer, PROC_LINE_LENGTH, file)) {
unsigned int oom;
int ok = sscanf(buffer, "%32u", &oom);
if (ok >= 1) {
@@ -677,14 +681,14 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
int cpus = this->super.cpuCount;
assert(cpus > 0);
for (int i = 0; i <= cpus; i++) {
- char buffer[256];
+ char buffer[PROC_LINE_LENGTH + 1];
unsigned long long int usertime, nicetime, systemtime, idletime;
unsigned long long int ioWait, irq, softIrq, steal, guest, guestnice;
ioWait = irq = softIrq = steal = guest = guestnice = 0;
// Depending on your kernel version,
// 5, 7, 8 or 9 of these fields will be set.
// The rest will remain at zero.
- char* ok = fgets(buffer, 255, file);
+ char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
if (!ok) buffer[0] = '\0';
if (i == 0)
sscanf(buffer, "cpu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice);
diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h
index 538d98cb..2a4abff9 100644
--- a/linux/LinuxProcessList.h
+++ b/linux/LinuxProcessList.h
@@ -59,6 +59,10 @@ typedef struct LinuxProcessList_ {
#define PROCMEMINFOFILE PROCDIR "/meminfo"
#endif
+#ifndef PROC_LINE_LENGTH
+#define PROC_LINE_LENGTH 512
+#endif
+
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);

© 2014-2024 Faster IT GmbH | imprint | privacy policy