Refactor the logic for OSP compatibility
authorHyunbin Lee <hyunbin.lee@samsung.com>
Mon, 3 Jun 2013 05:14:38 +0000 (14:14 +0900)
committerHyunbin Lee <hyunbin.lee@samsung.com>
Wed, 26 Jun 2013 09:16:04 +0000 (18:16 +0900)
Change-Id: I68e6b6293415d1049b3d35e2ee95269017232833
Signed-off-by: Hyunbin Lee <hyunbin.lee@samsung.com>
osp-env-config.c

index 5ae53be..33759a5 100644 (file)
@@ -54,8 +54,8 @@ static const char* _EXT_OSP_HOME_PATH = "/opt/storage/sdcard/osp/\0";
 
 struct _path_info
 {
-    char src_path[PATH_MAX];
-    char dest_path[PATH_MAX];
+       char src_path[PATH_MAX];
+       char dest_path[PATH_MAX];
 };
 
 struct _dir_info
@@ -101,39 +101,38 @@ get_package_id_from_app_rootpath(const char* app_rootpath, char* package_id)
        const char* p = NULL;
        if (strncmp(app_rootpath, "/opt/apps/org.tizen.", 19) == 0)
        {
-       p = strrchr(app_rootpath, '.') + 1;
+               p = strrchr(app_rootpath, '.') + 1;
        }
        else
        {
-       p = strrchr(app_rootpath, '/') + 1;
+               p = strrchr(app_rootpath, '/') + 1;
        }
        strncpy(package_id, p, _MAX_PACKAGEID_LENGTH);
-    package_id[_MAX_PACKAGEID_LENGTH] = '\0';
-
+       package_id[_MAX_PACKAGEID_LENGTH] = '\0';
        _SECURE_LOGI("package id: %s", package_id);
 }
 
 static void
 get_package_id_from_package_name(const char* package_name, char* package_id)
 {
-    char* tmpbuf = NULL;
-
-    if (strncmp(package_name, "com", 3) == 0)
-    {   // in case of com.samsung.#osp#[package_id]#[serviceid]
-        tmpbuf = strstr(package_name, "#osp#");
-        if (tmpbuf != NULL)
-        {
-            strncpy(package_id, tmpbuf + 5, _MAX_PACKAGEID_LENGTH);
-        }
-    }
-    else if (strncmp(package_name, "osp", 3) == 0)
-    {   // in case of osp.[package_id].#osp#[serviceid]
-        tmpbuf = strstr(package_name, "osp.");
-        if (tmpbuf != NULL)
-        {
-            strncpy(package_id, tmpbuf + 4, _MAX_PACKAGEID_LENGTH);
-        }
-    }
+       char* tmpbuf = NULL;
+
+       if (strncmp(package_name, "com", 3) == 0)
+       {   // in case of com.samsung.#osp#[package_id]#[serviceid]
+               tmpbuf = strstr(package_name, "#osp#");
+               if (tmpbuf != NULL)
+               {
+                       strncpy(package_id, tmpbuf + 5, _MAX_PACKAGEID_LENGTH);
+               }
+       }
+       else if (strncmp(package_name, "osp", 3) == 0)
+       {   // in case of osp.[package_id].#osp#[serviceid]
+               tmpbuf = strstr(package_name, "osp.");
+               if (tmpbuf != NULL)
+               {
+                       strncpy(package_id, tmpbuf + 4, _MAX_PACKAGEID_LENGTH);
+               }
+       }
        else if (strncmp(package_name, "org.tizen", 9) == 0)
        {
                // in case of org.tizen.[package_id]#[serviceid]
@@ -143,17 +142,16 @@ get_package_id_from_package_name(const char* package_name, char* package_id)
                        strncpy(package_id, tmpbuf + 10, _MAX_PACKAGEID_LENGTH);
                }
        }
-    else if (strlen(package_name) == 10)
-    {
+       else if (strlen(package_name) == 10)
+       {
                strncpy(package_id, package_name, _MAX_PACKAGEID_LENGTH);
-    }
-    else
-    {
-        LOGE("package name is invalid (%s)", package_name);
-    }
-
-    package_id[_MAX_PACKAGEID_LENGTH] = '\0';
+       }
+       else
+       {
+               LOGE("package name is invalid (%s)", package_name);
+       }
 
