Add EXTENDED_INTERNAL type for extended internal storage 64/124964/11 accepted/tizen/4.0/unified/20170816.012035 accepted/tizen/4.0/unified/20170829.020542 accepted/tizen/unified/20170608.072310 submit/tizen/20170607.084951 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004
authorpr.jung <pr.jung@samsung.com>
Thu, 13 Apr 2017 07:18:10 +0000 (16:18 +0900)
committerJung <pr.jung@samsung.com>
Wed, 7 Jun 2017 02:33:48 +0000 (02:33 +0000)
Change-Id: I68d069cc718f3b735622fe20ee902b7c505f540e
Signed-off-by: pr.jung <pr.jung@samsung.com>
include/storage-expand.h
include/storage-experimental.h
src/storage-external-dbus.h
src/storage-external.c
src/storage-external.h
src/storage.c

index b432382f7c7a85b97389c0d9c264434f7b64f243..5db5a9b098174e938b1a677c7f5c06948b128e46 100644 (file)
@@ -50,8 +50,9 @@ typedef enum {
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef enum {
-       STORAGE_TYPE_INTERNAL, /**< Internal device storage (built-in storage in a device, non-removable) */
-       STORAGE_TYPE_EXTERNAL, /**< External storage */
+       STORAGE_TYPE_INTERNAL,          /**< Internal device storage (built-in storage in a device, non-removable) */
+       STORAGE_TYPE_EXTERNAL,          /**< External storage */
+       STORAGE_TYPE_EXTENDED_INTERNAL, /**< Extended internal storage (External storage used as internal storage) (Since 4.0) */
 } storage_type_e;
 
 
@@ -249,8 +250,9 @@ int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb call
  * @since_tizen 3.0
  */
 typedef enum {
-       STORAGE_DEV_EXT_SDCARD = 1001, /**< sdcard device (external storage) */
-       STORAGE_DEV_EXT_USB_MASS_STORAGE, /**< USB storage device (external storage) */
+       STORAGE_DEV_EXT_SDCARD = 1001,     /**< SD card device (external storage) */
+       STORAGE_DEV_EXT_USB_MASS_STORAGE,  /**< USB storage device (external storage) */
+       STORAGE_DEV_EXTENDED_INTERNAL,     /**< Extended internal storage device (External storage used as internal storage) (Since 4.0) */
 } storage_dev_e;
 
 
index a86b27272a722cebb9b365fbcd07f3259cb541ec..5f547be6de76479681a0f6d5b7b340a1abb590b9 100644 (file)
@@ -39,8 +39,8 @@ extern "C" {
  * @since_tizen 3.0
  *
  * @param[in] storage_id The storage id
- * @param[out] type storage type (internal or external).
- * @param[out] dev the kind of storage device for external type (sdcard, usb). If type is #STORAGE_TYPE_EXTERNAL, then value of this param is invalid.
+ * @param[out] type The storage @a type (internal or external).
+ * @param[out] dev The storage device for external storage. If @a type is #STORAGE_TYPE_INTERNAL, then value of @a dev should be ignored.
  *
  * @return @c 0 on success,
  *         otherwise a negative error value
index 0589959c500d923128693b777eb44189eed4a4c6..a955aefc4563d8b95afec4a297b9b34e73d51e71 100644 (file)
@@ -44,6 +44,7 @@ enum storage_ext_state {
 enum storage_ext_type {
        STORAGE_EXT_SCSI,
        STORAGE_EXT_MMC,
+       STORAGE_EXT_MMC_EXTENDED_INTERNAL,
 };
 
 enum storage_ext_flags {
index 42ea2e8913ed31c39b8d3236752a7146971922db..e4985293b6e75f30054792ec1fc7f5e4289490ae 100755 (executable)
@@ -28,8 +28,9 @@
 #include "log.h"
 #include "storage-external-dbus.h"
 
-#define EXTERNAL_STORAGE_PATH "/run/external-storage"
-#define PATH_LEN              55
+#define EXTERNAL_STORAGE_PATH  "/run/external-storage"
+#define EXTENDED_INTERNAL_PATH "/run/extended-internal-sd"
+#define PATH_LEN               55
 
 static dd_list *cb_list[STORAGE_CALLBACK_MAX];
 
@@ -151,8 +152,13 @@ int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *
                        continue;
                }
 
-               ret_cb = callback(dev->storage_id, STORAGE_TYPE_EXTERNAL,
-                               state, dev->mount_point, user_data);
+               if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL)
+                       ret_cb = callback(dev->storage_id,
+                                       STORAGE_TYPE_EXTENDED_INTERNAL,
+                                       state, dev->mount_point, user_data);
+               else
+                       ret_cb = callback(dev->storage_id, STORAGE_TYPE_EXTERNAL,
+                                       state, dev->mount_point, user_data);
                if (!ret_cb)
                        break;
        }
@@ -215,6 +221,8 @@ static int storage_ext_type_changed(storage_ext_device *dev, enum storage_ext_st
                strdev = STORAGE_DEV_EXT_USB_MASS_STORAGE;
        else if (dev->type == STORAGE_EXT_MMC)
                strdev = STORAGE_DEV_EXT_SDCARD;
+       else if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL)
+               strdev = STORAGE_DEV_EXTENDED_INTERNAL;
        else {
                _E("Invalid dev type (%d)", dev->type);
                return -EINVAL;
@@ -354,11 +362,12 @@ int storage_ext_unregister_cb(enum storage_cb_type type, struct storage_cb_info
        return 0;
 }
 
-int storage_ext_get_root(int storage_id, char *path, size_t len)
+int storage_ext_get_root(int storage_id, char *path, size_t len, bool *extendedinternal)
 {
        FILE *fp;
        storage_ext_device *dev;
        char file_name[PATH_LEN];
+       char file_name2[PATH_LEN];
        char *tmp;
        int ret = 0;
 
@@ -367,8 +376,13 @@ int storage_ext_get_root(int storage_id, char *path, size_t len)
 
        if (!path)
                return -EINVAL;
+       if (!extendedinternal)
+               return -EINVAL;
 
        snprintf(file_name, PATH_LEN, EXTERNAL_STORAGE_PATH"/%d", storage_id);
+       snprintf(file_name2, PATH_LEN, EXTENDED_INTERNAL_PATH"/%d", storage_id);
+
+       *extendedinternal = false;
 
        if (access(file_name, R_OK) == 0) {
                fp = fopen(file_name, "r");
@@ -385,7 +399,23 @@ int storage_ext_get_root(int storage_id, char *path, size_t len)
                        _D("Failed to get path");
                        goto out;
                }
+               *extendedinternal = false;
+       } else if (access(file_name2, R_OK) == 0) {
+               fp = fopen(file_name2, "r");
+               if (!fp) {
+                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+                       ret = -ENODEV;
+                       goto out;
+               }
 
+               tmp = fgets(path, len, fp);
+               fclose(fp);
+               if (!tmp) {
+                       ret = -ENODEV;
+                       _D("Failed to get path");
+                       goto out;
+               }
+               *extendedinternal = true;
        } else {
                dev = calloc(1, sizeof(storage_ext_device));
                if (!dev) {
@@ -403,6 +433,10 @@ int storage_ext_get_root(int storage_id, char *path, size_t len)
                }
 
                snprintf(path, len, "%s", dev->mount_point);
+               if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL)
+                       *extendedinternal = true;
+               else
+                       *extendedinternal = false;
                storage_ext_release_device(&dev);
        }
 
@@ -441,7 +475,7 @@ int storage_ext_get_state(int storage_id, storage_state_e *state)
        if (ret < 0)
                _E("Failed to get state of storage id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
 
-out :
+out:
        storage_ext_release_device(&dev);
        return ret;
 }
index c7bd9fd751abacfc2b3f366793e73225aebbfa0f..af36ed1106982dced62b3e24a726beb339f1001c 100755 (executable)
@@ -26,7 +26,7 @@ int storage_ext_get_space(int storage_id,
 int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *user_data);
 int storage_ext_register_cb(enum storage_cb_type type, struct storage_cb_info *info);
 int storage_ext_unregister_cb(enum storage_cb_type type, struct storage_cb_info *info);
-int storage_ext_get_root(int storage_id, char *path, size_t len);
+int storage_ext_get_root(int storage_id, char *path, size_t len, bool *extendedinternal);
 int storage_ext_get_state(int storage_id, storage_state_e *state);
 int storage_ext_get_primary_mmc_path(char *path, size_t len);
 
index 598a289abaff331a1985e99051d810513133f921..7b5a185d652533f80e3b207cd6961f34125f728e 100644 (file)
@@ -92,6 +92,7 @@ API int storage_get_root_directory(int storage_id, char **path)
        dd_list *elem;
        char root[PATH_MAX];
        int ret;
+       bool extendedint;
 
        if (storage_id < 0)
                return STORAGE_ERROR_NOT_SUPPORTED;
@@ -116,7 +117,7 @@ API int storage_get_root_directory(int storage_id, char **path)
        }
 
        /* external storage */
