Apply new request from data disc 38/105638/5
authorYong Yeon Kim <yy9875.kim@samsung.com>
Fri, 16 Dec 2016 10:17:31 +0000 (19:17 +0900)
committerbeibei zhao <beibei.zhao@samsung.com>
Tue, 20 Dec 2016 07:11:53 +0000 (23:11 -0800)
Change-Id: I53140bd259a0dd89c265df8049f757a7df9af554
(cherry picked from commit 852e2791cc4ee5714a122154a0a99be4a9e73e30)

src/common/include/media-common-types.h
src/scanner-v2/include/media-scanner-common-v2.h
src/scanner-v2/media-scanner-common-v2.c
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner-v2/media-scanner-v2.c
src/server/media-server-main.c

index 1a17051..f690cdf 100755 (executable)
 #define MS_DISC_STATE "db/disc/mount/state"
 #define MS_DISC_PATH "memory/disc/info/mount_path"
 #define MS_DISC_TYPE "memory/disc/info/logical_type"
+#define MS_DISC_ACCESS_STATE "memory/disc/info/datadisc/access_state/mmfw"
+typedef enum {
+       MS_DISC_ACCESS = 1,     /**< The device's external storage */
+       MS_DISC_NOT_ACCESS = 2, /**< The external USB storage (Since 2.4) */
+} ms_disc_access_state_e;
 
 /*Use for Poweroff sequence*/
 #define POWEROFF -1 /*This number uses for stopping Scannig thread*/
index 30f6356..63eeecd 100644 (file)
@@ -29,5 +29,9 @@ int msc_set_mmc_status(ms_stg_status_e status);
 int msc_get_mmc_status(ms_stg_status_e *status);
 int msc_set_power_status(bool status);
 int msc_get_power_status(bool *status);
+int msc_set_disc_stg_scan_status(bool status);
+bool msc_get_disc_stg_scan_status(void);
+int msc_set_disc_dir_scan_status(bool status);
+bool msc_get_disc_dir_scan_status(void);
 
 #endif /*_MEDIA_SCANNER_COMMON_V2_H_*/
index b747376..c075a9c 100644 (file)
@@ -25,6 +25,8 @@
 
 int mmc_state2 = 0;
 bool power_off2;
+bool disc_stg_scan_status;
+bool disc_dir_scan_status;
 
 int msc_set_mmc_status(ms_stg_status_e status)
 {
@@ -54,3 +56,28 @@ int msc_get_power_status(bool *status)
        return MS_MEDIA_ERR_NONE;
 }
 
