block: Add block configuration for multimount option 57/43457/1
authorJiyoung Yun <jy910.yun@samsung.com>
Thu, 9 Jul 2015 09:57:05 +0000 (18:57 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Thu, 9 Jul 2015 09:57:05 +0000 (18:57 +0900)
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 <jy910.yun@samsung.com>
CMakeLists.txt
packaging/deviced.spec
src/block/block.c
src/block/block.conf [new file with mode: 0644]

index d42cd4e..28a1719 100755 (executable)
@@ -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)
index b0f33e9..bdf9209 100755 (executable)
@@ -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
index 87203f8..863c121 100644 (file)
@@ -34,6 +34,7 @@
 #include <tzplatform_config.h>
 
 #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 (file)
index 0000000..8898468
--- /dev/null
@@ -0,0 +1,7 @@
+[Block]
+
+[MMC]
+Multimount=no # yes or no
+
+[SCSI]
+Multimount=yes # yes or no