diff options
author | Hannes Reinecke <hare@suse.de> | 2009-09-30 10:56:28 +0200 |
---|---|---|
committer | Mike Christie <michaelc@cs.wisc.edu> | 2009-09-30 12:47:16 -0500 |
commit | 3bb88ea9be814a2f598cf6f1d1fcdbc2f57ff0a8 (patch) | |
tree | 2d341cc5383d3d9ba8a01e1d87a946ee6be75376 /usr | |
parent | daacde2927ff77b5dadcf0ef474b74644acd7b70 (diff) | |
download | open-iscsi-3bb88ea9be814a2f598cf6f1d1fcdbc2f57ff0a8.tar.gz |
Allow update of discovery records.
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 <hare@suse.de>
Diffstat (limited to 'usr')
-rw-r--r-- | usr/idbm.c | 29 | ||||
-rw-r--r-- | usr/idbm.h | 1 | ||||
-rw-r--r-- | usr/iscsiadm.c | 15 |
3 files changed, 44 insertions, 1 deletions
@@ -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 */ @@ -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; |