Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
f098db3e56
!58 Fix the iotop crash caused by non-UTF-8 characters
From: @lv_1245 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-12-17 07:03:51 +00:00
lvyy
965ee5b226 Fix the iotop crash caused by non-UTF-8 characters 2024-12-17 06:27:44 +00:00
openeuler-ci-bot
4adb4f7b75
!51 Fix crash when hide UI elements on smaller terminals
From: @lv_1245 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-12-05 02:46:24 +00:00
lvyy
5fd646070b Hide UI elements on smaller terminals 2024-12-05 02:24:58 +00:00
openeuler-ci-bot
1a6c45b714
!28 add loongarch64 support
From: @cenhuilin 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-07-22 08:15:25 +00:00
cenhuilin
e62cebb84f add loongarch64 support 2024-07-02 17:12:25 +08:00
openeuler-ci-bot
93859b126b
!12 [sync] PR-11: [sync] PR-8: Sync each branch submit
From: @openeuler-sync-bot 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-03-22 07:31:53 +00:00
chenyanpanHW
a037b2ccc9 delete -S git from %autosetup, and delete BuildRequires git
(cherry picked from commit bf2519eb6d8e7a0fbe213233fa11ce108e163e4c)
(cherry picked from commit c0a2e0c7daca939e2d530e91951b64c4d0ee3c21)
2022-03-22 10:46:34 +08:00
Zhiqiang Liu
218c6cf948 iotop: backport some bugfix patches
iotop: backport some bugfix patches

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
(cherry picked from commit c34f53122701d6820d851c1cfbfeb1d338e7073d)
(cherry picked from commit 00d7df66ec022d90a4dc7408aac5bbfb870921ee)
2022-03-22 10:46:34 +08:00
Wu Bo
6d2bacb7da rebuild iotop
(cherry picked from commit 07f54ea2f3b17a2188f1f84c22c13dbbf24e0306)
(cherry picked from commit 43cd081c6cc28650c15ed5fed7f08082edc16f1e)
2022-03-22 10:46:34 +08:00
20 changed files with 718 additions and 63 deletions

View File

@ -1,9 +0,0 @@
diff -ru iotop-0.6.orign/sbin/iotop iotop-0.6/sbin/iotop
--- iotop-0.6.orign/sbin/iotop 2013-05-27 00:44:18.000000000 +0200
+++ iotop-0.6/sbin/iotop 2015-11-15 22:47:24.468058681 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# iotop: Display I/O usage of processes in a top like UI
# Copyright (c) 2007, 2008 Guillaume Chazarain <guichaz@gmail.com>, GPLv2
# See iotop --help for some help

View File

@ -0,0 +1,47 @@
From 7d6b10b118a8164ef8a924a0c131b2a062349fd3 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Sun, 29 Apr 2018 11:40:58 +0800
Subject: [PATCH 01/11] Switch from python to python3
Python 2 will be EOL in 2020 so Python 3 is preferrable.
See-also: https://pythonclock.org/
---
iotop.py | 2 +-
sbin/iotop | 2 +-
setup.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/iotop.py b/iotop.py
index 13ed873..666c6b4 100755
--- a/iotop.py
+++ b/iotop.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# iotop: Display I/O usage of processes in a top like UI
# Copyright (c) 2007, 2008 Guillaume Chazarain <guichaz@gmail.com>
# GPL version 2 or later
diff --git a/sbin/iotop b/sbin/iotop
index c5202d3..bb23a6e 100755
--- a/sbin/iotop
+++ b/sbin/iotop
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# iotop: Display I/O usage of processes in a top like UI
# Copyright (c) 2007, 2008 Guillaume Chazarain <guichaz@gmail.com>, GPLv2
# See iotop --help for some help
diff --git a/setup.py b/setup.py
index cd639ca..c63a36e 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from distutils.core import setup
from distutils.command import install as distutils_install
--
1.8.3.1

View File

