From 141443c8130ea80f920f58df8f2f5642b934c29b Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Mon, 22 Jan 2018 17:06:21 +0100 Subject: [PATCH] iostat: Refresh device list properly When running iostat to monitor disk activity, disconnecting a USB drive from the system then reconnecting another one didn't make the new one appear on the list. This patch fixes the problem. Reported-by: Robert Hoffmann Signed-off-by: Sebastien GODARD --- iostat.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/iostat.c b/iostat.c index 649a502..a1ec4f2 100644 --- a/iostat.c +++ b/iostat.c @@ -463,6 +463,11 @@ void save_stats(char *name, int curr, void *st_io, int iodev_nr, st_hdr_iodev_i = st_hdr_iodev + i; if (st_hdr_iodev_i->status == DISK_UNREGISTERED) { st_hdr_iodev_i->status = DISK_REGISTERED; + if (st_hdr_iodev_i->used == FALSE) { + st_iodev_i = st_iodev[!curr] + i; + memset(st_iodev_i, 0, IO_STATS_SIZE); + st_hdr_iodev_i->used = TRUE; + } } st_iodev_i = st_iodev[curr] + i; *st_iodev_i = *((struct io_stats *) st_io); -- 2.40.0