iscsi-initiator-utils/iscsi-initiator-utils-fix-iface-op-ret-val.patch
2010-07-27 21:12:21 +00:00

75 lines
1.8 KiB
Diff

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index b7d11b5..fcf2a3a 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -465,7 +465,8 @@ static int iface_fn(void *data, node_rec_t *rec)
return op_data->fn(op_data->data, rec);
}
-static int for_each_rec(struct node_rec *rec, void *data, idbm_iface_op_fn *fn)
+static int __for_each_rec(int verbose, struct node_rec *rec,
+ void *data, idbm_iface_op_fn *fn)
{
struct rec_op_data op_data;
int nr_found = 0, rc;
@@ -477,16 +478,25 @@ static int for_each_rec(struct node_rec *rec, void *data, idbm_iface_op_fn *fn)
rc = idbm_for_each_rec(&nr_found, &op_data, iface_fn);
if (rc) {
- log_error("Could not execute operation on all "
- "records. Err %d.", rc);
+ if (verbose)
+ log_error("Could not execute operation on all "
+ "records. Err %d.", rc);
} else if (!nr_found) {
- log_error("no records found!");
+ if (verbose)
+ log_error("no records found!");
rc = ENODEV;
}
return rc;
}
+static int for_each_rec(struct node_rec *rec, void *data,
+ idbm_iface_op_fn *fn)
+{
+ return __for_each_rec(1, rec, data, fn);
+}
+
+
static int login_portals(struct node_rec *pattern_rec)
{
struct list_head rec_list;
@@ -1098,9 +1108,9 @@ new_fail:
}
/* logout and delete records using it first */
- rc = for_each_rec(rec, NULL, delete_node);
- if (rc)
- break;
+ rc = __for_each_rec(0, rec, NULL, delete_node);
+ if (rc && rc != ENODEV)
+ goto delete_fail;
rc = iface_conf_delete(iface);
if (rc)
@@ -1167,9 +1177,11 @@ delete_fail:
if (rc)
goto update_fail;
- rc = for_each_rec(rec, &set_param, idbm_node_set_param);
- if (rc)
- break;
+ rc = __for_each_rec(0, rec, &set_param, idbm_node_set_param);
+ if (rc == ENODEV)
+ rc = 0;
+ else if (rc)
+ goto update_fail;
printf("%s updated.\n", iface->name);
break;
--
1.6.6.1