]> granicus.if.org Git - sysstat/commitdiff
iostat: Refresh device list properly
authorSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 22 Jan 2018 16:06:21 +0000 (17:06 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Mon, 22 Jan 2018 16:06:21 +0000 (17:06 +0100)
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 <robert@noreply.servermasters.com>
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
iostat.c

index 649a502351b0bcfe4a9e1ecd9b345641e6f14aa6..a1ec4f2624c0f5b3b9af589f1c86caffb3b8634d 100644 (file)
--- 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);