[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7
Mike Christie
michaelc at cs.wisc.edu
Sat Apr 7 15:44:15 UTC 2012
The following commit has been merged in the upstream-mnc branch:
commit eaed16d0f7ae246d885290ab19e8955fd20d498f
Author: Mike Christie <michaelc at cs.wisc.edu>
Date: Thu Mar 22 00:59:04 2012 -0400
iscsistart: have iscsistart use same multi param code as iscsiadm
This just has iscsistart use the same multi param argument
code as iscsiadm.
diff --git a/usr/idbm.c b/usr/idbm.c
index 6842820..971f1e4 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2354,38 +2354,6 @@ idbm_slp_defaults(struct iscsi_slp_config *cfg)
sizeof(struct iscsi_slp_config));
}
-int idbm_parse_param(char *param, struct node_rec *rec)
-{
- char *name, *value;
- recinfo_t *info;
- int rc;
-
- name = param;
-
- value = strchr(param, '=');
- if (!value) {
- log_error("Invalid --param %s. Missing setting.\n", param);
- return ISCSI_ERR_INVAL;
- }
- *value = '\0';
- value++;
-
- info = idbm_recinfo_alloc(MAX_KEYS);
- if (!info) {
- log_error("Could not allocate memory to setup params.\n");
- return ISCSI_ERR_NOMEM;
- }
-
- idbm_recinfo_node(rec, info);
-
- rc = idbm_rec_update_param(info, name, value, 0);
- if (rc)
- log_error("Could not set %s to %s. Check that %s is a "
- "valid parameter.\n", name, value, name);
- free(info);
- return rc;
-}
-
struct user_param *idbm_alloc_user_param(char *name, char *value)
{
struct user_param *param;
@@ -2413,23 +2381,28 @@ free_param:
return NULL;
}
-int idbm_node_set_param(void *data, node_rec_t *rec)
+int idbm_node_set_rec_from_param(struct list_head *params, node_rec_t *rec,
+ int verify)
{
- struct list_head *params = data;
struct user_param *param;
recinfo_t *info;
int rc = 0;
+ if (list_empty(params))
+ return 0;
+
info = idbm_recinfo_alloc(MAX_KEYS);
if (!info)
return ISCSI_ERR_NOMEM;
idbm_recinfo_node(rec, info);
- list_for_each_entry(param, params, list) {
- rc = idbm_verify_param(info, param->name);
- if (rc)
- goto free_info;
+ if (verify) {
+ list_for_each_entry(param, params, list) {
+ rc = idbm_verify_param(info, param->name);
+ if (rc)
+ goto free_info;
+ }
}
list_for_each_entry(param, params, list) {
@@ -2438,15 +2411,22 @@ int idbm_node_set_param(void *data, node_rec_t *rec)
goto free_info;
}
- rc = idbm_rec_write(rec);
- if (rc)
- goto free_info;
-
free_info:
free(info);
return rc;
}
+int idbm_node_set_param(void *data, node_rec_t *rec)
+{
+ int rc;
+
+ rc = idbm_node_set_rec_from_param(data, rec, 1);
+ if (rc)
+ return rc;
+
+ return idbm_rec_write(rec);
+}
+
int idbm_discovery_set_param(void *data, discovery_rec_t *rec)
{
struct list_head *params = data;
diff --git a/usr/idbm.h b/usr/idbm.h
index 7aee007..245f046 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -142,7 +142,8 @@ extern int idbm_discovery_read(discovery_rec_t *rec, int type, char *addr,
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_parse_param(char *param, struct node_rec *rec);
+extern int idbm_node_set_rec_from_param(struct list_head *params,
+ node_rec_t *rec, int verify);
extern int idbm_node_set_param(void *data, node_rec_t *rec);
extern int idbm_discovery_set_param(void *data, discovery_rec_t *rec);
struct user_param *idbm_alloc_user_param(char *name, char *value);
diff --git a/usr/iscsistart.c b/usr/iscsistart.c
index 6ab8d6b..1a3b579 100644
--- a/usr/iscsistart.c
+++ b/usr/iscsistart.c
@@ -58,11 +58,6 @@ static node_rec_t config_rec;
static LIST_HEAD(targets);
static LIST_HEAD(user_params);
-struct user_param {
- struct list_head list;
- char *param_string;
-};
-
static char program_name[] = "iscsistart";
/* used by initiator */
@@ -136,7 +131,6 @@ static int stop_event_loop(void)
static int apply_params(struct node_rec *rec)
{
- struct user_param *param;
int rc;
/* Must init this so we can check if user overrode them */
@@ -144,11 +138,9 @@ static int apply_params(struct node_rec *rec)
rec->conn[0].timeo.noop_out_interval = -1;
rec->conn[0].timeo.noop_out_timeout = -1;
- list_for_each_entry(param, &user_params, list) {
- rc = idbm_parse_param(param->param_string, rec);
- if (rc)
- return rc;
- }
+ rc = idbm_node_set_rec_from_param(&user_params, rec, 0);
+ if (rc)
+ return rc;
/*
* For root boot we could not change this in older versions so
@@ -167,23 +159,32 @@ static int apply_params(struct node_rec *rec)
return 0;
}
-static int alloc_param(char *param_string)
+static int parse_param(char *param_str)
{
struct user_param *param;
+ char *name, *value;
- param = calloc(1, sizeof(*param));
- if (!param) {
- printf("Could not allocate for param.\n");
- return ISCSI_ERR_NOMEM;
+ name = param_str;
+
+ value = strchr(param_str, '=');
+ if (!value) {
+ log_error("Invalid --param %s. Missing value.", param_str);
+ return ISCSI_ERR_INVAL;
+ }
+ *value = '\0';
+
+ value++;
+ if (!strlen(value)) {
+ log_error("Invalid --param %s. Missing value.", param_str);
+ return ISCSI_ERR_INVAL;
}
- INIT_LIST_HEAD(¶m->list);
- param->param_string = strdup(param_string);
- if (!param->param_string) {
- printf("Could not allocate for param.\n");
- free(param);
+ param = idbm_alloc_user_param(name, value);
+ if (!param) {
+ log_error("Could not allocate memory for param.");
return ISCSI_ERR_NOMEM;
}
+
list_add(¶m->list, &user_params);
return 0;
}
@@ -397,7 +398,7 @@ int main(int argc, char *argv[])
fw_free_targets(&targets);
exit(0);
case 'P':
- err = alloc_param(optarg);
+ err = parse_param(optarg);
if (err)
exit(err);
break;
--
Debian Open-iSCSI Packaging
More information about the Pkg-iscsi-maintainers
mailing list