@ -1,7 +1,7 @@
From 99c8d7cedce81f17b851954d94bfa73787300599 Mon Sep 17 00:00:00 2001
From 435bbde65bd10aa2ecbd352f46bb7f0abddc2189 Mon Sep 17 00:00:00 2001
From: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
Date: Fri, 17 Oct 2014 13:49:31 +0200
Subject: [PATCH] Fix build error with Python 3 caused by itervalues() in
Subject: [PATCH 02/11] Fix build error with Python 3 caused by itervalues() in
setup.py
The itervalues() method is not available in Python 3. As a
@ -15,7 +15,7 @@ Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 7150102..9de6068 100755
index c63a36e..a73423d 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ from iotop.version import VERSION
@ -26,7 +26,7 @@ index 7150102..9de6068 100755
+ for d in distutils_install.INSTALL_SCHEMES.values():
if d.get('scripts', '').endswith('/bin'):
d['scripts'] = d['scripts'][:-len('/bin')] + '/sbin'
--
2.4.10.GIT
--
1.8.3.1

View File

@ -1,18 +0,0 @@
diff -up iotop-0.6/iotop/data.py.splitline iotop-0.6/iotop/data.py
--- iotop-0.6/iotop/data.py.splitline 2013-05-27 00:44:18.000000000 +0200
+++ iotop-0.6/iotop/data.py 2018-07-09 16:08:04.135771959 +0200
@@ -193,7 +193,13 @@ def parse_proc_pid_status(pid):
result_dict = {}
try:
for line in open('/proc/%d/status' % pid):
- key, value = line.split(':\t', 1)
+ try:
+ key, value = line.split(':', 1)
+ except ValueError:
+ # Ignore lines that are not formatted correctly as
+ # some downstream kernels may have weird lines and
+ # the needed fields are probably formatted correctly.
+ continue
result_dict[key] = value.strip()
except IOError:
pass # No such process

View File

@ -0,0 +1,31 @@
From 961bd1671afbf501251119cdd7c02ce8cdaa7446 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 28 Jul 2016 13:25:54 +0800
Subject: [PATCH 03/11] Only split /proc/*/status lines on the : character.
Apparently vserver kernels have some lines that don't
appear to have the tab character so iotop crashes.
The tab character will be stripped by the next code line.
Closes: https://bugs.gentoo.org/show_bug.cgi?id=458556
---
iotop/data.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/iotop/data.py b/iotop/data.py
index 25b659e..bf2e7b5 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -193,7 +193,7 @@ def parse_proc_pid_status(pid):
result_dict = {}
try:
for line in open('/proc/%d/status' % pid):
- key, value = line.split(':\t', 1)
+ key, value = line.split(':', 1)
result_dict[key] = value.strip()
except IOError:
pass # No such process
--
1.8.3.1

View File

@ -0,0 +1,64 @@
From bd9396b2003a57077d2e7ca0b4b510537a24075c Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Fri, 25 May 2018 15:13:26 +0800
Subject: [PATCH 04/11] Ignore invalid lines in /proc/*/status files
One Ubuntu Linux kernel security fix introduced a blank line.
Some other Linux kernels may have invalid lines in the future.
See-also: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1772671
Fixes: https://bugs.launchpad.net/ubuntu/+source/iotop/+bug/1772856
Reported-by: Paul Jaros <jaros.paul@gmail.com>
Reported-in: <CAEh_nc0_DXTmfu16PxmVyrCi6QQeSrpnGGhtfNu60wJYfa_6Zw@mail.gmail.com>
Traceback (most recent call last):
File "/usr/sbin/iotop", line 17, in <module>
main()
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 620, in main
main_loop()
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 610, in <lambda>
main_loop = lambda: run_iotop(options)
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 508, in run_iotop
return curses.wrapper(run_iotop_window, options)
File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
return func(stdscr, *args, **kwds)
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 501, in run_iotop_window
ui.run()
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 155, in run
self.process_list.duration)
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 434, in refresh_display
lines = self.get_data()
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 415, in get_data
return list(map(format, processes))
File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 388, in format
cmdline = p.get_cmdline()
File "/usr/lib/python2.7/dist-packages/iotop/data.py", line 292, in get_cmdline
proc_status = parse_proc_pid_status(self.pid)
File "/usr/lib/python2.7/dist-packages/iotop/data.py", line 196, in parse_proc_pid_status
key, value = line.split(':\t', 1)
ValueError: need more than 1 value to unpack
---
iotop/data.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/iotop/data.py b/iotop/data.py
index bf2e7b5..62626c3 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -193,7 +193,13 @@ def parse_proc_pid_status(pid):
result_dict = {}
try:
for line in open('/proc/%d/status' % pid):
- key, value = line.split(':', 1)
+ try:
+ key, value = line.split(':', 1)
+ except ValueError:
+ # Ignore lines that are not formatted correctly as
+ # some downstream kernels may have weird lines and
+ # the needed fields are probably formatted correctly.
+ pass
result_dict[key] = value.strip()
except IOError:
pass # No such process
--
1.8.3.1