+int msc_set_disc_stg_scan_status(bool status)
+{
+       disc_stg_scan_status = status;
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+bool msc_get_disc_stg_scan_status(void)
+{
+       return disc_stg_scan_status;
+}
+
+int msc_set_disc_dir_scan_status(bool status)
+{
+       disc_dir_scan_status = status;
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+bool msc_get_disc_dir_scan_status(void)
+{
+       return disc_dir_scan_status;
+}
+
+
index 5c8d827..9b2e922 100755 (executable)
@@ -63,7 +63,7 @@ GMutex extract_data_mutex;
 #define LAST_EVENT 1
 #define NORMAL_EVENT 0
 
-static int __msc_check_extract_stop_status(int scan_type, ms_storage_type_t storage_type, const char *start_path, int pid);
+static int __msc_check_extract_stop_status(int scan_type, ms_storage_type_t storage_type, const char *start_path, int pid, bool is_end);
 static int __msc_set_storage_extract_status(ms_storage_scan_status_e status);
 static int __msc_get_storage_extract_status(ms_storage_scan_status_e *status);
 static int __msc_resume_extract();
@@ -77,7 +77,7 @@ typedef struct{
 
 #define SAFE_FREE(src)      { if(src) {free(src); src = NULL;}}
 
-static int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage_type, const char *path, int scan_type, int burst, int pid, uid_t uid, unsigned int *io_err_count);
+static int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage_type, const char *path, int scan_type, int burst, int pid, uid_t uid, unsigned int *io_err_count, bool is_end);
 
 int msc_init_extract_thread()
 {
@@ -111,7 +111,7 @@ int msc_deinit_extract_thread()
        return MS_MEDIA_ERR_NONE;
 }
 
-int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage_type, const char *path, int scan_type, int burst, int pid, uid_t uid, unsigned int *io_err_count)
+int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage_type, const char *path, int scan_type, int burst, int pid, uid_t uid, unsigned int *io_err_count, bool is_end)
 {
        MS_DBG_WARN("begin of __msc_folder_bulk_extract");
        int ret = MS_MEDIA_ERR_NONE;
@@ -134,6 +134,13 @@ int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage
        while (data_array->len != 0) {
                tmp_ret = MS_MEDIA_ERR_NONE;
                db_data = NULL;
+
+               tmp_ret = __msc_check_extract_stop_status(scan_type, storage_type, path, pid, is_end);
+               if (tmp_ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
+                       MS_DBG_ERR("__msc_folder_bulk_extract MS_MEDIA_ERR_SCANNER_FORCE_STOP");
+                       break;
+               }
+
                db_data = g_array_index(data_array, ms_item_info_s*, 0);
                g_array_remove_index (data_array, 0);
 
@@ -149,12 +156,6 @@ int __msc_folder_bulk_extract(void **handle, const char* storage_id, int storage
                        free(db_data);
                        db_data = NULL;
                }
-
-               tmp_ret = __msc_check_extract_stop_status(scan_type, storage_type, path, pid);
-               if (tmp_ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
-                       MS_DBG_ERR("__msc_folder_bulk_extract MS_MEDIA_ERR_SCANNER_FORCE_STOP");
-                       break;
-               }
        }
 
        if(extract_count > 0) {
@@ -191,6 +192,8 @@ gboolean msc_folder_extract_thread(void *data)
        char *update_path = NULL;
        unsigned int io_err_count = 0;
        uid_t uid = MEDIA_DEFAULT_UID;
+       int disc_state = 0;
+       int end_flag = NORMAL_EVENT;
 
        while (1) {
                extract_data = g_async_queue_pop(folder_extract_queue);
@@ -237,9 +240,10 @@ gboolean msc_folder_extract_thread(void *data)
                        ret = MS_MEDIA_ERR_INVALID_PARAMETER;
                        goto NEXT;
                }
+               end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
 
                storage_type = ms_get_storage_type_by_full(extract_data->msg, uid);
-               ret = __msc_check_extract_stop_status(extract_data->msg_type, storage_type, update_path, extract_data->pid);
+               ret = __msc_check_extract_stop_status(extract_data->msg_type, storage_type, update_path, extract_data->pid, end_flag);
 
                if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        MS_DBG_ERR("MS_MEDIA_ERR_SCANNER_FORCE_STOP");
@@ -247,8 +251,6 @@ gboolean msc_folder_extract_thread(void *data)
                }
 
                /*insert data into media db */
-               int end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
-
                ret = msc_check_db_size(uid, extract_data->msg_type);
                if (ret != MS_MEDIA_ERR_NONE) {
                        MS_DBG_ERR("NOT ENOUGH MEMORY");
@@ -259,7 +261,7 @@ gboolean msc_folder_extract_thread(void *data)
                }
 
                //ret = ms_insert_item_pass2(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag);
-               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag, extract_data->pid, uid, &io_err_count);
+               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag, extract_data->pid, uid, &io_err_count, end_flag);
 
 NEXT:
                if (power_off2) {
@@ -282,6 +284,16 @@ NEXT:
                g_directory_extract_processing = false;
                msc_del_cur_extract_item();
                msc_del_cancel_extract_item();
+               if (msc_get_disc_dir_scan_status()) {
+                       MS_DBG("[DISC ACCESS END]");
+                       msc_set_disc_dir_scan_status(false);
+
+                       ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
+                       if (disc_state == MS_DISC_ACCESS) {
+                               MS_DBG("[CHANGE DISC STATE]");
+                               ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
+                       }
+               }
 
                MS_DBG_WARN("DIRECTORY EXTRACT END [%d]", ret);
 
@@ -324,6 +336,8 @@ gboolean msc_storage_extract_thread(void *data)
        //GArray *dir_array = NULL;
        unsigned int io_err_count = 0;
        uid_t uid = MEDIA_DEFAULT_UID;
+       int disc_state = 0;
+       int end_flag = NORMAL_EVENT;
 
        while (1) {
                __msc_set_storage_extract_status(MS_STORAGE_SCAN_DONE);
@@ -336,7 +350,7 @@ gboolean msc_storage_extract_thread(void *data)
                __msc_set_storage_extract_status(MS_STORAGE_SCAN_META_PROCESSING);
 
                io_err_count = 0;
-               
+
                MS_DBG_WARN("STORAGE extract START extract len is %d ",         g_async_queue_length(storage_extract_queue));
 
                scan_type = extract_data->msg_type;
@@ -357,15 +371,32 @@ gboolean msc_storage_extract_thread(void *data)
                        continue;
                }
 
+               end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
                update_path = strndup(extract_data->msg, extract_data->msg_size);
                MS_DBG_WARN("extract storage_id is [%s], path [%s]", extract_data->storage_id, update_path);
 
                ms_set_storage_scan_status(handle, extract_data->storage_id, MEDIA_EXTRACT_PROCESSING, uid);
                __msc_extract_set_db_status(MS_DB_UPDATING);
 
-               ret = __msc_check_extract_stop_status(extract_data->msg_type, storage_type, update_path, extract_data->pid);
+               ret = __msc_check_extract_stop_status(extract_data->msg_type, storage_type, update_path, extract_data->pid, end_flag);
                if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
-                       MS_DBG_ERR("MS_MEDIA_ERR_SCANNER_FORCE_STOP");
+                       MS_DBG_ERR("MS_MEDIA_ERR_SCANNER_FORCE_STOP[%s]", update_path);
+                       if (end_flag) {
+                               __msc_extract_set_db_status(MS_DB_STOPPED);
+
+                               if (strncmp(update_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0) {
+                                       if (msc_get_disc_stg_scan_status()) {
+                                               MS_DBG("[DISC ACCESS STOP]");
+                                               msc_set_disc_stg_scan_status(false);
+
+                                               ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
+                                               if (disc_state == MS_DISC_ACCESS) {
+                                                       MS_DBG("[CHANGE DISC STATE]");
+                                                       ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
+                                               }
+                                       }
+                               }
+                       }
                        goto NEXT;
                }
 
@@ -373,15 +404,27 @@ gboolean msc_storage_extract_thread(void *data)
                if (ret != MS_MEDIA_ERR_NONE) {
                        MS_DBG_ERR("NOT ENOUGH MEMORY");
                        __msc_extract_set_db_status(MS_DB_STOPPED);
+                       if (strncmp(update_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0) {
+                               if (msc_get_disc_stg_scan_status()) {
+                                       MS_DBG("[DISC ACCESS STOP]");
+                                       msc_set_disc_stg_scan_status(false);
+
+                                       ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
+                                       if (disc_state == MS_DISC_ACCESS) {
+                                               MS_DBG("[CHANGE DISC STATE]");
+                                               ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
+                                       }
+                               }
+                       }
+
                        goto NEXT;
                }
 
                storage_type = ms_get_storage_type_by_full(extract_data->msg, uid);
 
                /*extract meta*/
-               int end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
                //ret = ms_insert_item_pass2(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag);
-               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag, extract_data->pid, uid, &io_err_count);
+               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag, extract_data->pid, uid, &io_err_count, end_flag);
 
                msc_del_extract_blocked_path();
 
