Ensure that generated USN is unique

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4471 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2012-08-24 02:15:04 +00:00
parent 5b26b06791
commit 19153e3a65

View File

@@ -4139,11 +4139,12 @@ out:
return res;
}
/* scst_vdisk_mutex supposed to be held */
static int vdev_create(struct scst_dev_type *devt,
const char *name, struct scst_vdisk_dev **res_virt_dev)
{
int res;
struct scst_vdisk_dev *virt_dev;
struct scst_vdisk_dev *virt_dev, *vv;
uint64_t dev_id_num;
res = -EEXIST;
@@ -4185,6 +4186,15 @@ static int vdev_create(struct scst_dev_type *devt,
scnprintf(virt_dev->usn, sizeof(virt_dev->usn), "%llx", dev_id_num);
TRACE_DBG("usn %s", virt_dev->usn);
list_for_each_entry(vv, &vdev_list, vdev_list_entry) {
if (strcmp(virt_dev->usn, vv->usn) == 0) {
PRINT_ERROR("New usn %s conflicts with one of dev %s",
virt_dev->usn, vv->name);
res = -EEXIST;
goto out_free;
}
}
*res_virt_dev = virt_dev;
res = 0;