[PATCH] check for duplicate target name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



when creating a new target check for duplicate target name.

Signed-off-by: Doron Shoham <dorons@xxxxxxxxxxxx>
---
 usr/target.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/usr/target.c b/usr/target.c
index 32812d9..dc30c87 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -67,6 +67,15 @@ static struct target *target_lookup(int tid)
 	return NULL;
 }
 
+static int target_name_lookup(char *name)
+{
+	struct target *target;
+	list_for_each_entry(target, &target_list, target_siblings)
+		if (!strcmp(target->name, name))
+			return 1;
+	return 0;
+}
+
 static struct it_nexus *it_nexus_lookup(int tid, uint64_t itn_id)
 {
 	struct target *target;
@@ -1660,6 +1669,11 @@ int tgt_target_create(int lld, int tid, char *args)
 		return TGTADM_TARGET_EXIST;
 	}
 
+	if (target_name_lookup(targetname)) {
+		eprintf("Target name %s already exists\n", targetname);
+		return TGTADM_TARGET_EXIST;
+	}
+
 	bst = get_backingstore_template(tgt_drivers[lld]->default_bst);
 	if (!bst)
 		return TGTADM_INVALID_REQUEST;
-- 
1.5.3.8

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux