From: Sebastien GODARD Date: Mon, 22 Jan 2018 16:06:21 +0000 (+0100) Subject: iostat: Refresh device list properly X-Git-Tag: v11.7.2~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=141443c8130ea80f920f58df8f2f5642b934c29b;p=sysstat 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 --- 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);