Fredrik Fornwall
7 years ago
7 changed files with 136 additions and 130 deletions
@ -0,0 +1,33 @@ |
|||||
|
diff -u -r ../procps-ng-3.3.14/procio.c ./procio.c
|
||||
|
--- ../procps-ng-3.3.14/procio.c 2018-04-10 13:26:34.695269068 +0200
|
||||
|
+++ ./procio.c 2018-05-19 03:03:48.858822656 +0200
|
||||
|
@@ -46,6 +46,7 @@
|
||||
|
static ssize_t proc_write(void *, const char *, size_t); |
||||
|
static int proc_close(void *); |
||||
|
|
||||
|
+#ifndef __ANDROID__
|
||||
|
__extension__ |
||||
|
static cookie_io_functions_t procio = { |
||||
|
.read = proc_read, |
||||
|
@@ -53,9 +54,13 @@
|
||||
|
.seek = NULL, |
||||
|
.close = proc_close, |
||||
|
}; |
||||
|
+#endif
|
||||
|
|
||||
|
FILE *fprocopen(const char *path, const char *mode) |
||||
|
{ |
||||
|
+#ifdef __ANDROID__
|
||||
|
+ return fopen(path, mode);
|
||||
|
+#else
|
||||
|
pcookie_t *cookie = NULL; |
||||
|
FILE *handle = NULL; |
||||
|
mode_t flags = 0; |
||||
|
@@ -144,6 +149,7 @@
|
||||
|
} |
||||
|
out: |
||||
|
return handle; |
||||
|
+#endif
|
||||
|
} |
||||
|
|
||||
|
static |
@ -0,0 +1,59 @@ |
|||||
|
Ignore Permission denied in several places. |
||||
|
|
||||
|
On some Androids many of proc files can't actually be opened. So ignore |
||||
|
when opening fails and go on. |
||||
|
|
||||
|
diff -u -r ../procps-ng-3.3.14/top/top.c ./top/top.c
|
||||
|
--- ../procps-ng-3.3.14/top/top.c 2018-03-03 07:11:55.698869268 +0000
|
||||
|
+++ ./top/top.c 2018-05-19 00:20:58.203786150 +0000
|
||||
|
@@ -2558,7 +2558,7 @@
|
||||
|
(sorry Linux, but you'll have to close it for us) */ |
||||
|
if (!fp) { |
||||
|
if (!(fp = fopen("/proc/stat", "r"))) |
||||
|
- error_exit(fmtmk(N_fmt(FAIL_statopn_fmt), strerror(errno)));
|
||||
|
+ return;
|
||||
|
/* note: we allocate one more CPU_t via totSLOT than 'cpus' so that a |
||||
|
slot can hold tics representing the /proc/stat cpu summary */ |
||||
|
Cpu_tics = alloc_c(totSLOT * sizeof(CPU_t)); |
||||
|
@@ -4106,7 +4106,7 @@
|
||||
|
tmptty.c_cc[VERASE] = *key_backspace; |
||||
|
#ifdef TERMIOS_ONLY |
||||
|
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty)) |
||||
|
- error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
|
||||
|
+ {}
|
||||
|
tcgetattr(STDIN_FILENO, &Tty_tweaked); |
||||
|
#endif |
||||
|
// lastly, a nearly raw mode for unsolicited single keystrokes |
||||
|
@@ -4114,7 +4114,7 @@
|
||||
|
tmptty.c_cc[VMIN] = 1; |
||||
|
tmptty.c_cc[VTIME] = 0; |
||||
|
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty)) |
||||
|
- error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
|
||||
|
+ {}
|
||||
|
tcgetattr(STDIN_FILENO, &Tty_raw); |
||||
|
|
||||
|
#ifndef OFF_STDIOLBF |
||||
|
@@ -5444,7 +5444,7 @@
|
||||
|
|
||||
|
if (!Numa_node_tot) goto numa_nope; |
||||
|
|
||||
|
- if (CHKw(w, View_CPUNOD)) {
|
||||
|
+ if (Cpu_tics && CHKw(w, View_CPUNOD)) {
|
||||
|
if (Numa_node_sel < 0) { |
||||
|
// display the 1st /proc/stat line, then the nodes (if room) |
||||
|
summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_allcpus_txt)); |
||||
|
@@ -5479,12 +5479,12 @@
|
||||
|
} |
||||
|
} else |
||||
|
numa_nope: |
||||
|
- if (CHKw(w, View_CPUSUM)) {
|
||||
|
+ if (Cpu_tics && CHKw(w, View_CPUSUM)) {
|
||||
|
// display just the 1st /proc/stat line |
||||
|
summary_hlp(&Cpu_tics[Cpu_faux_tot], N_txt(WORD_allcpus_txt)); |
||||
|
Msg_row += 1; |
||||
|
|
||||
|
- } else {
|
||||
|
+ } else if (Cpu_tics) {
|
||||
|
// display each cpu's states separately, screen height permitting... |
||||
|
for (i = 0; i < Cpu_faux_tot; i++) { |
||||
|
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_tics[i].id); |
@ -1,92 +0,0 @@ |
|||||
Ignore Permission denied in several places. |
|
||||
|
|
||||
On some Androids many of proc files can't actually be opened. So ignore |
|
||||
when opening fails and go on. |
|
||||
|
|
||||
diff '--exclude=config.log' -ur src-orig/proc/sysinfo.c src/proc/sysinfo.c
|
|
||||
--- src-orig/proc/sysinfo.c 2017-08-26 23:22:50.704748922 +0200
|
|
||||
+++ src/proc/sysinfo.c 2017-08-27 00:08:52.482479053 +0200
|
|
||||
@@ -97,6 +97,10 @@
|
|
||||
char *savelocale; |
|
||||
#endif |
|
||||
|
|
||||
+ if (uptime_fd == -1 && (uptime_fd = open(UPTIME_FILE, O_RDONLY)) == -1) {
|
|
||||
+ return 0;
|
|
||||
+ }
|
|
||||
+
|
|
||||
FILE_TO_BUF(UPTIME_FILE,uptime_fd); |
|
||||
#ifndef __ANDROID__ |
|
||||
savelocale = strdup(setlocale(LC_NUMERIC, NULL)); |
|
||||
@@ -130,6 +136,7 @@
|
|
||||
/* /proc/stat can get very large on multi-CPU systems so we |
|
||||
can't use FILE_TO_BUF */ |
|
||||
if (!(f = fopen(STAT_FILE, "r"))) { |
|
||||
+ return 0;
|
|
||||
fputs(BAD_OPEN_MESSAGE, stderr); |
|
||||
fflush(NULL); |
|
||||
_exit(102); |
|
||||
@@ -389,6 +401,10 @@
|
|
||||
char *savelocale; |
|
||||
#endif |
|
||||
|
|
||||
+ if (loadavg_fd == -1 && (loadavg_fd = open(LOADAVG_FILE, O_RDONLY)) == -1) {
|
|
||||
+ return;
|
|
||||
+ }
|
|
||||
+
|
|
||||
FILE_TO_BUF(LOADAVG_FILE,loadavg_fd); |
|
||||
#ifndef __ANDROID__ |
|
||||
savelocale = strdup(setlocale(LC_NUMERIC, NULL)); |
|
||||
diff '--exclude=config.log' -ur src-orig/top/top.c src/top/top.c
|
|
||||
--- src-orig/top/top.c 2017-08-26 23:22:50.708748956 +0200
|
|
||||
+++ src/top/top.c 2017-08-27 00:13:34.416643298 +0200
|
|
||||
@@ -2379,7 +2379,7 @@
|
|
||||
(sorry Linux, but you'll have to close it for us) */ |
|
||||
if (!fp) { |
|
||||
if (!(fp = fopen("/proc/stat", "r"))) |
|
||||
- error_exit(fmtmk(N_fmt(FAIL_statopn_fmt), strerror(errno)));
|
|
||||
+ return NULL;
|
|
||||
/* note: we allocate one more CPU_t via totSLOT than 'cpus' so that a |
|
||||
slot can hold tics representing the /proc/stat cpu summary */ |
|
||||
cpus = alloc_c(totSLOT * sizeof(CPU_t)); |
|
||||
@@ -3814,7 +3814,7 @@
|
|
||||
tmptty.c_cc[VERASE] = *key_backspace; |
|
||||
#ifdef TERMIOS_ONLY |
|
||||
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty)) |
|
||||
- error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
|
|
||||
+ {}
|
|
||||
tcgetattr(STDIN_FILENO, &Tty_tweaked); |
|
||||
#endif |
|
||||
// lastly, a nearly raw mode for unsolicited single keystrokes |
|
||||
@@ -3822,7 +3822,7 @@
|
|
||||
tmptty.c_cc[VMIN] = 1; |
|
||||
tmptty.c_cc[VTIME] = 0; |
|
||||
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty)) |
|
||||
- error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
|
|
||||
+ {}
|
|
||||
tcgetattr(STDIN_FILENO, &Tty_raw); |
|
||||
|
|
||||
#ifndef OFF_STDIOLBF |
|
||||
@@ -5155,7 +5155,7 @@
|
|
||||
#ifndef NUMA_DISABLE |
|
||||
if (!Numa_node_tot) goto numa_nope; |
|
||||
|
|
||||
- if (CHKw(w, View_CPUNOD)) {
|
|
||||
+ if (smpcpu && CHKw(w, View_CPUNOD)) {
|
|
||||
if (Numa_node_sel < 0) { |
|
||||
// display the 1st /proc/stat line, then the nodes (if room) |
|
||||
summary_hlp(&smpcpu[smp_num_cpus], N_txt(WORD_allcpus_txt)); |
|
||||
@@ -5191,12 +5191,12 @@
|
|
||||
} else |
|
||||
numa_nope: |
|
||||
#endif |
|
||||
- if (CHKw(w, View_CPUSUM)) {
|
|
||||
+ if (smpcpu && CHKw(w, View_CPUSUM)) {
|
|
||||
// display just the 1st /proc/stat line |
|
||||
summary_hlp(&smpcpu[Cpu_faux_tot], N_txt(WORD_allcpus_txt)); |
|
||||
Msg_row += 1; |
|
||||
|
|
||||
- } else {
|
|
||||
+ } else if (smpcpu) {
|
|
||||
// display each cpu's states separately, screen height permitting... |
|
||||
for (i = 0; i < Cpu_faux_tot; i++) { |
|
||||
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id); |
|
Loading…
Reference in new issue