block: Format storage as ext4 filesystem when request is for extended internal storage 07/150707/3
authorpr.jung <pr.jung@samsung.com>
Wed, 10 May 2017 10:12:31 +0000 (19:12 +0900)
committerJung <pr.jung@samsung.com>
Mon, 18 Sep 2017 09:51:56 +0000 (09:51 +0000)
Change-Id: Ia00b45e1306b6aeda266a915c21d7514263c0182
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/block/block.c

index 7b14acb..48a3259 100644 (file)
 #define EXTENDED_INTERNAL_PATH "/run/extended-internal-sd"
 #define PATH_LEN               55
 
-#define EXTENDED_SD_PATH       "/opt/media/extendedsd"
+#define EXTENDED_SD_PATH       "/opt/extendedsd"
 #define EXTENDED_SD_STRING     "ExtendedInternalSD"
 
+#define EXT4_NAME              "ext4"
+
 /* Minimum value of block id */
 #define BLOCK_ID_MIN 10
 /* For 2.4 Backward Compatibility */
@@ -691,6 +693,7 @@ static struct block_data *make_block_data(const char *devnode,
        BLOCK_FLAG_CLEAR_ALL(data);
 
        /* for 2.4 backward compatibility */
+       // What if storage id 1 is existed? (multi sdcard case)
        if (data->primary == true && data->block_type == BLOCK_MMC_DEV)
                data->id = EXT_PRIMARY_SD_FIXID;
        else
@@ -1385,25 +1388,32 @@ static int block_format(struct block_data *data,
 {
        const struct block_fs_ops *fs;
        dd_list *elem;
+       const char *fstype;
        int len;
        int r;
 
        if (!data || !data->devnode || !data->mount_point)
                return -EINVAL;
 
-       if (!fs_type)
-               fs_type = data->fs_type;
+       if (data->block_type == BLOCK_MMC_EXTENDED_INTERNAL_DEV)
+               fstype = EXT4_NAME;
+       else {
+               if (!fs_type)
+                       fstype = data->fs_type;
+               else
+                       fstype = fs_type;
+       }
 
        fs = NULL;
-       len = strlen(fs_type);
+       len = strlen(fstype);
        DD_LIST_FOREACH(fs_head, elem, fs) {
-               if (!strncmp(fs->name, fs_type, len))
+               if (!strncmp(fs->name, fstype, len))
                        break;
        }
 
        if (!fs) {
                BLOCK_FLAG_SET(data, FS_NOT_SUPPORTED);
-               _E("not supported file system(%s)", fs_type);
+               _E("not supported file system(%s)", fstype);
                return -ENOTSUP;
        }
 
@@ -1483,7 +1493,8 @@ static struct format_data *get_format_data(
 static void release_format_data(struct format_data *data)
 {
        if (data) {
-               free(data->fs_type);
+               if (data->fs_type)
+                       free(data->fs_type);
                free(data);
        }
 }
@@ -3111,17 +3122,17 @@ out:
 }
 
 /*
-  Method name          Method call   format string         Reply format string
-{ "ShowDeviceList",    NULL,         NULL,                 request_show_device_list },
-{ "GetDeviceList" ,    "s",          "a(issssssisibii)",   request_get_device_list },
-{ "GetDeviceList2",    "s",          "a(issssssisibi)",    request_get_device_list_2 },
-{ "Mount",             "is",         "i",                  request_public_mount_block },
-{ "Unmoun,             "ii",         "i",                  request_public_unmount_block },
-{ "Format",            "ii",         "i",                  request_format_block },
-{ "GetDeviceInfo",     "i",          "(issssssisibii)",    request_get_device_info },
-{ "GetMmcPrimary",     NULL,         "(issssssisibii)",    request_get_mmc_primary },
-{ "PrivateMount",      "is",         "i",                  request_private_mount_block },
-{ "PrivateUnmount",    "ii",         "i",                  request_private_unmount_block },
+  Method name      Method call format string  Reply format string
+{ "ShowDeviceList",                      NULL,               NULL, request_show_device_list },
+{ "GetDeviceList",                        "s", "a(issssssisibii)", request_get_device_list },
+{ "GetDeviceList2",                       "s",  "a(issssssisibi)", request_get_device_list_2 },
+{ "Mount",                               "is",                "i", request_public_mount_block },
+{ "Unmoun,                               "ii",                "i", request_public_unmount_block },
+{ "Format",                              "ii",                "i", request_format_block },
+{ "GetDeviceInfo",                        "i",  "(issssssisibii)", request_get_device_info },
+{ "GetMmcPrimary",                       NULL, "(issssssisibii)" , request_get_mmc_primary },
+{ "PrivateMount",                        "is",                "i", request_private_mount_block },
+{ "PrivateUnmount",                      "ii",                "i", request_private_unmount_block },
 */
 
 static const dbus_method_s manager_methods[] = {