-       ret = storage_ext_get_root(storage_id, root, sizeof(root));
+       ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
        if (ret < 0) {
                _E("Failed to get root path of external storage(%d, %d", storage_id, ret); //LCOV_EXCL_LINE
                return STORAGE_ERROR_INVALID_PARAMETER;
@@ -140,6 +141,7 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
        int ret;
        dd_list *elem;
        bool found;
+       bool extendedint;
 
        if (storage_id < 0)
                return STORAGE_ERROR_NOT_SUPPORTED;
@@ -186,11 +188,14 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
                return STORAGE_ERROR_NOT_SUPPORTED;
        }
 
-       ret = storage_ext_get_root(storage_id, root, sizeof(root));
+       ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
        if (ret < 0) {
                _E("Failed to get root dir for external storage(id:%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
-               return STORAGE_ERROR_OPERATION_FAILED;
+               return STORAGE_ERROR_NOT_SUPPORTED;
        }
+       /* The operation is not decided */
+       if (extendedint)
+               return STORAGE_ERROR_NOT_SUPPORTED;
 
        snprintf(temp, sizeof(temp), "%s/%s", root, dir_path[type]);
 
@@ -208,6 +213,9 @@ API int storage_get_type(int storage_id, storage_type_e *type)
 {
        const struct storage_ops *st;
        dd_list *elem;
+       char root[PATH_MAX];
+       int ret;
+       bool extendedint;
 
        if (storage_id < 0)
                return STORAGE_ERROR_NOT_SUPPORTED;
@@ -226,7 +234,15 @@ API int storage_get_type(int storage_id, storage_type_e *type)
        }
 
        /* external storage */
-       *type = STORAGE_TYPE_EXTERNAL;
+       ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
+       if (ret < 0) {
+               _E("Failed to get type of external storage");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+       if (extendedint)
+               *type = STORAGE_TYPE_EXTENDED_INTERNAL;
+       else
+               *type = STORAGE_TYPE_EXTERNAL;
 
        return STORAGE_ERROR_NONE;
 }
@@ -471,7 +487,7 @@ API int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback,
                return STORAGE_ERROR_NOT_SUPPORTED;
        }
 
-       if (type != STORAGE_TYPE_EXTERNAL) {
+       if (type != STORAGE_TYPE_EXTERNAL && type != STORAGE_TYPE_EXTENDED_INTERNAL) {
                _E("Invalid type (%d)", type);
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
@@ -505,7 +521,7 @@ API int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callbac
                return STORAGE_ERROR_NOT_SUPPORTED;
        }
 
-       if (type != STORAGE_TYPE_EXTERNAL) {
+       if (type != STORAGE_TYPE_EXTERNAL && type != STORAGE_TYPE_EXTENDED_INTERNAL) {
                _E("Invalid type (%d)", type);
                return STORAGE_ERROR_INVALID_PARAMETER;
        }