We should allow updating of discovery records, too.
This enables open-iscsi to use different settings during
discovery to different targets.

Signed-off-by: Hannes Reinecke <h...@suse.de>

diff --git a/usr/idbm.c b/usr/idbm.c
index ee38e64..ca5479e 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2097,6 +2097,35 @@ free_info:
        return rc;
 }
 
+int idbm_discovery_set_param(void *data, discovery_rec_t *rec)
+{
+       struct db_set_param *param = data;
+       recinfo_t *info;
+       int rc = 0;
+
+       info = idbm_recinfo_alloc(MAX_KEYS);
+       if (!info)
+               return ENOMEM;
+
+       idbm_recinfo_discovery((discovery_rec_t *)rec, info);
+
+       rc = idbm_verify_param(info, param->name);
+       if (rc)
+               goto free_info;
+
+       rc = idbm_rec_update_param(info, param->name, param->value, 0);
+       if (rc)
+               goto free_info;
+
+       rc = idbm_discovery_write((discovery_rec_t *)rec);
+       if (rc)
+               goto free_info;
+
+free_info:
+       free(info);
+       return rc;
+}
+
 int idbm_init(idbm_get_config_file_fn *fn)
 {
        /* make sure root db dir is there */
diff --git a/usr/idbm.h b/usr/idbm.h
index ed8badd..0609c47 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -139,6 +139,7 @@ extern int idbm_rec_read(node_rec_t *out_rec, char 
*target_name,
                         int tpgt, char *addr, int port,
                         struct iface_rec *iface);
 extern int idbm_node_set_param(void *data, node_rec_t *rec);
+extern int idbm_discovery_set_param(void *data, discovery_rec_t *rec);
 
 /* lower level idbm functions for use by iface.c */
 extern void idbm_recinfo_config(recinfo_t *info, FILE *f);
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 9d2ce71..c9f9a88 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1912,7 +1912,7 @@ main(int argc, char **argv)
                                   name, value);
                break;
        case MODE_DISCOVERY:
-               if ((rc = verify_mode_params(argc, argv, "SIPdmtplo", 0))) {
+               if ((rc = verify_mode_params(argc, argv, "SIPdmntplov", 0))) {
                        log_error("discovery mode: option '-%c' is not "
                                  "allowed/supported", rc);
                        rc = -1;
@@ -1991,6 +1991,19 @@ main(int argc, char **argv)
                                                           "record!");
                                                rc = -1;
                                        }
+                               } else if (op == OP_UPDATE) {
+                                       struct db_set_param set_param;
+
+                                       if (!name || !value) {
+                                               log_error("Update requires "
+                                                         "name and value");
+                                               rc = -1;
+                                               goto out;
+                                       }
+                                       set_param.name = name;
+                                       set_param.value = value;
+                                       if 
(idbm_discovery_set_param(&set_param, &drec))
+                                               rc = -1;
                                } else {
                                        log_error("operation is not 
supported.");
                                        rc = -1;

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to