From d6d73985ed027e7f91bc06935be62ffb3ca2a8f0 Mon Sep 17 00:00:00 2001 From: Zheng Yongjun Date: Wed, 23 Feb 2022 10:12:41 +0800 Subject: [PATCH] =?UTF-8?q?1,=E5=A2=9E=E5=8A=A0el1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=9A=84mount=E7=82=B9=202,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0launcher=E5=BA=94=E7=94=A8=E7=9A=84=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=A4=84=E7=90=86=203,=E4=BF=AE=E5=A4=8D=E6=8E=89socket=20fd?= =?UTF-8?q?=E5=9C=A8=E9=94=99=E8=AF=AF=E8=B7=AF=E5=BE=84=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=B3=84=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zheng Yongjun --- src/appspawn_server.cpp | 53 ++++++++++++++++++++---------------- src/socket/client_socket.cpp | 2 ++ src/socket/server_socket.cpp | 1 + 3 files changed, 32 insertions(+), 24 deletions(-) mode change 100755 => 100644 src/appspawn_server.cpp diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp old mode 100755 new mode 100644 index 1ad7b0a3..2b422d60 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -418,26 +418,34 @@ int32_t AppSpawnServer::DoAppSandboxMountOnce(const std::string originPath, cons return 0; } -int32_t AppSpawnServer::DoAppSandboxMount(const ClientSocket::AppProperty *appProperty, std::string rootPath) +int32_t AppSpawnServer::DoAppSandboxMount(const ClientSocket::AppProperty *appProperty, + std::string rootPath) { std::string currentUserId = std::to_string(appProperty->uid / UID_BASE); std::string oriInstallPath = "/data/app/el1/bundle/public/"; - std::string oriDataPath = "/data/app/el2/" + currentUserId + "/base/"; + std::string oriel1DataPath = "/data/app/el1/" + currentUserId + "/base/"; + std::string oriel2DataPath = "/data/app/el2/" + currentUserId + "/base/"; std::string oriDatabasePath = "/data/app/el2/" + currentUserId + "/database/"; + const std::string oriappdataPath = "/data/accounts/account_0/appdata/"; std::string destDatabasePath = rootPath + "/data/storage/el2/database"; std::string destInstallPath = rootPath + "/data/storage/el1/bundle"; - std::string destDataPath = rootPath + "/data/storage/el2/base"; + std::string destel1DataPath = rootPath + "/data/storage/el1/base"; + std::string destel2DataPath = rootPath + "/data/storage/el2/base"; + std::string destappdataPath = rootPath + oriappdataPath; int rc = 0; std::string bundleName = appProperty->bundleName; oriInstallPath += bundleName; - oriDataPath += bundleName; + oriel1DataPath += bundleName; + oriel2DataPath += bundleName; oriDatabasePath += bundleName; std::map mountMap; mountMap[destDatabasePath] = oriDatabasePath; mountMap[destInstallPath] = oriInstallPath; - mountMap[destDataPath] = oriDataPath; + mountMap[destel1DataPath] = oriel1DataPath; + mountMap[destel2DataPath] = oriel2DataPath; + mountMap[destappdataPath] = oriappdataPath; std::map::iterator iter; for (iter = mountMap.begin(); iter != mountMap.end(); ++iter) { @@ -447,19 +455,6 @@ int32_t AppSpawnServer::DoAppSandboxMount(const ClientSocket::AppProperty *appPr } } - // Add distributedfile module support, later reconstruct it - std::string oriDistributedPath = "/mnt/hmdfs/" + currentUserId + "/account/merge_view/data/" + bundleName; - std::string destDistributedPath = rootPath + "/data/storage/el2/distributedfiles"; - DoAppSandboxMountOnce(oriDistributedPath.c_str(), destDistributedPath.c_str()); - - std::string oriDistributedGroupPath = "/mnt/hmdfs/" + currentUserId + "/non_account/merge_view/data/" + bundleName; - std::string destDistributedGroupPath = rootPath + "/data/storage/el2/auth_groups"; - DoAppSandboxMountOnce(oriDistributedGroupPath.c_str(), destDistributedGroupPath.c_str()); - - const std::string oriappdataPath = "/data/accounts/account_0/appdata/"; - std::string destappdataPath = rootPath + oriappdataPath; - DoAppSandboxMountOnce(oriappdataPath.c_str(), destappdataPath.c_str()); - // to create some useful dir when mount point created std::vector mkdirInfo; std::string dirPath; @@ -474,12 +469,6 @@ int32_t AppSpawnServer::DoAppSandboxMount(const ClientSocket::AppProperty *appPr mkdir(dirPath.c_str(), FILE_MODE); } - // do webview adaption - std::string oriwebviewPath = "/data/app/el1/bundle/public/com.ohos.webviewhap"; - std::string destwebviewPath = destInstallPath + "/webview"; - chmod(destwebviewPath.c_str(), WEBVIEW_FILE_MODE); - DoAppSandboxMountOnce(oriwebviewPath.c_str(), destwebviewPath.c_str()); - return 0; } @@ -487,6 +476,7 @@ int32_t AppSpawnServer::DoAppSandboxMountCustomized(const ClientSocket::AppPrope { std::string bundleName = appProperty->bundleName; std::string currentUserId = std::to_string(appProperty->uid / UID_BASE); + std::string destInstallPath = rootPath + "/data/storage/el1/bundle"; // account_0/applications/ dir can still access other packages' data now for compatibility purpose std::string oriapplicationsPath = "/data/app/el1/bundle/public/"; @@ -497,6 +487,21 @@ int32_t AppSpawnServer::DoAppSandboxMountCustomized(const ClientSocket::AppPrope std::string destbundlesPath = rootPath + "/data/bundles/"; DoAppSandboxMountOnce(oriapplicationsPath.c_str(), destbundlesPath.c_str()); + // Add distributedfile module support, later reconstruct it + std::string oriDistributedPath = "/mnt/hmdfs/" + currentUserId + "/account/merge_view/data/" + bundleName; + std::string destDistributedPath = rootPath + "/data/storage/el2/distributedfiles"; + DoAppSandboxMountOnce(oriDistributedPath.c_str(), destDistributedPath.c_str()); + + std::string oriDistributedGroupPath = "/mnt/hmdfs/" + currentUserId + "/non_account/merge_view/data/" + bundleName; + std::string destDistributedGroupPath = rootPath + "/data/storage/el2/auth_groups"; + DoAppSandboxMountOnce(oriDistributedGroupPath.c_str(), destDistributedGroupPath.c_str()); + + // do webview adaption + std::string oriwebviewPath = "/data/app/el1/bundle/public/com.ohos.webviewhap"; + std::string destwebviewPath = destInstallPath + "/webview"; + chmod(destwebviewPath.c_str(), WEBVIEW_FILE_MODE); + DoAppSandboxMountOnce(oriwebviewPath.c_str(), destwebviewPath.c_str()); + if (bundleName.find("medialibrary") != std::string::npos) { std::string oriMediaPath = "/storage/media/" + currentUserId; std::string destMediaPath = rootPath + "/storage/media"; diff --git a/src/socket/client_socket.cpp b/src/socket/client_socket.cpp index 44ea1688..308f389c 100644 --- a/src/socket/client_socket.cpp +++ b/src/socket/client_socket.cpp @@ -63,12 +63,14 @@ int ClientSocket::ConnectSocket(int connectFd) } if (PackSocketAddr() != 0) { + CloseSocket(connectFd); return -1; } if ((setsockopt(connectFd, SOL_SOCKET, SO_RCVTIMEO, &SOCKET_TIMEOUT, sizeof(SOCKET_TIMEOUT)) != 0) || (setsockopt(connectFd, SOL_SOCKET, SO_SNDTIMEO, &SOCKET_TIMEOUT, sizeof(SOCKET_TIMEOUT)) != 0)) { HiLog::Warn(LABEL, "Client: Failed to set opt of socket %d, err %d", connectFd, errno); + CloseSocket(connectFd); return -1; } diff --git a/src/socket/server_socket.cpp b/src/socket/server_socket.cpp index 05671538..6a632b63 100644 --- a/src/socket/server_socket.cpp +++ b/src/socket/server_socket.cpp @@ -207,6 +207,7 @@ int ServerSocket::WaitForConnection(int connectFd) if ((setsockopt(connFd, SOL_SOCKET, SO_RCVTIMEO, &SOCKET_TIMEOUT, sizeof(SOCKET_TIMEOUT)) < 0) || (setsockopt(connFd, SOL_SOCKET, SO_SNDTIMEO, &SOCKET_TIMEOUT, sizeof(SOCKET_TIMEOUT)) < 0)) { HiLog::Warn(LABEL, "Server: Failed to set opt of Connection %d, err %d", connFd, errno); + close(connFd); return (-errno); } -- Gitee