block: in case of mmc device's primary, use static directory for libstorage library 16/47916/2 accepted/tizen/mobile/20150911.091857 accepted/tizen/tv/20150911.091910 accepted/tizen/wearable/20150911.091926 submit/tizen/20150911.075444
authorKunhoon Baik <knhoon.baik@samsung.com>
Thu, 10 Sep 2015 04:24:43 +0000 (13:24 +0900)
committertaeyoung <ty317.kim@samsung.com>
Thu, 10 Sep 2015 11:51:44 +0000 (20:51 +0900)
     : the libstorage library provide static path like "/usr/storage/sdcard"

Change-Id: I7f196ced789584c457b4bfb6a567caff84bfc9d7
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/block/block.c

index 90e0a7f..4a6f686 100644 (file)
@@ -231,10 +231,24 @@ static void signal_device_changed(struct block_device *bdev)
                        "issssssisib", arr);
 }
 
-static char *generate_mount_path(const char *fs_uuid_enc)
+static char *generate_mount_path(struct block_data *data)
 {
-       const char *str;
-       str = tzplatform_mkpath(TZ_SYS_STORAGE, fs_uuid_enc);
+       const char *str, *node;
+
+       if (!data)
+               return NULL;
+
+       /* For libstorage API
+        * If it's a primary partition and mmc device,
+        * use 'sdcard' node as mount point. */
+       if (data->primary && data->block_type == BLOCK_MMC_DEV)
+               node = "sdcard";
+       else if (data->fs_uuid_enc)
+               node = data->fs_uuid_enc;
+       else
+               return NULL;
+
+       str = tzplatform_mkpath(TZ_SYS_STORAGE, node);
        if (!str)
                return NULL;
        return strdup(str);
@@ -297,10 +311,8 @@ static struct block_data *make_block_data(const char *devnode,
                data->fs_type = strdup(fs_type);
        if (fs_version)
                data->fs_version = strdup(fs_version);
-       if (fs_uuid_enc) {
+       if (fs_uuid_enc)
                data->fs_uuid_enc = strdup(fs_uuid_enc);
-               data->mount_point = generate_mount_path(fs_uuid_enc);
-       }
        if (readonly)
                data->readonly = atoi(readonly);
        data->primary = check_primary_partition(devnode);
@@ -313,6 +325,8 @@ static struct block_data *make_block_data(const char *devnode,
        else
                data->block_type = -1;
 
+       data->mount_point = generate_mount_path(data);
+
        return data;
 }
 
@@ -359,15 +373,15 @@ static int update_block_data(struct block_data *data,
        data->fs_uuid_enc = NULL;
        free(data->mount_point);
        data->mount_point = NULL;
-       if (fs_uuid_enc) {
+       if (fs_uuid_enc)
                data->fs_uuid_enc = strdup(fs_uuid_enc);
-               data->mount_point = generate_mount_path(fs_uuid_enc);
-       }
 
        data->readonly = false;
        if (readonly)
                data->readonly = atoi(readonly);
 
+       data->mount_point = generate_mount_path(data);
+
        return 0;
 }
 
@@ -748,7 +762,7 @@ int change_mount_point(const char *devnode,
        if (mount_point)
                data->mount_point = strdup(mount_point);
        else
-               data->mount_point = generate_mount_path(data->fs_uuid_enc);
+               data->mount_point = generate_mount_path(data);
 
        return 0;
 }