@@ -394,12 +437,33 @@ gboolean msc_storage_extract_thread(void *data)
                        __msc_set_storage_extract_status(MS_STORAGE_SCAN_META_STOP);
                        /* set vconf key db extract status */
                        __msc_extract_set_db_status(MS_DB_STOPPED);
+                       if (msc_get_disc_stg_scan_status()) {
+                               MS_DBG("[DISC ACCESS STOP]");
+                               msc_set_disc_stg_scan_status(false);
+
+                               ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
+                               if (disc_state == MS_DISC_ACCESS) {
+                                       MS_DBG("[CHANGE DISC STATE]");
+                                       ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
+                               }
+                       }
                } else if (extract_data->result == TRUE) {
                        MS_DBG_WARN("extract_data->result == TRUE, MS_STORAGE_SCAN_COMPLETE");
                        ms_set_storage_scan_status(handle, extract_data->storage_id, MEDIA_EXTRACT_COMPLETE, uid);
                        __msc_set_storage_extract_status(MS_STORAGE_SCAN_COMPLETE);
                        /* set vconf key db extract status */
                        __msc_extract_set_db_status(MS_DB_UPDATED);
+                       if (msc_get_disc_stg_scan_status()) {
+                               MS_DBG("[DISC ACCESS END]");
+                               msc_set_disc_stg_scan_status(false);
+
+                               ms_config_get_int(MS_DISC_ACCESS_STATE, &disc_state);
+                               if (disc_state == MS_DISC_ACCESS) {
+                                       MS_DBG("[CHANGE DISC STATE]");
+                                       ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_NOT_ACCESS);
+                               }
+
+                       }
                }
 
 #if 0
