From 77878e17d6d8e9eaf193e4d0ad2d31e1adeecbc1 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Wed, 10 May 2017 19:12:31 +0900 Subject: [PATCH] block: Format storage as ext4 filesystem when request is for extended internal storage Change-Id: Ia00b45e1306b6aeda266a915c21d7514263c0182 Signed-off-by: pr.jung --- src/block/block.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/block/block.c b/src/block/block.c index 7b14acb..48a3259 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -91,9 +91,11 @@ #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[] = { -- 2.7.4