SysLog(NID_IO, "ConvertNativeErrorToResult received : %d\n", errNo);
result r = E_SUCCESS;
//Covert the SLP response to Osp response
- switch(errNo)
- {
+ switch(errNo)
+ {
case 0:
r = E_SUCCESS;
break;
default:
r = E_SYSTEM;
- }
+ }
return r;
}
_MmcStorageManagerService::_MmcStorageManagerService(void)
: __pStub(null)
+ , __pVirtualRootList(null)
{
+ __pVirtualRootList = new (std::nothrow) LinkedList(SingleObjectDeleter);
}
_MmcStorageManagerService::~_MmcStorageManagerService(void)
{
int ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, MmcEventVconfCallback);
+ delete __pVirtualRootList;
}
_MmcStorageManagerService*
int ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, MmcEventVconfCallback, this);
SysTryReturnResult(NID_IO, ret == 0, E_SYSTEM, "Failed to register MMC event vconf callback.");
+ SysLog(NID_IO, "MMC callback is successfully registered.");
return E_SUCCESS;
}
{
char srcPath[_MAX_EXT_SRC_DIR_COUNT][_MAX_PATH_LENGTH];
char destPath[_MAX_EXT_DEST_DIR_COUNT][_MAX_PATH_LENGTH];
+ bool compat = false;
SysLog(NID_IO, "MMC event occurs.");
_AppList::const_iterator iter;
for (iter = pMmcMgr->__appList.begin(); iter != pMmcMgr->__appList.end(); ++iter)
{
+ compat = true;
const String* pAppRoot = iter->second;
if (pAppRoot != null)
{
/*
- /opt/storage/sdcard -> {app-root}/opt/storage/sdcard: It is mounted by system.
/opt/storage/sdcard/osp/apps/pkgId -> {app-root}/HomeExt
/opt/storage/sdcard/osp/share -> {app-root}/ShareExt
/opt/storage/sdcard/osp/share2 -> {app-root}/Share2Ext
SysLog(NID_IO, "OSP compatible application is unregistered.");
}
SysLog(NID_IO, "unmount() succeeded, mount flag: %s", mountFlag);
- }
- }
- }
+ }
+ }
+ }
+
+ // Checks virtual root application
+ IEnumerator* pEnum = pMmcMgr->__pVirtualRootList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ compat = false;
+ const String* pAppRoot = static_cast< String* >(pEnum->GetCurrent());
+ if (pAppRoot != null)
+ {
+ std::unique_ptr< char[] > pAppRootPath(_StringConverter::CopyToCharArrayN(*pAppRoot));
+ SysTryReturnVoidResult(NID_IO, pAppRootPath != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ String destPath(*pAppRoot);
+ destPath.Append(L"/virtual-root/opt/storage/sdcard");
+
+ std::unique_ptr< char[] > pDestPath(_StringConverter::CopyToCharArrayN(destPath));
+ SysTryReturnVoidResult(NID_IO, pDestPath != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ char* pPkgId = strrchr(pAppRootPath.get(), '/');
+ char mountFlag[_MAX_PATH_LENGTH] = { 0, };
+ sprintf(mountFlag, "%s/%s", _EXTERNAL_MOUNT_FLAG, ++pPkgId);
+
+ if (value == 1)
+ {
+ SysLog(NID_IO, "MMC mount event for virtual root application.");
+
+ res = access(mountFlag, F_OK);
+ if (res == -1 && errno == ENOENT)
+ {
+ if (access(pAppRootPath.get(), F_OK) == 0)
+ {
+ // /opt/storage/sdcard -> {app-root}/virtual-root/opt/storage/sdcard
+#ifdef _OSP_EMUL_
+ res = mount("/dev/mmcblk0", pDestPath.get(), "ext4", 0, "");
+#else
+ res = mount("/dev/mmcblk1p1", pDestPath.get(), "vfat", 0,
+ "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed,smackfsroot=*,smackfsdef=*");
+#endif
+
+ SysTryReturnVoidResult(NID_IO, res == 0, E_SYSTEM, "[E_SYSTEM] Failed to mount (%s), errno: %d (%s)",
+ pDestPath.get(), errno, strerror(errno));
+
+ r = _MmcStorageManagerService::CreateFlag(mountFlag);
+ if (IsFailed(r))
+ {
+ SysLogException(NID_IO, E_SYSTEM, "[%s] Failed to create mount flag (%s)",
+ GetErrorMessage(r), mountFlag);
+ res = umount2(pDestPath.get(), MNT_DETACH);
+ }
+ SysLog(NID_IO, "mount() succeeded, mount flag: %s", mountFlag);
+ }
+ }
+ else if (res == -1)
+ {
+ SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to access mount flag (%s), errno: %d (%s)",
+ mountFlag, errno, strerror(errno));
+ return;
+ }
+ else
+ {
+ SysLog(NID_IO, "mount() was already done.");
+ }
+ }
+ else
+ {
+ SysLog(NID_IO, "MMC unmount event for virtual root application.");
+
+ res = umount2(pDestPath.get(), MNT_DETACH);
+ SysTryLog(NID_IO, res == 0 || errno == EINVAL || errno == ENOENT,
+ "[E_SYSTEM] Failed to unmount (%s), errno: %d (%s)", pDestPath.get(), errno, strerror(errno));
+
+ if (access(mountFlag, F_OK) == 0)
+ {
+ res = unlink(mountFlag);
+ SysTryReturnVoidResult(NID_IO, res == 0, E_SYSTEM, "[E_SYSTEM] Failed to remove mount flag (%s), errno: %d (%s)",
+ mountFlag, errno, strerror(errno));
+ }
+
+ if (access(pAppRootPath.get(), F_OK) != 0 && errno == ENOENT)
+ {
+ pMmcMgr->__pVirtualRootList->Remove(*pAppRoot);
+ SysLog(NID_IO, "Virtual root application is unregistered.");
+ }
+ SysLog(NID_IO, "unmount() succeeded, mount flag: %s", mountFlag);
+ }
+ }
+ }
+
res = vconf_set_int(VCONFKEY_APPSERVICE_MMC_STATUS, value);
}
return;
CATCH:
- for (int i = _MAX_EXT_DIR_MOUNT_COUNT; i >= 0; --i)
+ if (compat == true)
{
- int res = umount2(destPath[i], MNT_DETACH);
- SysTryLog(NID_IO, res == 0 || errno == EINVAL || errno == ENOENT,
- "[E_SYSTEM] Failed to unmount (%s), errno: %d (%s)", destPath[i], errno, strerror(errno));
+ for (int i = _MAX_EXT_DIR_MOUNT_COUNT; i >= 0; --i)
+ {
+ int res = umount2(destPath[i], MNT_DETACH);
+ SysTryLog(NID_IO, res == 0 || errno == EINVAL || errno == ENOENT,
+ "[E_SYSTEM] Failed to unmount (%s), errno: %d (%s)", destPath[i], errno, strerror(errno));
+ }
}
return;
}