From 39982620adfc069f948aa4f3b91f456f75d745c1 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Thu, 9 Jul 2015 18:57:05 +0900 Subject: [PATCH] block: Add block configuration for multimount option Currently, deviced does not support multi mount in mmc devices. So we turn off a multi mount option by using block configuration file. Change-Id: Ia2eb51cab54e3004d8a43baf0cda0c26f39512c9 Signed-off-by: Jiyoung Yun --- CMakeLists.txt | 1 + packaging/deviced.spec | 1 + src/block/block.c | 39 +++++++++++++++++++++++++++++++++++++++ src/block/block.conf | 7 +++++++ 4 files changed, 48 insertions(+) create mode 100644 src/block/block.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index d42cd4e..28a1719 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,7 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_I INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/deviced-pre.sh DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/deviced.conf DESTINATION /etc/dbus-1/system.d) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/movi_format.sh DESTINATION bin) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/block/block.conf DESTINATION /etc/deviced) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/usb/usb-setting.conf DESTINATION /etc/deviced) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/usb/usb-operation.conf DESTINATION /etc/deviced) INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/mmc-smack-label DESTINATION bin) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index b0f33e9..bdf9209 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -305,6 +305,7 @@ systemctl daemon-reload %{_bindir}/deviced-pre.sh %{_bindir}/deviced %{_bindir}/movi_format.sh +%{_sysconfdir}/deviced/block.conf %{_sysconfdir}/deviced/usb-setting.conf %{_sysconfdir}/deviced/usb-operation.conf %{_bindir}/mmc-smack-label diff --git a/src/block/block.c b/src/block/block.c index 87203f8..863c121 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -34,6 +34,7 @@ #include #include "core/log.h" +#include "core/config-parser.h" #include "core/device-notifier.h" #include "core/devices.h" #include "core/udev.h" @@ -63,6 +64,8 @@ #define BLOCK_TYPE_SCSI "scsi" #define BLOCK_TYPE_ALL "all" +#define BLOCK_CONF_FILE "/etc/deviced/block.conf" + enum block_dev_operation { BLOCK_DEV_MOUNT, BLOCK_DEV_UNMOUNT, @@ -84,6 +87,10 @@ struct format_data { enum unmount_operation option; }; +static struct block_conf { + bool multimount; +} block_conf[BLOCK_MMC_DEV + 1]; + static dd_list *fs_head; static dd_list *block_dev_list; static dd_list *block_ops_list; @@ -669,6 +676,12 @@ int mount_block_device(const char *devnode) return 0; } + if (!block_conf[data->block_type].multimount && + !data->primary) { + _I("Not support multi mount by config info"); + return 0; + } + r = pthread_create(&th, NULL, mount_start, bdev); if (r != 0) { _E("fail to create thread for %s", data->devnode); @@ -1449,10 +1462,36 @@ static int init_block_object_iface(void) return 0; } +static int load_config(struct parse_result *result, void *user_data) +{ + int index; + + if (MATCH(result->section, "Block")) + return 0; + + if (MATCH(result->section, "SCSI")) + index = BLOCK_SCSI_DEV; + else if (MATCH(result->section, "MMC")) + index = BLOCK_MMC_DEV; + else + return -EINVAL; + + if (MATCH(result->name, "Multimount")) + block_conf[index].multimount = + (MATCH(result->value, "yes") ? true : false); + + return 0; +} + static void block_init(void *data) { int ret; + /* load config */ + ret = config_parse(BLOCK_CONF_FILE, load_config, NULL); + if (ret < 0) + _E("fail to load %s, Use default value", BLOCK_CONF_FILE); + /* register block manager object and interface */ ret = register_edbus_interface_and_method(DEVICED_PATH_BLOCK_MANAGER, DEVICED_INTERFACE_BLOCK_MANAGER, diff --git a/src/block/block.conf b/src/block/block.conf new file mode 100644 index 0000000..8898468 --- /dev/null +++ b/src/block/block.conf @@ -0,0 +1,7 @@ +[Block] + +[MMC] +Multimount=no # yes or no + +[SCSI] +Multimount=yes # yes or no -- 2.7.4