]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: move config_file argument into nvme_root
authorHannes Reinecke <hare@suse.de>
Fri, 7 May 2021 08:12:41 +0000 (10:12 +0200)
committerHannes Reinecke <hare@suse.de>
Fri, 11 Jun 2021 10:18:29 +0000 (12:18 +0200)
Store the config file in the nvme_root structure; that allows us
to call nvme_update_config() without having to specify the
configuration file.

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

index 38333e9712aa14a0455e19a0899b92454dc533bb..04c70742717f8c8935833c8f2ef33dc5b79930f5 100644 (file)
@@ -131,6 +131,7 @@ struct nvme_host {
 };
 
 struct nvme_root {
+       char *config_file;
        struct list_head hosts;
        bool modified;
 };
@@ -198,16 +199,18 @@ nvme_root_t nvme_scan(const char *config_file)
 {
        nvme_root_t r = nvme_scan_filter(NULL);
 
-       if (r && config_file)
+       if (r && config_file) {
                json_read_config(r, config_file);
+               r->config_file = strdup(config_file);
+       }
        return r;
 }
 
-int nvme_update_config(nvme_root_t r, const char *config_file)
+int nvme_update_config(nvme_root_t r)
 {
-       if (!r->modified)
+       if (!r->modified || !r->config_file)
                return 0;
-       return json_update_config(r, config_file);
+       return json_update_config(r, r->config_file);
 }
 
 nvme_host_t nvme_first_host(nvme_root_t r)
@@ -269,6 +272,8 @@ void nvme_free_tree(nvme_root_t r)
 
        nvme_for_each_host_safe(r, h, _h)
                nvme_free_host(h);
+       if (r->config_file)
+               free(r->config_file);
        free(r);
 }
 
index 8823254a09d31aa4f5714f6d496175c3d59a5289..53f53e3f2c21fc46179ea1c407d5137204a91fa1 100644 (file)
@@ -977,11 +977,10 @@ void nvme_reset_topology(nvme_root_t r);
 /**
  * nvme_update_config() -
  * @r:
- * @config_file:
  *
  * Return:
  */
-int nvme_update_config(nvme_root_t r, const char *config_file);
+int nvme_update_config(nvme_root_t r);
 
 /**
  * nvme_free_tree() -