]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: re-read 'state' attribute
authorHannes Reinecke <hare@suse.de>
Tue, 11 May 2021 15:59:20 +0000 (17:59 +0200)
committerHannes Reinecke <hare@suse.de>
Sat, 19 Jun 2021 11:36:53 +0000 (13:36 +0200)
The 'state' attribute might change at any time, so we need to update
it upon access.

Signed-off-by: Hannes Reinecke <hare@suse.de>
src/nvme/tree.c

index e118be529158972d26a8d168262d4d84ffdc5919..56cb733350436e9dc8a23f9372100a5d2007d706 100644 (file)
@@ -566,6 +566,11 @@ const char *nvme_ctrl_get_model(nvme_ctrl_t c)
 
 const char *nvme_ctrl_get_state(nvme_ctrl_t c)
 {
+       char *state = c->state;
+
+       c->state = nvme_get_ctrl_attr(c, "state");
+       if (state)
+               free(state);
        return c->state;
 }