block: Format as ext4 filesystem when request is for extended internal storage 48/131248/8
authorpr.jung <pr.jung@samsung.com>
Wed, 10 May 2017 10:12:31 +0000 (19:12 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 11 Sep 2017 11:59:47 +0000 (20:59 +0900)
Change-Id: Ia00b45e1306b6aeda266a915c21d7514263c0182
Signed-off-by: pr.jung <pr.jung@samsung.com>
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/block/block.c

index 8b10c77..bcf31c9 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 */
@@ -694,6 +696,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
@@ -1388,25 +1391,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_STRING;
+       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;
        }
 
@@ -1486,7 +1496,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);
        }
 }