@@ -693,7 +757,7 @@ int msc_del_extract_blocked_path(void)
        return MS_MEDIA_ERR_NONE;
 }
 
-static int __msc_check_extract_stop_status(int scan_type, ms_storage_type_t storage_type, const char *start_path, int pid)
+static int __msc_check_extract_stop_status(int scan_type, ms_storage_type_t storage_type, const char *start_path, int pid, bool is_end)
 {
        int ret = MS_MEDIA_ERR_NONE;
 
@@ -741,12 +805,16 @@ static int __msc_check_extract_stop_status(int scan_type, ms_storage_type_t stor
                /* check block path */
                if (g_extract_blocked_path != NULL) {
                        MS_DBG_WARN("check blocked storage [%s][%s]", g_extract_blocked_path, start_path);
-                       if (strncmp(start_path, g_extract_blocked_path, strlen(start_path)) == 0) {
+                       if (strncmp(start_path, g_extract_blocked_path, strlen(g_extract_blocked_path)) == 0) {
                                MS_DBG_ERR("Receive blocked message[%s][%s]. STOP extract!!", g_extract_blocked_path, start_path);
                                ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
                        }
-
-                       MS_SAFE_FREE(g_extract_blocked_path);
+                       if (is_end) {
+                               MS_DBG("[END REQUEST]");
+                               MS_SAFE_FREE(g_extract_blocked_path);
+                       } else {
+                               MS_DBG("[NOT END REQUEST]");
+                       }
                }
 
                g_mutex_unlock(&extract_blocked_mutex);
index b410c95..9e7b645 100755 (executable)
@@ -1267,6 +1267,11 @@ gboolean msc_directory_scan_thread(void *data)
                /*call for bundle commit*/
                ms_bacth_commit_enable(handle, TRUE, TRUE, MS_NOTI_SWITCH_OFF, 0);
 
+               if (strcmp(scan_data->msg, MEDIA_ROOT_PATH_DISC) == 0) {
+                       MS_DBG("[DATA DISC]");
+                       msc_set_disc_dir_scan_status(true);
+               }
+
                /*insert data into media db */
                ret = __msc_db_update(handle, storage_id, scan_data);
 
@@ -1614,6 +1619,11 @@ gboolean msc_storage_scan_thread(void *data)
                /*start db updating */
                ms_set_db_status(MS_DB_UPDATING, storage_type);
 
+               if (strcmp(update_path, MEDIA_ROOT_PATH_DISC) == 0) {
+                       MS_DBG("[DATA DISC]");
+                       msc_set_disc_stg_scan_status(true);
+               }
+
                valid_status = (scan_type == MS_MSG_STORAGE_PARTIAL || MS_MSG_STORAGE_ALL == scan_type) ? TRUE : FALSE;
 
                if (scan_type != MS_MSG_STORAGE_INVALID)
index f647b60..013672f 100755 (executable)
@@ -144,6 +144,84 @@ void _msc_mmc_vconf_cb(void *data)
        return;
 }
 
+#ifdef _USE_SENIOR_MODE
+extern GAsyncQueue *storage_queue2;
+extern GAsyncQueue *storage_extract_queue;
+extern int g_directory_scan_processing2;
+extern bool g_directory_extract_processing;
+
+void _msc_datadisc_vconf_cb(void *data)
+{
+       int disc_state = 0;
+       char *disc_type = NULL;
+       char *disc_path = NULL;
+       char *valid_type = "data";
+       char storage_path[11] = {0,};
+
+       /*check disc type */
+       if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
+               MS_DBG_ERR("Get MS_DISC_TYPE failed.");
+               goto END;
+       }
+
+       MS_DBG("[disc type] %s", disc_type);
+
+       if (strcmp(disc_type, valid_type) == 0) {
+               ms_config_get_int(MS_DISC_STATE, &disc_state);
+
+               if (disc_state == 1) {
+                       MS_DBG_WARN("[DISC INSERTED]");
+               } else {
+                       MS_DBG_WARN("[DISC REMOVED]");
+                       int status  = -1;
+
+                       /* check mount path */
+                       if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
+                               MS_DBG_ERR("Get MS_DISC_PATH failed.");
+                               goto END;
+                       }
+
+                       MS_DBG("[disc path] %s", disc_path);
+                       memset(storage_path, 0x0, sizeof(storage_path));
+                       strncpy(storage_path, disc_path, sizeof(storage_path)-1);
+
+                       if (msc_get_disc_dir_scan_status() ||
+                               msc_get_disc_stg_scan_status()) {
+                               MS_DBG("[DATA DISC IS READING]");
+                               ms_config_set_int(MS_DISC_ACCESS_STATE, MS_DISC_ACCESS);
+                       }
+
+                       if(!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status)) {
+                               MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
+                       }
+
+                       if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+                               msc_set_blocked_path(storage_path);
+                       }
+
+                       if (g_directory_scan_processing2 != 0) {
+                               MS_DBG_WARN("Doing directory scanning. Set cancel path");
+                               msc_set_cancel_scan_item(storage_path, -1);
+                       }
+
+                       if (!(g_async_queue_length(storage_extract_queue) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+                               msc_set_extract_blocked_path(storage_path);
+                       }
+
+                       if (g_directory_extract_processing == true) {
+                               MS_DBG_WARN("Doing directory extracting. Set cancel path");
+                               msc_set_cancel_extract_item(storage_path, -1);
+                       }
+               }
+       }
+
+END:
+       MS_SAFE_FREE(disc_type);
+
+       return;
+}
+#endif
+
 int main(int argc, char **argv)
 {
        GThread *storage_scan_thread = NULL;
@@ -290,6 +368,11 @@ static void __msc_add_event_receiver(void *data)
        /*set power off callback function*/
        ms_sys_set_poweroff_cb(__msc_power_off_cb, NULL);
        ms_sys_set_device_block_event_cb(msc_device_block_changed_cb, NULL);
+
+#ifdef _USE_SENIOR_MODE
+       if (vconf_notify_key_changed(MS_DISC_STATE, (vconf_callback_fn) _msc_datadisc_vconf_cb, NULL) == -1)
+               MS_DBG_ERR("add call back function for event %s fails", MS_DISC_STATE);
+#endif
 }
 
 static void __msc_remove_event_receiver(void)
