A user can mount and unmount freely with ECP UI and ECP CLI.
However, certain directories, such as IDE workspaces, are
not allowed to unmount it for normal usage. So, ECP CLI with
special arguments sets unmodifiable level.
The level is used 1 for unmodifiable and 0 for normal usage.
Change-Id: Ic8c35e27193fa54e5acc508a5700f6fb342b6960
Signed-off-by: Jinhyung Choi <jinh0.choi@samsung.com>
obj-y += ecs_mon.o ecs-json-streamer.o
obj-y += ecs_eventcast.o
obj-y += ecs_sensor.o
+obj-y += ecs_hds.o
obj-y += ecs_nfc.o
obj-y += ecs_sdcard.o
#define MSG_TYPE_PACKAGE "package"
#define MSG_GROUP_STATUS 15
-#define MSG_GROUP_HDS 100
-
-#define HDS_ACTION_MOUNT 1
-#define HDS_ACTION_UMOUNT 2
enum message_action {
MSG_ACT_BATTERY_LEVEL = 100,
--- /dev/null
+/*
+ * Emulator Control Server - HDS
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Jinhyung choi <jinh0.choi@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include <string.h>
+
+#include "qemu-common.h"
+#include "fsdev/qemu-fsdev.h"
+
+#include "emul_state.h"
+#include "ecs_hds.h"
+#include "util/hds.h"
+#include "util/device_hotplug.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(qemu, hds);
+
+static void ecs_hds_do_status(char* cmd, type_group group)
+{
+ char* data = get_hds_lists();
+ LOG_INFO("hds status: %s\n", data);
+ make_send_device_ntf(cmd, group, ECS_HDS_ACTION_STATE, data);
+}
+
+static void ecs_hds_do_mount(char* cmd, type_group group, char *data)
+{
+ char token[] = "\n";
+ char* host;
+ char* level_token;
+ char* hds_id;
+ char* guest;
+ int level = 0;
+
+ if (data == NULL) {
+ LOG_WARNING("ecs_hds_do_mount data is empty.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_FAIL, NULL);
+ return;
+ }
+
+ host = strtok(data, token);
+ if (host == NULL) {
+ LOG_WARNING("ecs_hds_do_mount host token is empty.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_FAIL, 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;
+ }
+
+ level_token = strtok(NULL, token);
+ if (level_token != NULL) {
+ level = atoi(level_token);
+ }
+
+ hds_id = new_hds_list(host, guest, level);
+ if (hds_id != NULL) {
+ LOG_INFO("do attach tag: %s, host: %s, guest: %s, level: %d\n", hds_id, host, guest, level);
+ do_hotplug(ATTACH_HDS, hds_id, strlen(hds_id) + 1);
+ } else {
+ LOG_WARNING("ecs_hds_do_mount hds_id is empty.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_MOUNT_FAIL, NULL);
+ }
+}
+
+static void ecs_hds_do_umount(char* cmd, type_group group, type_action action, char *data)
+{
+ int level = 0;
+ int len = 0;
+ int tag_level = 0;
+ char token[] = "\n";
+ char* tag;
+ char* level_token;
+ char* guest_path;
+ char emuld_data [OUT_BUF_SIZE];
+
+ if (data == NULL) {
+ LOG_WARNING("ecs_hds_do_umount data is empty.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_UMOUNT_FAIL, NULL);
+ return;
+ }
+
+ tag = strtok(data, token);
+ if (tag == NULL) {
+ LOG_WARNING("ecs_hds_do_umount tag token is empty.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_UMOUNT_FAIL, NULL);
+ return;
+ }
+
+ level_token = strtok(NULL, token);
+ if (level_token != NULL) {
+ level = atoi(level_token);
+ }
+
+ LOG_INFO("try detach with is_hds_attached : %s, %d, level: %d\n",
+ tag, is_hds_attached(tag), level);
+
+ if (!is_hds_attached(tag)) {
+ LOG_WARNING("hds is not attached. do not try detach it.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_UMOUNT_FAIL, NULL);
+ return;
+ }
+
+ guest_path = get_guest_path_by_id(tag);
+ if (guest_path == NULL) {
+ LOG_WARNING("hds guest path is empty with tag %s.\n", tag);
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_UMOUNT_FAIL, NULL);
+ return;
+ }
+
+ tag_level = get_hds_level_by_id(tag);
+
+ if (tag_level > level) {
+ LOG_WARNING("HDS Level is not enough to unmount.\n");
+ make_send_device_ntf(cmd, group, ECS_HDS_ACT_UMOUNT_NOT_ENOUGH_LEVEL, NULL);
+ return;
+ }
+
+ len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", data, guest_path);
+ LOG_INFO("send emuld to umount.%s\n", emuld_data);
+ send_msg_to_guest(cmd, group, action, emuld_data, len + 1);
+}
+
+void msgproc_device_req_hds(ECS_Client* ccli, ECS__DeviceReq* msg, char * cmd)
+{
+ char* data = NULL;
+ type_group group = (type_group) (msg->group & 0xff);
+ type_action action = (type_action) (msg->action & 0xff);
+
+ if (msg->has_data && msg->data.len > 0)
+ {
+ data = (char*) g_malloc0(msg->data.len + 1);
+ memcpy(data, msg->data.data, msg->data.len);
+ }
+
+ LOG_INFO("hds group: %d, action : %d\n", group, action);
+ if (group == MSG_GROUP_STATUS) {
+ ecs_hds_do_status(cmd, group);
+ } else if (group == ECS_HDS_MSG_GROUP && action == ECS_HDS_ACTION_MOUNT) {
+ ecs_hds_do_mount(cmd, group, data);
+ } else if (group == ECS_HDS_MSG_GROUP && action == ECS_HDS_ACTION_UMOUNT) {
+ ecs_hds_do_umount(cmd, group, action, data);
+ } else {
+ LOG_WARNING("hds unknown command: group %d action %d\n", group, action);
+ }
+
+ if (data) {
+ g_free(data);
+ }
+}
+
+static void send_hds_mount_request(char* list)
+{
+ int len = 0;
+ char token[] = ",";
+ char emuld_data [OUT_BUF_SIZE];
+ char* id;
+ char* host;
+ char* guest;
+
+ LOG_INFO("handling mount request: %s\n", list);
+
+ id = strtok(list, token);
+ if (id == NULL) {
+ LOG_WARNING("cannot send mount request because of id\n");
+ return;
+ }
+
+ host = strtok(NULL, token);
+ if (host == NULL) {
+ LOG_WARNING("cannot send mount request because of host\n");
+ return;
+ }
+
+ guest = strtok(NULL, token);
+ if (guest == NULL) {
+ LOG_WARNING("cannot send mount request because of guest\n");
+ return;
+ }
+
+ len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", id, guest);
+ send_msg_to_guest(MSG_TYPE_HDS, ECS_HDS_MSG_GROUP,
+ ECS_HDS_ACTION_MOUNT, emuld_data, len + 1);
+}
+
+static void* hds_mount_request_thread(void* args)
+{
+ char* list = (char*)args;
+ char token[] = "\n";
+ char* hds_list;
+
+ hds_list = strtok(list, token);
+ if (hds_list == NULL) {
+ LOG_INFO("no hds mount request\n");
+ free(list);
+ return NULL;
+ }
+
+ send_hds_mount_request(hds_list);
+
+ while((hds_list = strtok(NULL, token)) != NULL) {
+ send_hds_mount_request(hds_list);
+ }
+
+ free(list);
+ return NULL;
+}
+
+static void ecs_hds_do_get_list(void)
+{
+ char* list;
+ QemuThread hds_thread_id;
+
+ list = get_hds_lists();
+ if (strlen(list) == 0) {
+ LOG_INFO("none of mount candidates available.\n");
+ return;
+ }
+ qemu_thread_create(&hds_thread_id, "hds_mount", hds_mount_request_thread,
+ (void*)list, QEMU_THREAD_DETACHED);
+}
+
+void msgproc_injector_do_hds(char* cat, type_action action, const char* data)
+{
+ FsDriverEntry *entry;
+ char msg [OUT_BUF_SIZE];
+ char *host;
+ char *guest;
+ int level = 0;
+
+ LOG_INFO("hds status is %d, %s\n", action, data);
+ switch (action) {
+ case ECS_HDS_ACT_GET_LIST:
+ ecs_hds_do_get_list();
+ break;
+ case ECS_HDS_ACT_ADD_LIST_FOR_DEFAULT:
+ entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
+ if (entry == NULL) {
+ LOG_WARNING("cannot find fsdev entry.\n");
+ break;
+ }
+
+ if (!add_hds_list(DEFAULT_STATIC_HDS_ID, entry->path, DEFAULT_HDS_GUEST_PATH, 0)) {
+ LOG_WARNING("cannot add into hds list.\n");
+ break;
+ }
+
+ set_hds_attached(DEFAULT_STATIC_HDS_ID, true);
+ data = DEFAULT_STATIC_HDS_ID;
+
+ // pass-through
+ case ECS_HDS_ACT_MOUNT_SUCCESS:
+ if (data == NULL) {
+ LOG_WARNING("error: hds data is null.\n");
+ break;
+ }
+ host = get_host_path_by_id(data);
+ if (host == NULL) {
+ LOG_WARNING("get_host_path_by_id failed with %s\n", data);
+ break;
+ }
+ guest = get_guest_path_by_id(data);
+ if (guest == NULL) {
+ LOG_WARNING("get_guest_path_by_id failed with %s\n", data);
+ break;
+ }
+
+ level = get_hds_level_by_id(data);
+ snprintf(msg, sizeof(msg), "%s,%s,%s,%d,", data, host, guest, level);
+ make_send_device_ntf(cat, ECS_HDS_MSG_GROUP, action, msg);
+ break;
+ case ECS_HDS_ACT_MOUNT_FAIL:
+ case ECS_HDS_ACT_MOUNT_NOT_PERMITTED: // not exist on the possible path
+ case ECS_HDS_ACT_MOUNT_NOT_VALID_PATH: // not a vaild path
+ if (data == NULL) {
+ LOG_WARNING("error: hds data is null.\n");
+ break;
+ }
+ remove_hds_list((char*)data);
+ do_hotplug(DETACH_HDS, (char*)data, strlen(data) + 1);
+ make_send_device_ntf(cat, ECS_HDS_MSG_GROUP, action, (char*)data);
+ break;
+ case ECS_HDS_ACT_UMOUNT_SUCCESS:
+ if (data == NULL) {
+ LOG_WARNING("error: hds data is null.\n");
+ break;
+ }
+ do_hotplug(DETACH_HDS, (char*)data, strlen(data) + 1);
+ make_send_device_ntf(cat, ECS_HDS_MSG_GROUP, action, (char*)data);
+ break;
+ case ECS_HDS_ACT_UMOUNT_FAIL:
+ if (data == NULL) {
+ LOG_WARNING("error: hds data is null.\n");
+ break;
+ }
+ make_send_device_ntf(cat, ECS_HDS_MSG_GROUP, action, (char*)data);
+ break;
+ default:
+ LOG_WARNING("unknown action: %s.\n", action);
+ break;
+ }
+}
--- /dev/null
+/*
+ * Emulator Control Server - HDS
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Jinhyung choi <jinh0.choi@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef __ECS_HDS_H__
+#define __ECS_HDS_H__
+
+#include "ecs.h"
+
+#define ECS_HDS_MSG_GROUP 100
+
+#define ECS_HDS_ACTION_MOUNT 1
+#define ECS_HDS_ACTION_UMOUNT 2
+#define ECS_HDS_ACTION_STATE 99
+
+enum hds_act_result {
+ 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_UMOUNT_SUCCESS = 3,
+ ECS_HDS_ACT_UMOUNT_FAIL = 4,
+ ECS_HDS_ACT_UMOUNT_DETACH_FAIL = 5,
+ ECS_HDS_ACT_UMOUNT_NOT_ENOUGH_LEVEL = 31,
+ ECS_HDS_ACT_ADD_LIST_FOR_DEFAULT = 99
+};
+
+void msgproc_device_req_hds(ECS_Client* ccli, ECS__DeviceReq* msg, char * cmd);
+void msgproc_injector_do_hds(char* cat, type_action action, const char* data);
+
+#endif /* __ECS_HDS_H__ */
#include "hw/virtio/maru_virtio_nfc.h"
#include "util/ui_operations.h"
-#include "util/device_hotplug.h"
-#include "util/hds.h"
+#include "ecs_hds.h"
#include "emul_state.h"
#include "ecs.h"
#include "debug_ch.h"
}
}
-static void msgproc_device_req_hds(ECS_Client* ccli, ECS__DeviceReq* msg, char * cmd)
-{
- int len = 0;
- char* data = NULL;
- char token[] = "\n";
- type_group group = (type_group) (msg->group & 0xff);
- type_action action = (type_action) (msg->action & 0xff);
-
- if (msg->has_data && msg->data.len > 0)
- {
- data = (char*) g_malloc0(msg->data.len + 1);
- memcpy(data, msg->data.data, msg->data.len);
- }
-
- LOG_INFO("hds group: %d, action : %d\n", group, action);
- if (group == MSG_GROUP_STATUS) {
- data = get_hds_lists();
- LOG_INFO("hds status: %s\n", data);
- make_send_device_ntf(cmd, group, 99, data);
- } else if (group == MSG_GROUP_HDS && action == HDS_ACTION_MOUNT) {
- char *host = strtok(data, token);
- if (host == NULL) {
- make_send_device_ntf(cmd, group, 2, NULL);
- goto hds_free;
- }
- char *guest = strtok(NULL, token);
- if (guest == NULL) {
- make_send_device_ntf(cmd, group, 2, NULL);
- goto hds_free;
- }
-
- char* hds_id = new_hds_list(host, guest);
- if (hds_id != NULL) {
- LOG_INFO("do attach tag: %s, host: %s, guest: %s\n", hds_id, host, guest);
- do_hotplug(ATTACH_HDS, hds_id, strlen(hds_id) + 1);
- } else {
- make_send_device_ntf(cmd, group, 2, NULL);
- }
- } else if (group == MSG_GROUP_HDS && action == HDS_ACTION_UMOUNT) {
- LOG_INFO("try detach with is_hds_attached : %s, %d\n", data, is_hds_attached(data));
- if (is_hds_attached(data)) {
- char emuld_data [OUT_BUF_SIZE];
- char* guest_path = get_guest_path_by_id(data);
- if (strlen(guest_path) == 0) {
- LOG_SEVERE("hds guest path is empty.\n");
- return;
- }
- len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", data, guest_path);
- LOG_INFO("send emuld to umount.%s\n", emuld_data);
- send_msg_to_guest(cmd, group, action, emuld_data, len + 1);
- } else {
- LOG_INFO("hds is not attached. do not try detach it.\n");
- make_send_device_ntf(cmd, group, 4, NULL);
- }
- } else {
- LOG_SEVERE("hds unknown command: group %d action %d\n", group, action);
- }
-hds_free:
- if (data) {
- g_free(data);
- }
-}
-
#ifndef CONFIG_EXTENSION_PATH
bool msgproc_device_req_ext(ECS_Client* ccli, ECS__DeviceReq* msg)
{
#include "qemu-common.h"
#include "qemu/error-report.h"
-#include "fsdev/qemu-fsdev.h"
#include "hw/virtio/maru_virtio_vmodem.h"
#include "hw/virtio/maru_virtio_evdi.h"
#include "hw/virtio/maru_virtio_jack.h"
#include "hw/virtio/maru_virtio_power.h"
-#include "util/device_hotplug.h"
-#include "util/hds.h"
#include "emul_state.h"
-#include "ecs.h"
+#include "ecs_hds.h"
#include "debug_ch.h"
#include "util/osutil.h"
#include "util/exported_strings.h"
#define SLEEP_CONNECT_SDB 1000 // ms
static QemuThread sdb_thread_id;
-static QemuThread hds_thread_id;
extern QemuMutex mutex_location_data;
static char location_data[MAX_INJECTOR_REQ_DATA];
msgproc_injector_req(NULL, &msg);
}
-static void send_hds_mount_request(char* list)
-{
- int len = 0;
- char token[] = ",";
- char emuld_data [OUT_BUF_SIZE];
- char* id;
- char* host;
- char* guest;
-
- LOG_INFO("handling mount request: %s\n", list);
-
- id = strtok(list, token);
- if (id == NULL) {
- LOG_SEVERE("cannot send mount request because of id\n");
- return;
- }
-
- host = strtok(NULL, token);
- if (host == NULL) {
- LOG_SEVERE("cannot send mount request because of host\n");
- return;
- }
-
- guest = strtok(NULL, token);
- if (guest == NULL) {
- LOG_SEVERE("cannot send mount request because of guest\n");
- return;
- }
-
- len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", id, guest);
- send_msg_to_guest(MSG_TYPE_HDS, MSG_GROUP_HDS, HDS_ACTION_MOUNT, emuld_data, len + 1);
-}
-
-static void* hds_mount_request_thread(void* args)
-{
- char* list = (char*)args;
- char token[] = "\n";
- char* hds_list;
-
- hds_list = strtok(list, token);
- if (hds_list == NULL) {
- LOG_INFO("no hds mount request\n");
- free(list);
- return NULL;
- }
-
- send_hds_mount_request(hds_list);
-
- while((hds_list = strtok(NULL, token)) != NULL) {
- send_hds_mount_request(hds_list);
- }
-
- free(list);
- return NULL;
-}
-
-#define MSG_GROUP_HDS 100
-static void do_hds(char* cat, type_action action, const char* data)
-{
- FsDriverEntry *entry;
- char msg [OUT_BUF_SIZE];
- char *host;
- char *guest;
- char* list;
-
- LOG_INFO("hds status is %d, %s\n", action, data);
- switch (action) {
- case 0: // get list from devices
- list = get_hds_lists();
- if (strlen(list) == 0) {
- LOG_INFO("none of mount candidates available.\n");
- break;
- }
- qemu_thread_create(&hds_thread_id, "hds_mount", hds_mount_request_thread, (void*)list, QEMU_THREAD_DETACHED);
- break;
- case 99: // add list for default hds
- entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID);
- if (entry == NULL) {
- LOG_SEVERE("cannot find fsdev entry.\n");
- break;
- }
-
- if (!add_hds_list(DEFAULT_STATIC_HDS_ID, entry->path, DEFAULT_HDS_GUEST_PATH)) {
- LOG_SEVERE("cannot add into hds list.\n");
- break;
- }
-
- set_hds_attached(DEFAULT_STATIC_HDS_ID, true);
- data = DEFAULT_STATIC_HDS_ID;
-
- // pass-through
- case 1: // mount success
- if (data == NULL) {
- LOG_SEVERE("error: hds data is null.\n");
- break;
- }
- host = get_host_path_by_id((char*)data);
- if (host == NULL)
- LOG_SEVERE("get_host_path_by_id failed with %s, %s\n", data, host);
- guest = get_guest_path_by_id((char*)data);
- if (guest == NULL)
- LOG_SEVERE("get_guest_path_by_id failed with %s, %s\n", data, guest);
- snprintf(msg, sizeof(msg), "%s,%s,%s", data, host, guest);
- make_send_device_ntf(cat, MSG_GROUP_HDS, action, msg);
- break;
- case 2: // mount failed.
- case 11: // not exist on the possible path
- case 12: // not a vaild path
- if (data == NULL) {
- LOG_SEVERE("error: hds data is null.\n");
- break;
- }
- remove_hds_list((char*)data);
- do_hotplug(DETACH_HDS, (char*)data, strlen(data) + 1);
- make_send_device_ntf(cat, MSG_GROUP_HDS, action, (char*)data);
- break;
- case 3: // unmount success
- if (data == NULL) {
- LOG_SEVERE("error: hds data is null.\n");
- break;
- }
- do_hotplug(DETACH_HDS, (char*)data, strlen(data) + 1);
- make_send_device_ntf(cat, MSG_GROUP_HDS, action, (char*)data);
- break;
- case 4: // unmount failed.
- if (data == NULL) {
- LOG_SEVERE("error: hds data is null.\n");
- break;
- }
- make_send_device_ntf(cat, MSG_GROUP_HDS, action, (char*)data);
- break;
- default:
- LOG_SEVERE("unknown action: %s.\n", action);
- break;
- }
-}
-
static bool do_push_package(char* cmd)
{
char buf[MAX_PKGS_LIST];
LOG_INFO("emuld connection is %d\n", action);
set_emuld_connection(action);
} else if (!strcmp(cat, "hds")) {
- do_hds(cat, action, data);
+ msgproc_injector_do_hds(cat, action, data);
return true;
} else if (!strcmp(cat, MSG_TYPE_PACKAGE)) {
do_package(cat, action, data);
#include "emulator.h"
#include "emul_state.h"
#include "device_hotplug.h"
-#include "ecs/ecs.h"
+#include "ecs/ecs_hds.h"
#include "hds.h"
#include "ecs/ecs_sdcard.h"
len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", id, guest);
LOG_INFO("send emuld to mount: %s", emuld_data);
- send_msg_to_guest(MSG_TYPE_HDS, MSG_GROUP_HDS, HDS_ACTION_MOUNT, emuld_data, len + 1);
+ send_msg_to_guest(MSG_TYPE_HDS, ECS_HDS_MSG_GROUP,
+ ECS_HDS_ACTION_MOUNT, emuld_data, len + 1);
return true;
}
char *id;
char *host;
char *guest;
+ int level; // 0: normal, 1: unmodifiable
QTAILQ_ENTRY(hds_list) next;
} hds_list;
return NULL;
}
-bool add_hds_list(const char* id, const char* host, const char* guest)
+bool add_hds_list(const char* id, const char* host, const char* guest, int level)
{
hds_list* list;
list->host = strdup(host);
list->guest = strdup(guest);
+ if (level != 0) {
+ list->level = 1;
+ }
+
QTAILQ_INSERT_TAIL(&lists, list, next);
return true;
}
-char* new_hds_list(const char* host, const char* guest)
+char* new_hds_list(const char* host, const char* guest, int level)
{
char* id = find_new_id();
if (id == NULL) {
return NULL;
}
- if (!add_hds_list(id, host, guest)) {
+ if (!add_hds_list(id, host, guest, level)) {
LOG_SEVERE("failed to add list.\n");
free(id);
return NULL;
return NULL;
}
+int get_hds_level_by_id(const char* id)
+{
+ LOG_TRACE("get_hds_level_by_id request: %s\n", id);
+ hds_list *list = find_list(id);
+ if (list != NULL) {
+ return list->level;
+ }
+ return 0;
+}
+
bool is_hds_attached(const char* id)
{
hds_list *list = find_list(id);
{
LOG_INFO("list id: %s\n", list->id);
if (list->attached) {
- hds_size = sprintf(hds, "%s,%s,%s,\n", list->id, list->host, list->guest);
+ hds_size = sprintf(hds, "%s,%s,%s,%d,\n", list->id, list->host, list->guest, list->level);
if (strlen(list_hds) + hds_size > list_len) {
list_len *= 2;
list_hds = g_realloc(list_hds, list_len);
#include "qemu-common.h"
-bool add_hds_list(const char* id, const char* host, const char* guest);
-char* new_hds_list(const char* host, const char* guest);
+bool add_hds_list(const char* id, const char* host, const char* guest, int level);
+char* new_hds_list(const char* host, const char* guest, int level);
void remove_hds_list(const char* id);
char* get_host_path_by_id(const char* id);
char* get_guest_path_by_id(const char* id);
+int get_hds_level_by_id(const char* id);
bool is_hds_attached(const char* id);
void set_hds_attached(const char* id, bool attached);