diff options
author | Nathan Scott <nathans@redhat.com> | 2020-08-20 14:19:53 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2020-08-20 14:19:53 +1000 |
commit | a82fd262d75f8494c34416e49c6241c29692676e (patch) | |
tree | 5c4ff9b8a872ca06e8e200a034099c736da1e160 /linux | |
parent | cdff8aea2ab10870af1aad5bdb6949ea0fd407b0 (diff) | |
parent | 63fbc3b51704b4b122d2cab57de7e7f9dfcc03b1 (diff) |
Merge branch 'hishamhm-pull-960'
Diffstat (limited to 'linux')
-rw-r--r-- | linux/Battery.c | 7 | ||||
-rw-r--r-- | linux/IOPriority.c | 2 | ||||
-rw-r--r-- | linux/IOPriority.h | 2 | ||||
-rw-r--r-- | linux/LinuxProcess.c | 4 | ||||
-rw-r--r-- | linux/LinuxProcess.h | 2 | ||||
-rw-r--r-- | linux/LinuxProcessList.c | 38 | ||||
-rw-r--r-- | linux/LinuxProcessList.h | 6 |
7 files changed, 30 insertions, 31 deletions
diff --git a/linux/Battery.c b/linux/Battery.c index 029eff59..7a1c8163 100644 --- a/linux/Battery.c +++ b/linux/Battery.c @@ -78,7 +78,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short const unsigned long int foundNum = atoi(foundNumStr); free(foundNumStr); free(line); - + total += foundNum; } @@ -175,7 +175,7 @@ static inline ssize_t xread(int fd, void *buf, size_t count) { } static void Battery_getSysData(double* level, ACPresence* isOnAC) { - + *level = 0; *isOnAC = AC_ERROR; @@ -205,7 +205,6 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { continue; if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') { - xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName); int fd = open(filePath, O_RDONLY); if (fd == -1) { @@ -258,7 +257,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { if (*isOnAC != AC_ERROR) { continue; } - + xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName); int fd = open(filePath, O_RDONLY); if (fd == -1) { diff --git a/linux/IOPriority.c b/linux/IOPriority.c index dd7c84a1..80007df0 100644 --- a/linux/IOPriority.c +++ b/linux/IOPriority.c @@ -4,7 +4,7 @@ htop - IOPriority.c Released under the GNU GPL, see the COPYING file in the source distribution for its full text. -Based on ionice, +Based on ionice, Copyright (C) 2005 Jens Axboe <jens@axboe.dk> Released under the terms of the GNU General Public License version 2 */ diff --git a/linux/IOPriority.h b/linux/IOPriority.h index 148e344c..1c9ca95b 100644 --- a/linux/IOPriority.h +++ b/linux/IOPriority.h @@ -8,7 +8,7 @@ htop - IOPriority.h Released under the GNU GPL, see the COPYING file in the source distribution for its full text. -Based on ionice, +Based on ionice, Copyright (C) 2005 Jens Axboe <jens@axboe.dk> Released under the terms of the GNU General Public License version 2 */ diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 70c3b5d1..50b4d220 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -125,7 +125,7 @@ typedef struct LinuxProcess_ { unsigned long long io_write_bytes; unsigned long long io_cancelled_write_bytes; unsigned long long io_rate_read_time; - unsigned long long io_rate_write_time; + unsigned long long io_rate_write_time; double io_rate_read_bps; double io_rate_write_bps; #endif @@ -409,7 +409,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) attr = CRT_colors[PROCESS_HIGH_PRIORITY]; xSnprintf(buffer, n, "R%1d ", IOPriority_data(lp->ioPriority)); } else if (klass == IOPRIO_CLASS_IDLE) { - attr = CRT_colors[PROCESS_LOW_PRIORITY]; + attr = CRT_colors[PROCESS_LOW_PRIORITY]; xSnprintf(buffer, n, "id "); } else { xSnprintf(buffer, n, "?? "); diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 44ae91c1..1e47ba28 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -116,7 +116,7 @@ typedef struct LinuxProcess_ { unsigned long long io_write_bytes; unsigned long long io_cancelled_write_bytes; unsigned long long io_rate_read_time; - unsigned long long io_rate_write_time; + unsigned long long io_rate_write_time; double io_rate_read_bps; double io_rate_write_bps; #endif diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index c6ab4807..7717d5a4 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -61,7 +61,7 @@ typedef struct CPUData_ { unsigned long long int softIrqTime; unsigned long long int stealTime; unsigned long long int guestTime; - + unsigned long long int totalPeriod; unsigned long long int userPeriod; unsigned long long int systemPeriod; @@ -85,11 +85,11 @@ typedef struct TtyDriver_ { typedef struct LinuxProcessList_ { ProcessList super; - + CPUData* cpus; TtyDriver* ttyDrivers; bool haveSmapsRollup; - + #ifdef HAVE_DELAYACCT struct nl_sock *netlink_socket; int netlink_family; @@ -328,7 +328,7 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname, location += 2; char *end = strrchr(location, ')'); if (!end) return false; - + int commsize = end - location; memcpy(command, location, commsize); command[commsize] = '\0'; @@ -379,9 +379,9 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname, location += 1; assert(location != NULL); process->processor = strtol(location, &location, 10); - + process->time = lp->utime + lp->stime; - + return true; } @@ -421,7 +421,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna process->io_rate_write_time = -1LL; return; } - + char buffer[1024]; ssize_t buflen = xread(fd, buffer, 1023); close(fd); @@ -438,7 +438,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna process->io_rchar = strtoull(line+7, NULL, 10); else if (strncmp(line+1, "ead_bytes: ", 11) == 0) { process->io_read_bytes = strtoull(line+12, NULL, 10); - process->io_rate_read_bps = + process->io_rate_read_bps = ((double)(process->io_read_bytes - last_read))/(((double)(now - process->io_rate_read_time))/1000); process->io_rate_read_time = now; } @@ -448,7 +448,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna process->io_wchar = strtoull(line+7, NULL, 10); else if (strncmp(line+1, "rite_bytes: ", 12) == 0) { process->io_write_bytes = strtoull(line+13, NULL, 10); - process->io_rate_write_bps = + process->io_rate_write_bps = ((double)(process->io_write_bytes - last_write))/(((double)(now - process->io_rate_write_time))/1000); process->io_rate_write_time = now; } @@ -726,7 +726,7 @@ static void LinuxProcessList_readDelayAcctData(LinuxProcessList* this, LinuxProc process->cpu_delay_percent = -1LL; return; } - + if (nl_recvmsgs_default(this->netlink_socket) < 0) { return; } @@ -750,11 +750,11 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna int fd = open(filename, O_RDONLY); if (fd == -1) return false; - + char command[4096+1]; // max cmdline length on Linux int amtRead = xread(fd, command, sizeof(command) - 1); close(fd); - int tokenEnd = 0; + int tokenEnd = 0; int lastChar = 0; if (amtRead == 0) { ((LinuxProcess*)process)->isKernelThread = true; @@ -791,13 +791,13 @@ static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned in i++; if ((!ttyDrivers[i].path) || maj < ttyDrivers[i].major) { break; - } + } if (maj > ttyDrivers[i].major) { continue; } if (min < ttyDrivers[i].minorFrom) { break; - } + } if (min > ttyDrivers[i].minorTo) { continue; } @@ -855,17 +855,17 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* // filename is a number: process directory int pid = atoi(name); - + if (parent && pid == parent->pid) continue; - if (pid <= 0) + if (pid <= 0) continue; bool preExisting = false; Process* proc = ProcessList_getProcess(pl, pid, &preExisting, (Process_New) LinuxProcess_new); proc->tgid = parent ? parent->pid : pid; - + LinuxProcess* lp = (LinuxProcess*) proc; char subdirname[MAX_NAME+1]; @@ -926,7 +926,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* LinuxProcessList_readOpenVZData(lp, dirname, name); } #endif - + #ifdef HAVE_VSERVER if (settings->flags & PROCESS_FLAG_LINUX_VSERVER) { LinuxProcessList_readVServerData(lp, dirname, name); @@ -954,7 +954,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* if (settings->flags & PROCESS_FLAG_LINUX_CGROUP) LinuxProcessList_readCGroupFile(lp, dirname, name); #endif - + if (settings->flags & PROCESS_FLAG_LINUX_OOM) LinuxProcessList_readOomData(lp, dirname, name); diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index 850f5733..4e0acc80 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -34,7 +34,7 @@ typedef struct CPUData_ { unsigned long long int softIrqTime; unsigned long long int stealTime; unsigned long long int guestTime; - + unsigned long long int totalPeriod; unsigned long long int userPeriod; unsigned long long int systemPeriod; @@ -58,11 +58,11 @@ typedef struct TtyDriver_ { typedef struct LinuxProcessList_ { ProcessList super; - + CPUData* cpus; TtyDriver* ttyDrivers; bool haveSmapsRollup; - + #ifdef HAVE_DELAYACCT struct nl_sock *netlink_socket; int netlink_family; |