block: Modify primary partition checking routine 19/105219/5
authorpr.jung <pr.jung@samsung.com>
Fri, 16 Dec 2016 04:25:52 +0000 (13:25 +0900)
committerpr.jung <pr.jung@samsung.com>
Mon, 19 Dec 2016 08:51:56 +0000 (17:51 +0900)
- ntfs is not supported
- When multimount is not supported, deviced mount only primary partition

Change-Id: I9393e9a84cc20c2da00a692d20afd6d97202f719
Signed-off-by: pr.jung <pr.jung@samsung.com>
CMakeLists.txt
packaging/deviced.spec
src/block/block.c

index 753cf8f..af799e4 100755 (executable)
@@ -186,7 +186,7 @@ IF(DISPLAY_MODULE STREQUAL on)
        SET(PKG_MODULES ${PKG_MODULES} libinput capi-system-sensor)
 ENDIF()
 IF(BLOCK_MODULE STREQUAL on)
-       SET(PKG_MODULES ${PKG_MODULES} storage app2sd)
+       SET(PKG_MODULES ${PKG_MODULES} storage app2sd blkid)
 ENDIF()
 IF(TZIP_MODULE STREQUAL on)
        SET(PKG_MODULES ${PKG_MODULES} minizip fuse)
index f6b6c39..bdb06d7 100644 (file)
@@ -87,6 +87,7 @@ BuildRequires:        pkgconfig(capi-system-sensor)
 %if %{?block_module} == on
 BuildRequires: pkgconfig(storage)
 BuildRequires: pkgconfig(app2sd)
+BuildRequires: pkgconfig(blkid)
 %endif
 %if %{?tzip_module} == on
 BuildRequires: pkgconfig(fuse)
index cccb69f..c7f750f 100644 (file)
@@ -39,6 +39,7 @@
 #include <tzplatform_config.h>
 #include <app2ext_interface.h>
 #include <libmount.h>
+#include <blkid/blkid.h>
 
 #include "core/log.h"
 #include "core/common.h"
@@ -545,10 +546,17 @@ out:
 
 static bool check_primary_partition(const char *devnode)
 {
+       struct block_fs_ops *fs;
+       blkid_probe probe;
+       dd_list *elem;
+       const char *filesystem = NULL;
        char str[PATH_MAX];
        char str2[PATH_MAX];
+       size_t fs_len;
        int len;
+       int ret;
        int i;
+       bool found = false;
 
        if (fnmatch(MMC_LINK_PATH, devnode, 0) &&
                fnmatch(MMC_PATH, devnode, 0) &&
@@ -560,13 +568,35 @@ static bool check_primary_partition(const char *devnode)
        len = strlen(str);
        str[len - 1] = '\0';
 
-       for (i = 1; i < 9; ++i) {
+       for (i = 1; i <= 9; ++i) {
                snprintf(str2, sizeof(str2), "%s%d", str, i);
-               if (access(str2, R_OK) == 0)
-                       break;
+               if (access(str2, R_OK) != 0)
+                       continue;
+
+               probe = blkid_new_probe_from_filename(str2);
+               if (!probe)
+                       continue;
+               if (blkid_do_probe(probe) != 0)
+                       continue;
+
+               ret = blkid_probe_lookup_value(probe, "TYPE", &filesystem, &fs_len);
+               if (ret < 0) {
+                       blkid_free_probe(probe);
+                       continue;
+               }
+               DD_LIST_FOREACH(fs_head, elem, fs) {
+                       if (!strncmp(fs->name, filesystem, fs_len)) {
+                               found = true;
+                               break;
+                       }
+               }
+               blkid_free_probe(probe);
+               if (!found)
+                       continue;
+               break;
        }
 
-       if (!strncmp(devnode, str2, strlen(str2) + 1))
+       if (found && !strncmp(devnode, str2, strlen(str2) + 1))
                return true;
 
        return false;
@@ -2001,6 +2031,11 @@ static int add_block_device(struct udev_device *dev, const char *devnode)
                return -EPERM;
        }
 
+       if (!block_conf[data->block_type].multimount && !data->primary) {
+               _D("Not support multi mount by config info");
+               return -EPERM;
+       }
+
        bdev = make_block_device(data);
        if (!bdev) {
                _E("fail to make block device for %s", devnode);