index 6025ae0..e58514d 100755 (executable)
@@ -676,6 +676,95 @@ static int __ms_check_usb_status(void)
        return MS_MEDIA_ERR_NONE;
 }
 
+static int __ms_check_disc_status(void)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       int disc_state = 0;
+       int validity = 0;
+       char *disc_type = NULL;
+       char *disc_path = NULL;
+       char *valid_type = "data";
+       ms_dir_scan_type_t scan_type = MS_SCAN_PART;
+       uid_t uid = MEDIA_DEFAULT_UID;
+       char mnt_path[11] = {0,};
+       char *storage_path = NULL;
+       void **handle = NULL;
+
+       ms_config_get_int(MS_DISC_STATE, &disc_state);
+       if (disc_state == 1) {
+               /*check disc type */
+               if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
+                       MS_DBG_ERR("Get MS_DISC_TYPE failed.");
+                       goto END;
+               }
+
+               if (strcmp(disc_type, valid_type) == 0) {
+                       MS_DBG_WARN("[DISC INSERTED][%s]",disc_type);
+                       MS_DBG_WARN("MOUNT PATH [%s]", mnt_path);
+
+                       /* check mount path */
+                       if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
+                               MS_DBG_ERR("Get MS_DISC_PATH failed.");
+                               goto END;
+                       }
+
+                       MS_DBG("[disc path] %s", disc_path);
+                       memset(mnt_path, 0x0, sizeof(mnt_path));
+                       strncpy(mnt_path, disc_path, sizeof(mnt_path)-1);
+
+                       ret = ms_load_functions();
+                       if (ret != MS_MEDIA_ERR_NONE) {
+                               MS_DBG_ERR("ms_load_functions failed [%d]", ret);
+                               return;
+                       }
+
+                       /* request scanning */
+                       ms_sys_get_uid(&uid);
+
+                       ms_connect_db(&handle, uid);
+
+                                       /* update storage information into media DB */
+                       ret = ms_check_storage(handle, DATADISC_STORAGE_ID, NULL, &storage_path, &validity);
+                       if (ret == 0) {
+                               ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 1, uid);
+                               if (ms_set_storage_scan_status(handle, DATADISC_STORAGE_ID, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
+                                       MS_DBG_ERR("ms_set_storage_scan_status failed");
+                               }
+
+                               MS_DBG_WARN("init storage data in DB");
+                               /* update storage_id table set validity=0 first */
+                               ms_validaty_change_all_items(handle, DATADISC_STORAGE_ID, MS_STORAGE_EXTERNAL, false, uid);
+                               /*update folder table set validity = 0*/
+                               ms_set_folder_validity(handle, DATADISC_STORAGE_ID, mnt_path, MS_INVALID, TRUE, uid);
+                               /* update folder table set scan_status=0 first */
+                               ms_set_folder_scan_status(handle, DATADISC_STORAGE_ID, NULL, MS_DIR_SCAN_NONE, uid);
+                               MS_DBG_WARN("init storage data in DB end");
+
+                       } else {
+                               ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, NULL, mnt_path, uid);
+                               if (ret != MS_MEDIA_ERR_NONE) {
+                                       MS_DBG_ERR("ms_insert_storage failed");
+                                       goto END;
+                               }
+                       }
+
+                       ms_send_storage_scan_request(mnt_path, DATADISC_STORAGE_ID, scan_type, uid);
+
+                       ms_disconnect_db(&handle);
+
+                       ms_unload_functions();
+               }
+       }
+
+END:
+       MS_SAFE_FREE(disc_type);
+       MS_SAFE_FREE(disc_path);
+       MS_SAFE_FREE(storage_path);
+
+
+       return MS_MEDIA_ERR_NONE;
+}
+
 static void __ms_check_mediadb(void)
 {
 #ifndef _USE_MULTI_USER
@@ -731,6 +820,11 @@ static void __ms_check_mediadb(void)
        if (_USE_SDCARD)
                __ms_check_mmc_status();
        __ms_check_usb_status();
+
+#ifdef _USE_SENIOR_MODE
+       __ms_check_disc_status();
+#endif
+
 }
 
 static bool __ms_is_dcm_supported()