Don't allow to create targets with the same names

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3428 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2011-04-29 21:53:19 +00:00
parent 8443ae6bc7
commit 9dcac0d305

View File

@@ -473,7 +473,7 @@ EXPORT_SYMBOL(scst_unregister_target_template);
struct scst_tgt *scst_register_target(struct scst_tgt_template *vtt,
const char *target_name)
{
struct scst_tgt *tgt;
struct scst_tgt *tgt, *t;
int rc = 0;
TRACE_ENTRY();
@@ -527,6 +527,14 @@ struct scst_tgt *scst_register_target(struct scst_tgt_template *vtt,
if (rc != 0)
goto out_free_tgt;
list_for_each_entry(t, &vtt->tgt_list, tgt_list_entry) {
if (strcmp(t->tgt_name, tgt->tgt_name) == 0) {
PRINT_ERROR("target %s already exists", tgt->tgt_name);
rc = -EEXIST;
goto out_unlock;
}
}
#ifdef CONFIG_SCST_PROC
rc = scst_build_proc_target_entries(tgt);
if (rc < 0)