View File

@ -1,19 +0,0 @@
diff -urN iotop-0.6.orig/iotop/ioprio.py iotop-0.6/iotop/ioprio.py
--- iotop-0.6.orig/iotop/ioprio.py 2013-05-27 00:44:18.000000003 +0200
+++ iotop-0.6/iotop/ioprio.py 2018-08-01 15:12:59.460788725 +0200
@@ -27,6 +27,7 @@
# 'x86_64' but it will use the i386 syscall number, that's why we consider both
# the architecture name and the word size.
IOPRIO_GET_ARCH_SYSCALL = [
+ ('aarch64', '*', 31),
('alpha', '*', 443),
('arm*', '*', 315),
('i*86', '*', 290),
@@ -41,6 +42,7 @@
]
IOPRIO_SET_ARCH_SYSCALL = [
+ ('aarch64', '*', 30),
('alpha', '*', 442),
('arm*', '*', 314),
('i*86', '*', 289),

View File

@ -0,0 +1,28 @@
From a196e5a7f4c0cb694597a5c354ec12e6b262e570 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Fri, 25 May 2018 15:20:44 +0800
Subject: [PATCH 05/11] Actually skip invalid lines in /proc/*/status
Actually skip invalid lines in /proc/*/status
Fixes: commit 0392b205b5c3973a326721c2e9f97f0fa2eefa82
---
iotop/data.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/iotop/data.py b/iotop/data.py
index 62626c3..8378e51 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -199,7 +199,7 @@ def parse_proc_pid_status(pid):
# Ignore lines that are not formatted correctly as
# some downstream kernels may have weird lines and
# the needed fields are probably formatted correctly.
- pass
+ continue
result_dict[key] = value.strip()
except IOError:
pass # No such process
--
1.8.3.1

View File

@ -1,6 +1,19 @@
diff -up iotop-0.6/iotop/ioprio.py.ppcprio iotop-0.6/iotop/ioprio.py
--- iotop-0.6/iotop/ioprio.py.ppcprio 2018-08-02 15:17:46.523099123 +0200
+++ iotop-0.6/iotop/ioprio.py 2018-08-02 15:19:45.671660952 +0200
From 745505381aec4bef1b71201c3ea702efd3851320 Mon Sep 17 00:00:00 2001
From: Wangjia <wangjia55@huawei.com>
Date: Sun, 12 Jul 2020 14:31:46 +0800
Subject: [PATCH 06/11] replace powerpc with ppc in ioprio.py
replace powerpc with ppc in ioprio.py
Signed-off-by: Wangjia <wangjia55@huawei.com>
---
iotop/ioprio.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/iotop/ioprio.py b/iotop/ioprio.py
index 85957fd..a624795 100644
--- a/iotop/ioprio.py
+++ b/iotop/ioprio.py
@@ -32,7 +32,7 @@ IOPRIO_GET_ARCH_SYSCALL = [
('i*86', '*', 290),
('ia64*', '*', 1275),
@ -19,3 +32,6 @@ diff -up iotop-0.6/iotop/ioprio.py.ppcprio iotop-0.6/iotop/ioprio.py
('s390*', '*', 282),
('sparc*', '*', 196),
('sh*', '*', 288),
--
1.8.3.1

View File

@ -0,0 +1,35 @@
From 15285f0c2ed214fc5ae75edc6389d864e6b2e615 Mon Sep 17 00:00:00 2001
From: wangjia <wangjia55@huawei.com>
Date: Sun, 12 Jul 2020 14:34:13 +0800
Subject: [PATCH 07/11] add aarch64 prio in ioprio.py
add aarch64 prio in ioprio.py
Signed-off-by: wangjia <wangjia55@huawei.com>
---
iotop/ioprio.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/iotop/ioprio.py b/iotop/ioprio.py
index a624795..d292add 100644
--- a/iotop/ioprio.py
+++ b/iotop/ioprio.py
@@ -27,6 +27,7 @@ import platform
# 'x86_64' but it will use the i386 syscall number, that's why we consider both
# the architecture name and the word size.
IOPRIO_GET_ARCH_SYSCALL = [
+ ('aarch64', '*', 31),
('alpha', '*', 443),
('arm*', '*', 315),
('i*86', '*', 290),
@@ -41,6 +42,7 @@ IOPRIO_GET_ARCH_SYSCALL = [
]
IOPRIO_SET_ARCH_SYSCALL = [
+ ('aarch64', '*', 30),
('alpha', '*', 442),
('arm*', '*', 314),
('i*86', '*', 289),
--
1.8.3.1

View File

@ -0,0 +1,54 @@
From 8b0d74472fccdff449bf83d7624df0867df83344 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 4 Aug 2016 17:28:57 +0800
Subject: [PATCH 08/11] Print the titles at specific locations
Prevents a crash in a 3-line terminal:
Traceback (most recent call last):
File "./iotop.py", line 12, in <module>
main()
File "./iotop/ui.py", line 652, in main
main_loop()
File "./iotop/ui.py", line 642, in <lambda>
main_loop = lambda: run_iotop(options)
File "./iotop/ui.py", line 537, in run_iotop
return curses.wrapper(run_iotop_window, options)
File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
return func(stdscr, *args, **kwds)
File "./iotop/ui.py", line 529, in run_iotop_window
ui.run()
File "./iotop/ui.py", line 176, in run
self.process_list.duration)
File "./iotop/ui.py", line 492, in refresh_display
self.win.addstr(title, attr)
_curses.error: addstr() returned ERR
---
iotop/ui.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/iotop/ui.py b/iotop/ui.py
index e033c92..848c42b 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -452,6 +452,7 @@ class IOTopUI(object):
self.win.addstr(i, 0, s[:self.width])
self.win.hline(len(summary), 0, ord(' ') | curses.A_REVERSE,
self.width)
+ pos = 0
remaining_cols = self.width
for i in range(len(titles)):
attr = curses.A_REVERSE
@@ -463,7 +464,8 @@ class IOTopUI(object):
title += self.sorting_reverse and '>' or '<'
title = title[:remaining_cols]
remaining_cols -= len(title)
- self.win.addstr(title, attr)
+ self.win.addstr(len(summary), pos, title, attr)
+ pos += len(title)
if Stats.has_blkio_delay_total:
status_msg = None
else:
--
1.8.3.1

View File

@ -0,0 +1,62 @@
From f079550490496eb1008fe73620ab5db3bd4a99a8 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 3 May 2018 11:06:09 +0800
Subject: [PATCH 09/11] Improve the message that is printed when Linux
taskstats are not found
Usually this means that iotop is being run in a container.
The Linux kernel doesn't support taskstats outside the host net namespace.
There was a patch that looks like it may fix this but it never got merged.
Traceback (most recent call last):
File "/usr/sbin/iotop", line 17, in <module>
main()
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 737, in main
main_loop()
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 727, in <lambda>
main_loop = lambda: run_iotop(options)
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 618, in run_iotop
return run_iotop_window(None, options)
File "/usr/lib/python3/dist-packages/iotop/ui.py", line 609, in run_iotop_window
taskstats_connection = TaskStatsNetlink(options)
File "/usr/lib/python3/dist-packages/iotop/data.py", line 151, in __init__
self.family_id = controller.get_family_id('TASKSTATS')
File "/usr/lib/python3/dist-packages/iotop/genetlink.py", line 76, in get_family_id
m = GeNlMessage.recv(self.conn)
File "/usr/lib/python3/dist-packages/iotop/genetlink.py", line 56, in recv
msg = conn.recv()
File "/usr/lib/python3/dist-packages/iotop/netlink.py", line 255, in recv
raise err
OSError: Netlink error: No such file or directory (2)
See-also: https://blog.outlyer.com/using-netlink-to-calculate-load-averages
See-also: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg924689.html
See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1290691
See-also: https://bugs.openvz.org/browse/OVZ-5655
---
iotop/ui.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/iotop/ui.py b/iotop/ui.py
index 848c42b..328dafe 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -520,6 +520,15 @@ configure sudo to allow you to run iotop as root.
Please do not file bugs on iotop about this.''', file=sys.stderr)
sys.exit(1)
+ if e.errno == errno.ENOENT:
+ print(e, file=sys.stderr)
+ print('''
+The Linux kernel interfaces that iotop relies on for process I/O statistics
+were not found. Please enable CONFIG_TASKSTATS in your Linux kernel build
+configuration, use iotop outside a container and or share the host's
+network namespace with the container.
+
+Please do not file bugs on iotop about this.''', file=sys.stderr
else:
raise
--
1.8.3.1

View File

@ -0,0 +1,34 @@
From cfdcabc05f75fbc5680608ef9c27069aa75077f6 Mon Sep 17 00:00:00 2001
From: Paul Jaros <jaros.paul@gmail.com>
Date: Thu, 24 May 2018 18:47:00 +0800
Subject: [PATCH 10/11] Fix crash due to syntax error
Traceback (most recent call last):
File "./iotop.py", line 9, in <module>
from iotop.ui import main
File "./iotop/ui.py", line 642
else:
^
SyntaxError: invalid syntax
Reported-in: <CAEh_nc0_DXTmfu16PxmVyrCi6QQeSrpnGGhtfNu60wJYfa_6Zw@mail.gmail.com>
---
iotop/ui.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/iotop/ui.py b/iotop/ui.py
index 328dafe..40e9a40 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -528,7 +528,7 @@ were not found. Please enable CONFIG_TASKSTATS in your Linux kernel build
configuration, use iotop outside a container and or share the host's
network namespace with the container.
-Please do not file bugs on iotop about this.''', file=sys.stderr
+Please do not file bugs on iotop about this.''', file=sys.stderr)
else:
raise
--
1.8.3.1

View File

@ -0,0 +1,61 @@
From a535dc4f25f65379bf81f947307d92eee1618e54 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 4 May 2017 21:23:22 +0800
Subject: [PATCH 11/11] Use monotonic time to calculate durations
Prevents incorrect calculations when the system time is set backwards.
Reported-by: Andrei Costin <zveriu@gmail.com>
Fixes: https://bugs.launchpad.net/bugs/1685512
---
iotop/data.py | 6 +++---
iotop/ui.py | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/iotop/data.py b/iotop/data.py
index 8378e51..befa9c7 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -248,7 +248,7 @@ class ProcessInfo(DumpableObject):
self.threads = {} # {tid: ThreadInfo}
self.stats_delta = Stats.build_all_zero()
self.stats_accum = Stats.build_all_zero()
- self.stats_accum_timestamp = time.time()
+ self.stats_accum_timestamp = time.monotonic()
def is_monitored(self, options):
if (options.pids and not options.processes and
@@ -373,7 +373,7 @@ class ProcessList(DumpableObject):
self.processes = {}
self.taskstats_connection = taskstats_connection
self.options = options
- self.timestamp = time.time()
+ self.timestamp = time.monotonic()
self.vmstat = vmstat.VmStat()
# A first time as we are interested in the delta
@@ -423,7 +423,7 @@ class ProcessList(DumpableObject):
return tids
def update_process_counts(self):
- new_timestamp = time.time()
+ new_timestamp = time.monotonic()
self.duration = new_timestamp - self.timestamp
self.timestamp = new_timestamp
diff --git a/iotop/ui.py b/iotop/ui.py
index 40e9a40..abd6b79 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -70,7 +70,7 @@ def format_stats(options, process, duration):
if options.accumulated:
stats = process.stats_accum
display_format = lambda size, duration: format_size(options, size)
- duration = time.time() - process.stats_accum_timestamp
+ duration = time.monotonic() - process.stats_accum_timestamp
else:
stats = process.stats_delta
display_format = lambda size, duration: format_bandwidth(
--
1.8.3.1

View File

@ -0,0 +1,33 @@
From 932711b0c43030068f60d6fc1e1ae3d1aca76777 Mon Sep 17 00:00:00 2001
From: cenhuilin <cenhuilin@kylinos.cn>
Date: Tue, 2 Jul 2024 17:09:13 +0800
Subject: [PATCH] loongarch64: add loongarch64 support
Signed-off-by: cenhuilin <cenhuilin@kylinos.cn>
---
iotop/ioprio.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/iotop/ioprio.py b/iotop/ioprio.py
index d292add..e6176f1 100644
--- a/iotop/ioprio.py
+++ b/iotop/ioprio.py
@@ -27,6 +27,7 @@ import platform
# 'x86_64' but it will use the i386 syscall number, that's why we consider both
# the architecture name and the word size.
IOPRIO_GET_ARCH_SYSCALL = [
+ ('loongarch64', '*', 31),
('aarch64', '*', 31),
('alpha', '*', 443),
('arm*', '*', 315),
@@ -42,6 +43,7 @@ IOPRIO_GET_ARCH_SYSCALL = [
]
IOPRIO_SET_ARCH_SYSCALL = [
+ ('loongarch64', '*', 30),
('aarch64', '*', 30),
('alpha', '*', 442),
('arm*', '*', 314),
--
2.33.0

View File

@ -0,0 +1,89 @@
From 16a30ece6ab4eaa9ca5d056ada94673265195e27 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 4 Aug 2016 18:00:29 +0800
Subject: [PATCH] Hide UI elements on smaller terminals
This helps usability on smaller terminals.
Hide the status bar first, then the summary and then the titles,
since that is the approximate order of usefulness.
Conflict: Adapt patch Context
Reference: https://repo.or.cz/iotop.git/commit/16a30ece6ab4eaa9ca5d056ada94673265195e27
---
iotop/ui.py | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/iotop/ui.py b/iotop/ui.py
index abd6b79..5a53ad6 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -410,8 +410,6 @@ class IOTopUI(object):
stats_lambda = lambda p: p.stats_delta
processes.sort(key=lambda p: key(p, stats_lambda(p)),
reverse=self.sorting_reverse)
- if not self.options.batch:
- del processes[self.height - 2:]
return list(map(format, processes))
def refresh_display(self, first_time, total, actual, duration):
@@ -448,10 +446,33 @@ class IOTopUI(object):
sys.stdout.flush()
else:
self.win.erase()
+
+ if Stats.has_blkio_delay_total:
+ status_msg = None
+ else:
+ status_msg = ('CONFIG_TASK_DELAY_ACCT not enabled in kernel, '
+ 'cannot determine SWAPIN and IO %')
+
+ len_summary = len(summary)
+ len_titles = int(bool(titles))
+ len_status_msg = int(bool(status_msg))
+ max_lines = self.height - len_summary - len_titles - len_status_msg
+ if max_lines < 5:
+ titles = []
+ len_titles = 0
+ if max_lines < 6:
+ summary = []
+ len_summary = 0
+ if max_lines < 7:
+ status_msg = None
+ len_status_msg = 0
+ max_lines = self.height - len_summary - len_titles - len_status_msg
+ num_lines = min(len(lines), max_lines)
+
for i, s in enumerate(summary):
self.win.addstr(i, 0, s[:self.width])
- self.win.hline(len(summary), 0, ord(' ') | curses.A_REVERSE,
- self.width)
+ if titles:
+ self.win.hline(len_summary, 0, ord(' ') | curses.A_REVERSE, self.width)
pos = 0
remaining_cols = self.width
for i in range(len(titles)):
@@ -464,18 +485,12 @@ class IOTopUI(object):
title += self.sorting_reverse and '>' or '<'
title = title[:remaining_cols]
remaining_cols -= len(title)
- self.win.addstr(len(summary), pos, title, attr)
+ self.win.addstr(len_summary, pos, title, attr)
pos += len(title)
- if Stats.has_blkio_delay_total:
- status_msg = None
- else:
- status_msg = ('CONFIG_TASK_DELAY_ACCT not enabled in kernel, '
- 'cannot determine SWAPIN and IO %')
- num_lines = min(len(lines), self.height - 2 - int(bool(status_msg)))
for i in range(num_lines):
try:
def print_line(line):
- self.win.addstr(i + len(summary) + 1, 0, line)
+ self.win.addstr(i + len_summary + len_titles, 0, line)
try:
print_line(lines[i])
except UnicodeEncodeError:
--
2.33.0

View File

@ -0,0 +1,49 @@
From 529a74a28be43c04840d937c87a5ee3b81133852 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 4 Aug 2016 18:24:46 +0800
Subject: [PATCH] Check the column title is not empty before using it
Fixes crash with terminals that don't fit all titles.
Traceback (most recent call last):
File "./iotop.py", line 12, in <module>
main()
File "./iotop/ui.py", line 669, in main
main_loop()
File "./iotop/ui.py", line 659, in <lambda>
main_loop = lambda: run_iotop(options)
File "./iotop/ui.py", line 554, in run_iotop
return curses.wrapper(run_iotop_window, options)
File "/usr/lib/python3.5/curses/__init__.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
File "./iotop/ui.py", line 546, in run_iotop_window
ui.run()
File "./iotop/ui.py", line 176, in run
self.process_list.duration)
File "./iotop/ui.py", line 515, in refresh_display
self.win.addstr(len_summary, pos, title, attr)
_curses.error: addwstr() returned ERR
Conflict: NA
Reference: https://repo.or.cz/iotop.git/commit/529a74a28be43c04840d937c87a5ee3b81133852
---
iotop/ui.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/iotop/ui.py b/iotop/ui.py
index 30efa73..a957bdd 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -511,7 +511,8 @@ class IOTopUI(object):
title += self.sorting_reverse and '>' or '<'
title = title[:remaining_cols]
remaining_cols -= len(title)
- self.win.addstr(len_summary, pos, title, attr)
+ if title:
+ self.win.addstr(len_summary, pos, title, attr)
pos += len(title)
for i in range(num_lines):
try:
--
2.33.0

View File

@ -0,0 +1,40 @@
From 443737ec620a699286b9b2e44dbcaac53f553812 Mon Sep 17 00:00:00 2001
From: Yanichkin Alexander <Alexander_Sergey@mail.ru>
Date: Fri, 8 Oct 2021 09:25:31 +0800
Subject: [PATCH] Workaround crashes due to non-UTF-8 characters in process
command-lines
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use the Python feature of replacing non-UTF-8 characters
with the U+FFFD REPLACEMENT CHARACTER (<28>).
This is only a workaround, a more useful action would be to guess the
encoding using chardet or similar and coerce the bytes into Unicode.
Fixes: https://bugs.launchpad.net/ubuntu/+source/iotop/+bug/1932523
Fixes: https://bugs.debian.org/737043
Conflict: NA
Reference: https://repo.or.cz/iotop.git/commit/443737ec620a699286b9b2e44dbcaac53f553812
---
iotop/data.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/iotop/data.py b/iotop/data.py
index 5d70e29..f5496d0 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -207,7 +207,7 @@ def find_uids(options):
def parse_proc_pid_status(pid):
result_dict = {}
try:
- for line in open('/proc/%d/status' % pid):
+ for line in open('/proc/%d/status' % pid, errors='replace'):
try:
key, value = line.split(':', 1)
except ValueError:
--
2.33.0

View File

@ -0,0 +1,32 @@
From 4b2e1aa2464cfc4a29c9565c9e143b52ef8e4848 Mon Sep 17 00:00:00 2001
From: Dominique Martinet <dominique.martinet@atmark-techno.com>
Date: Mon, 3 Apr 2023 18:09:29 +0900
Subject: [PATCH] data.py get_cmdline: use errors=replace for unicode errors
/proc/pid/cmdline is user-controlled and not necessarily valid unicode,
just replace bogus characters like already done for /proc/pid/status.
See-also: commit 443737ec620a699286b9b2e44dbcaac53f553812
Conflict: NA
Reference: https://repo.or.cz/iotop.git/commit/4b2e1aa2464cfc4a29c9565c9e143b52ef8e4848
---
iotop/data.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/iotop/data.py b/iotop/data.py
index f5496d0..8c1acae 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -307,7 +307,7 @@ class ProcessInfo(DumpableObject):
def get_cmdline(self):
# A process may exec, so we must always reread its cmdline
try:
- proc_cmdline = open('/proc/%d/cmdline' % self.pid)
+ proc_cmdline = open('/proc/%d/cmdline' % self.pid, errors='replace')
cmdline = proc_cmdline.read(4096)
except IOError:
return '{no such process}'
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: iotop
Version: 0.6
Release: 21
Release: 26
Summary: Simple top-like I/O monitor
License: GPLv2+
URL: http://guichaz.free.fr/iotop/
@ -8,13 +8,24 @@ URL: http://guichaz.free.fr/iotop/
Source0: http://guichaz.free.fr/iotop/files/%{name}-%{version}.tar.bz2
BuildArch: noarch
BuildRequires: python3-devel git
BuildRequires: python3-devel
Patch0000: 0000-iotop-0.6-python3.patch
Patch0001: 0001-iotop-python3build.patch
Patch0002: 0002-iotop-0.6-splitline.patch
Patch0003: 0003-iotop-0.3.2-ppcprio.patch
Patch0004: 0004-iotop-0.6-aarch64prio.patch
Patch1: 0001-Switch-from-python-to-python3.patch
Patch2: 0002-Fix-build-error-with-Python-3-caused-by-itervalues-i.patch
Patch3: 0003-Only-split-proc-status-lines-on-the-character.patch
Patch4: 0004-Ignore-invalid-lines-in-proc-status-files.patch
Patch5: 0005-Actually-skip-invalid-lines-in-proc-status.patch
Patch6: 0006-replace-powerpc-with-ppc-in-ioprio.py.patch
Patch7: 0007-add-aarch64-prio-in-ioprio.py.patch
Patch8: 0008-Print-the-titles-at-specific-locations.patch
Patch9: 0009-Improve-the-message-that-is-printed-when-Linux-tasks.patch
Patch10: 0010-Fix-crash-due-to-syntax-error.patch
Patch11: 0011-Use-monotonic-time-to-calculate-durations.patch
Patch12: 0012-loongarch64-add-loongarch64-support.patch
Patch13: 0013-Hide-UI-elements-on-smaller-terminals.patch
Patch14: 0014-Check-the-column-title-is-not-empty-before-using-it.patch
Patch15: 0015-Workaround-crashes-due-to-non-UTF-8-characters-in-pr.patch
Patch16: 0016-data.py-get_cmdline-use-errors-replace-for-unicode-e.patch
%description
iotop watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and
@ -34,7 +45,7 @@ Requires: man
This contains man files for the using of iotop
%prep
%autosetup -n %{name}-%{version} -p1 -S git
%autosetup -n %{name}-%{version} -p1
%build
%py3_build
@ -52,6 +63,21 @@ This contains man files for the using of iotop
%{_mandir}/man8/iotop.*
%changelog
* Tue Dec 17 2024 lvyy <lyunmail@163.com> - 0.6-26
- Fix the iotop crash caused by non-UTF-8 characters
* Thu Dec 5 2024 lvyy <lyunmail@163.com> - 0.6-25
- Fix crash when hide UI elements on smaller terminals
* Tue Jul 2 2024 cenhuilin <cenhuilin@kylinos.cn> - 0.6-24
- loongarch64: add loongarch64 support
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 0.6-23
- DESC: delete -S git from %autosetup, and delete BuildRequires git
* Sun Jul 12 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 0.6-22
- backport some bugfix patches
* Wed Jul 1 2020 Wu Bo <wubo009@163.com> - 0.6-21
- rebuild package