+       package_id[_MAX_PACKAGEID_LENGTH] = '\0';
        _SECURE_LOGI("package_id: %s", package_id);
 }
 
@@ -256,246 +254,249 @@ external_is_mounted(const char* pkgid)
 }
 
 static int
-mount_slp_paths(const char* app_rootpath)
+mount_native_paths(const char* app_rootpath)
 {
-    int i = 0;
-    static const struct _path_info mount_info[] = {
-        //{ "/bin",             "./bin" },
-        //{ "/boot",            "./boot" },
-        //{ "/cache",           "./cache" },
-        { "/csa",               "./csa" },
-        { "/dev",               "./dev" },
-        { "/dev/pts",           "./dev/pts" },
-        { "/dev/shm",           "./dev/shm" },
-        { "/etc",               "./etc" },
-        { "/lib",               "./lib" },
-        //{ "/lost+found",      "./lost+found" },
-        { "/media",             "./media" },
-        { "/mnt",               "./mnt" },
-        { "/opt",               "./opt" },
-        { "/opt/usr",           "./opt/usr" },
-        { "/opt/var/kdb/db",    "./opt/var/kdb/db" },
-        { "/opt/storage/sdcard","./opt/storage/sdcard" },
-        //{ "/packaging",       "./packaging" },
-        { "/proc",              "./proc" },
-        { "/sbin",              "./sbin" },
-        { "/smack",             "./smack" },
-        { "/srv",               "./srv" },
-        { "/sys",               "./sys" },
-        { "/sys/kernel/debug",  "./sys/kernel/debug" },
-        { "/tmp",               "./tmp" },
-        { "/usr",               "./usr" },
-        { "/var",               "./var" },
-        { "/var/run",           "./var/run" }
-    };
-
-    if (chdir(app_rootpath) != 0)
-    {
-        LOGE("chdir() failed path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
-        return -1;
-    }
-
-    for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
-    {
-        if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
-        {
-            LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
-                    mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
-
-            int j = 0;
-            for (j = i; j > 0; --j)
-            {
-                umount2(mount_info[j-1].dest_path, MNT_DETACH);
-            }
-            return -1;
-        }
-    }
-
-    return 0;
+       int i = 0;
+       static const struct _path_info mount_info[] =
+       {
+               //{ "/bin",                             "./bin" },
+               //{ "/boot",                    "./boot" },
+               //{ "/cache",                   "./cache" },
+               { "/csa",                               "./csa" },
+               { "/dev",                               "./dev" },
+               { "/dev/pts",                   "./dev/pts" },
+               { "/dev/shm",                   "./dev/shm" },
+               { "/etc",                               "./etc" },
+               { "/lib",                               "./lib" },
+               //{ "/lost+found",              "./lost+found" },
+               { "/media",                             "./media" },
+               { "/mnt",                               "./mnt" },
+               //{ "/packaging",               "./packaging" },
+               { "/proc",                              "./proc" },
+               { "/sbin",                              "./sbin" },
+               { "/smack",                             "./smack" },
+               { "/srv",                               "./srv" },
+               { "/sys",                               "./sys" },
+               { "/sys/kernel/debug",  "./sys/kernel/debug" },
+               { "/tmp",                               "./tmp" },
+               { "/usr",                               "./usr" },
+               { "/var",                               "./var" },
+               { "/var/run",                   "./var/run" },
+               { "/opt",                               "./opt" },
+               { "/opt/usr",                   "./opt/usr" },
+               { "/opt/var/kdb/db",    "./opt/var/kdb/db" },
+//             { "/opt/storage/sdcard","./opt/storage/sdcard" }
+       };
+
+       if (chdir(app_rootpath) != 0)
+       {
+               LOGE("chdir() failed path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+               return -1;
+       }
+
+       for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
+       {
+               if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+               {
+                       LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+                                       mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+                       int j = 0;
+                       for (j = i; j > 0; --j)
+                       {
+                               umount2(mount_info[j-1].dest_path, MNT_DETACH);
+                       }
+                       return -1;
+               }
+       }
+
+       return 0;
 }
 
 static int
 mount_osp_internal_paths(const char* app_rootpath, const char* pkgid)
 {
-    int i = 0;
-    char osp_share_pkgid_path[PATH_MAX] = {0, };
-    char osp_share2_pkgid_path[PATH_MAX] = {0, };
-    struct _path_info mount_info[] = {
-        { "\0",                    "./data/Share" },
-        { "\0",                    "./data/Share2" },
-        { "/opt/usr/share/.osp-compat/share",  "./Share" },
-        { "/opt/usr/share/.osp-compat/share2", "./Share2" },
-      //{ "/opt/osp/clipboard",    "./Clipboard" },
-      //{ "/opt/osp/partner/npki", "./NPKI" },
-      //{ "/opt/osp/system",       "./System" },
-      //{ "/opt/osp/Tmp",          "./Tmp" },
-        { "/opt/usr/media",        "./Media" }
-    };
-
-    strncpy(osp_share_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
-    strncat(osp_share_pkgid_path, "share/", 6);
-    strncat(osp_share_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(osp_share2_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
-    strncat(osp_share2_pkgid_path, "share2/", 7);
-    strncat(osp_share2_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(mount_info[0].src_path, osp_share_pkgid_path, strlen(osp_share_pkgid_path));
-    strncpy(mount_info[1].src_path, osp_share2_pkgid_path, strlen(osp_share2_pkgid_path));
-
-    if (chdir(app_rootpath) != 0)
-    {
-        LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
-        return -1;
-    }
-
-    for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
-    {
-        if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
-        {
-            LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
-                    mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
-
-            int j = 0;
-            for (j = i; j > 0; --j)
-            {
-                umount2(mount_info[j-1].dest_path, MNT_DETACH);
-            }
-            return -1;
-        }
-    }
-
-    return 0;
+       int i = 0;
+       char osp_share_pkgid_path[PATH_MAX] = {0, };
+       char osp_share2_pkgid_path[PATH_MAX] = {0, };
+       struct _path_info mount_info[] =
+       {
+               { "\0", "./data/Share" },
+               { "\0", "./data/Share2" },
+               { "/opt/usr/share/.osp-compat/share",   "./Share" },
+               { "/opt/usr/share/.osp-compat/share2",  "./Share2" },
+               //{ "/opt/osp/clipboard",   "./Clipboard" },
+               //{ "/opt/osp/partner/npki","./NPKI" },
+               //{ "/opt/osp/system",          "./System" },
+               //{ "/opt/osp/Tmp",                     "./Tmp" },
+               { "/opt/usr/media",                     "./Media" }
+       };
+
+       strncpy(osp_share_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
+       strncat(osp_share_pkgid_path, "share/", 6);
+       strncat(osp_share_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(osp_share2_pkgid_path, _OSP_COMPAT_SHARED_PATH, strlen(_OSP_COMPAT_SHARED_PATH));
+       strncat(osp_share2_pkgid_path, "share2/", 7);
+       strncat(osp_share2_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(mount_info[0].src_path, osp_share_pkgid_path, strlen(osp_share_pkgid_path));
+       strncpy(mount_info[1].src_path, osp_share2_pkgid_path, strlen(osp_share2_pkgid_path));
+
+       if (chdir(app_rootpath) != 0)
+       {
+               LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+               return -1;
+       }
+
+       for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); ++i)
+       {
+               if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+               {
+                       LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+                                       mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+                       int j = 0;
+                       for (j = i; j > 0; --j)
+                       {
+                               umount2(mount_info[j-1].dest_path, MNT_DETACH);
+                       }
+                       return -1;
+               }
+       }
+
+       return 0;
 }
 
 static int
 create_osp_external_paths(const char* app_rootpath, const char* pkgid)
 {
-    char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
-    char osp_ext_apps_pkgid_share_path[PATH_MAX] = {0, };
-    char osp_ext_apps_pkgid_share2_path[PATH_MAX] = {0, };
-    char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
-    char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
-       struct _dir_info external_dirs[] = {
-        { "./HomeExt",           0000, 0},
-        { "./ShareExt",          0000, 0},
-        { "./Share2Ext",         0000, 0},
-        { "/opt/storage/sdcard/osp",           0777,   0 },
-        { "/opt/storage/sdcard/osp/apps",      0777,   0 },
-        { "/opt/storage/sdcard/osp/share",     0777,   0 },
-        { "/opt/storage/sdcard/osp/share2",    0777,   0 },
-        { "\0", 0777, 0},
-        { "\0", 0777, 0},
-        { "\0", 0777, 0},
-        { "\0", 0777, 0},
-        { "\0", 0777, 0},
-        { "/opt/storage/sdcard/Images",        0777,   0 },
-        { "/opt/storage/sdcard/Sounds",        0777,   0 },
-        { "/opt/storage/sdcard/Videos",        0777,   0 },
-      //{ "/opt/storage/sdcard/Themes",        0777,   0 },
-        { "/opt/storage/sdcard/Others",        0777,   0 }
+       char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
+       char osp_ext_apps_pkgid_share_path[PATH_MAX] = {0, };
+       char osp_ext_apps_pkgid_share2_path[PATH_MAX] = {0, };
+       char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
+       char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
+       struct _dir_info external_dirs[] =
+       {
+               { "./HomeExt",          0000,   0 },
+               { "./ShareExt",         0000,   0 },
+               { "./Share2Ext",        0000,   0 },
+               { "/opt/storage/sdcard/osp",            0777,   0 },
+               { "/opt/storage/sdcard/osp/apps",       0777,   0 },
+               { "/opt/storage/sdcard/osp/share",      0777,   0 },
+               { "/opt/storage/sdcard/osp/share2",     0777,   0 },
+               { "\0", 0777,   0},
+               { "\0", 0777,   0},
+               { "\0", 0777,   0},
+               { "\0", 0777,   0},
+               { "\0", 0777,   0},
+               { "/opt/storage/sdcard/Images", 0777,   0 },
+               { "/opt/storage/sdcard/Sounds", 0777,   0 },
+               { "/opt/storage/sdcard/Videos", 0777,   0 },
+               { "/opt/storage/sdcard/Others", 0777,   0 }
        };
-    int i = 0;
-
-    strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
-    strncat(osp_ext_apps_pkgid_path, "apps/", 5);
-    strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(osp_ext_apps_pkgid_share_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
-    strncat(osp_ext_apps_pkgid_share_path, "/Share", 6);
-
-    strncpy(osp_ext_apps_pkgid_share2_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
-    strncat(osp_ext_apps_pkgid_share2_path, "/Share2", 7);
-
-    strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
-    strncat(osp_ext_share_pkgid_path, "share/", 6);
-    strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
-    strncat(osp_ext_share2_pkgid_path, "share2/", 7);
-    strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(external_dirs[7].path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
-    strncpy(external_dirs[8].path, osp_ext_apps_pkgid_share_path, strlen(osp_ext_apps_pkgid_share_path));
-    strncpy(external_dirs[9].path, osp_ext_apps_pkgid_share2_path, strlen(osp_ext_apps_pkgid_share2_path));
-    strncpy(external_dirs[10].path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
-    strncpy(external_dirs[11].path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
-
-    if (chdir(app_rootpath) != 0)
-    {
-        LOGE("chdir() failed (%s), path: %s", strerror(errno), app_rootpath);
-        return -1;
-    }
-
-    for (i = 0; i < sizeof(external_dirs)/sizeof(struct _dir_info); i++)
-    {
-        int ret = mkdir(external_dirs[i].path, external_dirs[i].mode);
-        if (ret == -1 && errno != 17) // EEXIST
-        {
-            LOGE("mkdir() failed, path: %s, errno: %d (%s)", external_dirs[i].path, errno, strerror(errno));
-            return -1;
-        }
-    }
-
-    return 0;
+       int i = 0;
+
+       strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+       strncat(osp_ext_apps_pkgid_path, "apps/", 5);
+       strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(osp_ext_apps_pkgid_share_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+       strncat(osp_ext_apps_pkgid_share_path, "/Share", 6);
+
+       strncpy(osp_ext_apps_pkgid_share2_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+       strncat(osp_ext_apps_pkgid_share2_path, "/Share2", 7);
+
+       strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+       strncat(osp_ext_share_pkgid_path, "share/", 6);
+       strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+       strncat(osp_ext_share2_pkgid_path, "share2/", 7);
+       strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(external_dirs[7].path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+       strncpy(external_dirs[8].path, osp_ext_apps_pkgid_share_path, strlen(osp_ext_apps_pkgid_share_path));
+       strncpy(external_dirs[9].path, osp_ext_apps_pkgid_share2_path, strlen(osp_ext_apps_pkgid_share2_path));
+       strncpy(external_dirs[10].path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
+       strncpy(external_dirs[11].path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
+
+       if (chdir(app_rootpath) != 0)
+       {
+               LOGE("chdir() failed (%s), path: %s", strerror(errno), app_rootpath);
+               return -1;
+       }
+
+       for (i = 0; i < sizeof(external_dirs)/sizeof(struct _dir_info); i++)
+       {
+               int ret = mkdir(external_dirs[i].path, external_dirs[i].mode);
+               if (ret == -1 && errno != 17) // EEXIST
+               {
+                       LOGE("mkdir() failed, path: %s, errno: %d (%s)", external_dirs[i].path, errno, strerror(errno));
+                       return -1;
+               }
+       }
+
+       return 0;
 }
 
 static int
 mount_osp_external_paths(const char* app_rootpath, const char* pkgid)
 {
-    char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
-    char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
-    char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
-    struct _path_info mount_info[] = {
-        { "/opt/storage/sdcard",  "./Storagecard/Media" },
-        { "/opt/storage/sdcard/osp/share",  "./ShareExt" },
-        { "/opt/storage/sdcard/osp/share2", "./Share2Ext" },
-        { "\0",  "./HomeExt" },
-        { "\0",  "./HomeExt/Share" },
-        { "\0",  "./HomeExt/Share2" },
-    };
-    int i = 0;
-
-    strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
-    strncat(osp_ext_apps_pkgid_path, "apps/", 5);
-    strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
-    strncat(osp_ext_share_pkgid_path, "share/", 6);
-    strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
-    strncat(osp_ext_share2_pkgid_path, "share2/", 7);
-    strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
-
-    strncpy(mount_info[3].src_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
-    strncpy(mount_info[4].src_path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
-    strncpy(mount_info[5].src_path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
-
-    if (chdir(app_rootpath) != 0)
-    {
-        LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
-        return -1;
-    }
-    LOGI("app_rootpath: %s", app_rootpath);
-
-    for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); i++)
-    {
-        if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
-        {
-            LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
-                    mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
-
-            int j = 0;
-            for (j = i; j > 0; --j)
-            {
-                umount2(mount_info[j-1].dest_path, MNT_DETACH);
-            }
-            return -1;
-        }
-    }
-
-    return 0;
+       char osp_ext_apps_pkgid_path[PATH_MAX] = {0, };
+       char osp_ext_share_pkgid_path[PATH_MAX] = {0, };
+       char osp_ext_share2_pkgid_path[PATH_MAX] = {0, };
+       struct _path_info mount_info[] =
+       {
+               { "/opt/storage/sdcard",                        "./Storagecard/Media"   },
+               { "/opt/storage/sdcard/osp/share",      "./ShareExt"                    },
+               { "/opt/storage/sdcard/osp/share2",     "./Share2Ext"                   },
+               { "\0", "./HomeExt"                     },
+               { "\0", "./HomeExt/Share"       },
+               { "\0", "./HomeExt/Share2"      }
+       };
+       int i = 0;
+
+       strncpy(osp_ext_apps_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+       strncat(osp_ext_apps_pkgid_path, "apps/", 5);
+       strncat(osp_ext_apps_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(osp_ext_share_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+       strncat(osp_ext_share_pkgid_path, "share/", 6);
+       strncat(osp_ext_share_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(osp_ext_share2_pkgid_path, _EXT_OSP_HOME_PATH, strlen(_EXT_OSP_HOME_PATH));
+       strncat(osp_ext_share2_pkgid_path, "share2/", 7);
+       strncat(osp_ext_share2_pkgid_path, pkgid, strlen(pkgid));
+
+       strncpy(mount_info[3].src_path, osp_ext_apps_pkgid_path, strlen(osp_ext_apps_pkgid_path));
+       strncpy(mount_info[4].src_path, osp_ext_share_pkgid_path, strlen(osp_ext_share_pkgid_path));
+       strncpy(mount_info[5].src_path, osp_ext_share2_pkgid_path, strlen(osp_ext_share2_pkgid_path));
+
+       if (chdir(app_rootpath) != 0)
+       {
+               LOGE("chdir() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
+               return -1;
+       }
+       LOGI("app_rootpath: %s", app_rootpath);
+
+       for (i = 0; i < sizeof(mount_info)/sizeof(struct _path_info); i++)
+       {
+               if (mount(mount_info[i].src_path, mount_info[i].dest_path, NULL, MS_BIND, NULL) != 0)
+               {
+                       LOGE("mount() failed, src path: %s, dest path: %s, errno: %d (%s)",
+                                       mount_info[i].src_path, mount_info[i].dest_path, errno, strerror(errno));
+
+                       int j = 0;
+                       for (j = i; j > 0; --j)
+                       {
+                               umount2(mount_info[j-1].dest_path, MNT_DETACH);
+                       }
+                       return -1;
+               }
+       }
+
+       return 0;
 }
 
 int
@@ -505,9 +506,9 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
        char osp_app_data_path[PATH_MAX] = {0, };
        //char internal_installed = 1; // true
        int mmc_mounted = 0;
-    struct statfs fs;
+       struct statfs fs;
 
-       /* e.g., app_rootdir is "/opt/apps/com.samsung.basicapp or /opt/osp/applications/[appId] */
+       /* e.g., app_rootdir is "/opt/usr/apps/[pkgId] */
        app_rootpath = get_app_rootpath_from_path(bin_path);
 
        _SECURE_LOGI("[data_caging] do_pre_exe() was called, package name: %s, package id: %s, binary: %s, app root: %s",
@@ -517,44 +518,47 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
 
        // TODO: Check whether the application is installed in internal or external storage.
        // Check installation position using the input path.
-    //if (internal_installed)
-    //{
-
-    if (!internal_is_mounted(package_id))
-    {
-        if (mount_slp_paths(app_rootpath) != 0)
-            goto ERROR;
-
-        if (mount_osp_internal_paths(app_rootpath, package_id) != 0)
-            goto ERROR;
-    }
-
-    int ret = 0;
-    ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_mounted);
-    if (ret < 0)
-    {
-        LOGE("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
-    }
-    if (mmc_mounted == 1)
-    {
-        LOGI("MMC is mounted.");
-        if (create_osp_external_paths(app_rootpath, package_id) != 0)
-        {
-            goto ERROR;
-        }
-
-        if (!external_is_mounted(package_id))
-        {
-            if (mount_osp_external_paths(app_rootpath, package_id) != 0)
-            {
-                goto ERROR;
-            }
-        }
-    }
-    /*}
-       else
+       //if (internal_installed)
+       //{
+
+       if (!internal_is_mounted(package_id))
+       {
+               if (mount_native_paths(app_rootpath) != 0)
+               {
+                       goto ERROR;
+               }
+               if (mount_osp_internal_paths(app_rootpath, package_id) != 0)
+               {
+                       goto ERROR;
+               }
+       }
+
+       int ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &mmc_mounted);
+       if (ret < 0)
+       {
+               LOGE("vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS) failed.");
+       }
+       if (mmc_mounted == 1)
        {
-           // TODO mount_external_paths(app_rootpath);
+               LOGI("MMC is mounted.");
+               if (create_osp_external_paths(app_rootpath, package_id) != 0)
+               {
+                       goto ERROR;
+               }
+
+               if (!external_is_mounted(package_id))
+               {
+                       if (mount_osp_external_paths(app_rootpath, package_id) != 0)
+                       {
+                               goto ERROR;
+                       }
+               }
+       }
+
+       /*}
+         else
+         {
+       // TODO mount_external_paths(app_rootpath);
        }*/
        LOGI("mount() succeeded.");
 
@@ -563,7 +567,7 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
                LOGE("chroot() failed, path: %s, errno: %d (%s)", app_rootpath, errno, strerror(errno));
                goto ERROR;
        }
-    if (chdir("/") != 0)
+       if (chdir("/") != 0)
        {
                LOGE("chdir() failed, path: /, errno: %d (%s)", errno, strerror(errno));
                goto ERROR;
@@ -583,29 +587,29 @@ do_pre_exe(const char* package_name, const char* bin_path, const char* package_i
        }
 
        free(app_rootpath);
-    umask(0022);
+       umask(0022);
 
        LOGI("[data_caging] do_pre_exec() succeeded.");
        return 0;
 
 ERROR:
-    free(app_rootpath);
-    umask(0022);
+       free(app_rootpath);
+       umask(0022);
 
        LOGI("[data_caging] do_pre_exec() failed.");
-    return -1;
+       return -1;
 }
 
 int
 do_pre_exec(const char* package_name, const char* bin_path)
 {
        char* app_rootpath = NULL;
-    char app_compat_path[PATH_MAX] = { 0, };
-    const char app_compat_file[] = "/info/compat.info\0";
-    int pathlen = 0;
-    char package_id[_MAX_PACKAGEID_LENGTH + 1] = { 0, };
-    char osp_app_data_path[PATH_MAX] = { 0, };
-    int osp_compat = 0;
+       char app_compat_path[PATH_MAX] = { 0, };
+       const char app_compat_file[] = "/info/compat.info\0";
+       int pathlen = 0;
+       char package_id[_MAX_PACKAGEID_LENGTH + 1] = { 0, };
+       char osp_app_data_path[PATH_MAX] = { 0, };
+       int osp_compat = 0;
 
        _SECURE_LOGI("do_pre_exec() is called, package name: %s, binary path: %s", package_name, bin_path);
 
@@ -613,38 +617,38 @@ do_pre_exec(const char* package_name, const char* bin_path)
 
        strncpy(app_compat_path, app_rootpath, strlen(app_rootpath));
        strncat(app_compat_path, app_compat_file, strlen(app_compat_file));
-    if (access(app_compat_path, F_OK) == 0)
-    {
-        osp_compat = 1;
-    }
-
-    // XXX: temp code
-    //if (package_name == NULL)
-    {
-        //LOGI("The package name is empty.");
-        get_package_id_from_app_rootpath(app_rootpath, package_id);
-    }
+       if (access(app_compat_path, F_OK) == 0)
+       {
+               osp_compat = 1;
+       }
+
+       // XXX: temp code
+       //if (package_name == NULL)
+       {
+               //LOGI("The package name is empty.");
+               get_package_id_from_app_rootpath(app_rootpath, package_id);
+       }
 #if 0
-    else
-    {
-        get_package_id_from_package_name(package_name, package_id);
-    }
+       else
+       {
+               get_package_id_from_package_name(package_name, package_id);
+       }
 #endif
-    // XXX-end
+       // XXX-end
 
        _SECURE_LOGI("package: %s (%s), binary: %s, OSP compat: %d", package_name, package_id, bin_path, osp_compat);
 
        // FIXME: Temporary code with security risk
        prctl(PR_SET_KEEPCAPS, 1);
 
-    if (osp_compat == 1)
-    {
+       if (osp_compat == 1)
+       {
                free(app_rootpath);
                //unshare(CLONE_NEWNS);
                return do_pre_exe(package_name, bin_path, package_id);
-    }
+       }
 
-    // API version is equal to or greater than Tizen 2.0
+       // API version is equal to or greater than Tizen 2.0
        // Set current working dir to "/opt/apps/{pkgId}/data"
        strncpy(osp_app_data_path, app_rootpath, strlen(app_rootpath));
        strncat(osp_app_data_path, "/data", strlen("/data"));