LOG_WARNING("ecs_hds_do_mount host token is empty.\n");
make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_FAIL, NULL);
return;
+ } else if (hds_is_host_path_used((const char*)host)) {
+ LOG_WARNING("host path '%s' is already taken.\n", host);
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_DUP_HOST_PATH, NULL);
+ return;
}
+
guest = strtok(NULL, token);
if (guest == NULL) {
LOG_WARNING("ecs_hds_do_mount guest token is empty.\n");
make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_FAIL, NULL);
return;
+ } else if (hds_is_guest_path_used((const char*)guest)) {
+ LOG_WARNING("guest path '%s' is already taken.\n", guest);
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_DUP_GUEST_PATH, NULL);
+ return;
}
level_token = strtok(NULL, token);
#define ECS_HDS_ACTION_STATE 99
enum hds_act_result {
+ //FIXME: numbering & ordering
ECS_HDS_ACT_GET_LIST = 0,
ECS_HDS_ACT_MOUNT_SUCCESS = 1,
ECS_HDS_ACT_MOUNT_FAIL = 2,
ECS_HDS_ACT_MOUNT_NOT_PERMITTED = 11,
ECS_HDS_ACT_MOUNT_NOT_VALID_PATH = 12,
+ ECS_HDS_ACT_MOUNT_DUP_HOST_PATH = 21,
+ ECS_HDS_ACT_MOUNT_DUP_GUEST_PATH = 22,
ECS_HDS_ACT_UMOUNT_SUCCESS = 3,
ECS_HDS_ACT_UMOUNT_FAIL = 4,
ECS_HDS_ACT_UMOUNT_DETACH_FAIL = 5,
list->attached = attached;
}
+bool hds_is_host_path_used(const char* path)
+{
+ hds_list *list, *next;
+
+ QTAILQ_FOREACH_SAFE(list, &lists, next, next)
+ {
+ if (!strcmp(list->host, path)) {
+ LOG_TRACE("found duplicated host path. id: %s\n", list->id);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool hds_is_guest_path_used(const char* path)
+{
+ hds_list *list, *next;
+
+ QTAILQ_FOREACH_SAFE(list, &lists, next, next)
+ {
+ if (!strcmp(list->guest, path)) {
+ LOG_TRACE("found duplicated guest path. id: %s\n", list->id);
+ return true;
+ }
+ }
+
+ return false;
+}
+
char* get_hds_lists(void)
{
hds_list *list, *next;
bool is_hds_attached(const char* id);
void set_hds_attached(const char* id, bool attached);
+bool hds_is_host_path_used(const char* path);
+bool hds_is_guest_path_used(const char* path);
+
char* get_hds_lists(void);
int hds_get_pci_available_slot_num(void);