[M120 Migration][VD] Add waiting for RW image mount 84/311184/2 submit/tizen/20240517.160021
authorjiangyuwei <yuwei.jiang@samsung.com>
Thu, 16 May 2024 01:56:08 +0000 (09:56 +0800)
committerBot Blink <blinkbot@samsung.com>
Fri, 17 May 2024 12:07:55 +0000 (12:07 +0000)
When UWE is used but RW image was not mounted yet,
Engine could wrongly dlopen RO package.

This patch adds additional waiting for RW mount
to prevent from opening RO package by mistake.

Max waiting time for RW mount: 10s

Reference:
  - https://review.tizen.org/gerrit/301389/

Change-Id: Ie83cde9ac0fe41391ecc6f01887da52d3d431c89
Signed-off-by: jiangyuwei <yuwei.jiang@samsung.com>
tizen_src/downloadable/chromium_efl_install.cc

index a1694fc5aaeb6bf2f3a13da4d9754a701f992a09..a382e4fbb15a4470c8c7390dbe5cd4b3a62c8bd4 100644 (file)
@@ -73,7 +73,10 @@ __attribute__((destructor)) void close_log_file() {
 #define SUCCESS 0
 #define FAIL -1
 
-const char* kChromiumMountReady = "/tmp/.chromium_mount.ready";
+const char* kChromiumUpdateOrPreloadMountReady =
+    "/tmp/.chromium_update_or_preload_mount.ready";
+const char* kChromiumUpgradeMountReady = "/tmp/.chromium_upgrade_mount.ready";
+const char* kChromiumUpgradeTPKExists = "/tmp/.chromium_upgrade_tpk.exists";
 const char* kColdBootRequester = "chromium-efl";
 const char* kLaunchFail = "rtc/memory/WebApp/LaunchFail";
 const char* kPSAgentReady = "/run/ps_agent.pid";
@@ -153,12 +156,6 @@ static int mount(bool mount, const char* args, bool use_system = false) {
     return FAIL;
   }
 
-  if (LwipcEventDone(kChromiumMountReady) < 0) {
-    // The Lwipc api simply calls the ioctl() inside the function.
-    // Failure of this API means that there are some kernel issues.
-    LOG(ERROR) << kChromiumMountReady << " Event Failed.";
-  }
-
   return SUCCESS;
 }
 
@@ -166,10 +163,10 @@ static int MountPatchedTPK() {
   int result = FAIL;
   if (!access(LIB_RO_ROOT_DIR "/version", F_OK)) {
     LOG(INFO) << LIB_RO_ROOT_DIR "/version file already exists.";
-    if (LwipcEventDone(kChromiumMountReady) < 0) {
+    if (LwipcEventDone(kChromiumUpdateOrPreloadMountReady) < 0) {
       // The Lwipc api simply calls the ioctl() inside the function.
       // Failure of this API means that there are some kernel issues.
-      LOG(ERROR) << kChromiumMountReady << " Event Failed.";
+      LOG(ERROR) << kChromiumUpdateOrPreloadMountReady << " Event Failed.";
     }
     return SUCCESS;
   }
@@ -178,17 +175,43 @@ static int MountPatchedTPK() {
     LOG(INFO) << PATH_UPDATED_CHROMIUM_EFL_IMG << " exists.";
     kTargetTPK = "WebEngine Updated TPK ";
     result = mount(true, MOUNT_ARGS_UPDATED_CHROMIUM);
+
+    if (LwipcEventDone(kChromiumUpdateOrPreloadMountReady) < 0) {
+      // The Lwipc api simply calls the ioctl() inside the function.
+      // Failure of this API means that there are some kernel issues.
+      LOG(ERROR) << kChromiumUpdateOrPreloadMountReady << " Event Failed.";
+    }
   }
 
   if (result != SUCCESS && !access(PATH_PRELOAD_CHROMIUM_EFL_IMG, F_OK)) {
     LOG(INFO) << PATH_PRELOAD_CHROMIUM_EFL_IMG << " exists.";
     kTargetTPK = "WebEngine Preload TPK ";
     result = mount(true, MOUNT_ARGS_PRELOAD_CHROMIUM);
+
+    if (LwipcEventDone(kChromiumUpdateOrPreloadMountReady) < 0) {
+      // The Lwipc api simply calls the ioctl() inside the function.
+      // Failure of this API means that there are some kernel issues.
+      LOG(ERROR) << kChromiumUpdateOrPreloadMountReady << " Event Failed.";
+    }
   }
 
   return result;
 }
 
+static void AlertUpgradeTPK() {
+  if (!access(PATH_UPGRADE_CHROMIUM_EFL_IMG, F_OK)) {
+    LOG(INFO) << PATH_UPGRADE_CHROMIUM_EFL_IMG << " exists.";
+
+    if (LwipcEventDone(kChromiumUpgradeTPKExists) < 0) {
+      // The Lwipc api simply calls the ioctl() inside the function.
+      // Failure of this API means that there are some kernel issues.
+      LOG(ERROR) << kChromiumUpgradeTPKExists << " Event Failed.";
+    }
+  } else {
+    LOG(INFO) << "No WebEngine Upgrade TPK found";
+  }
+}
+
 static void MountUpgradeTPK() {
   if (!access(LIB_UPGRADE_ROOT_DIR "/version", F_OK)) {
     RequestColdBoot();
@@ -199,6 +222,11 @@ static void MountUpgradeTPK() {
     LOG(INFO) << PATH_UPGRADE_CHROMIUM_EFL_IMG << " exists.";
     kTargetTPK = "WebEngine Upgrade TPK ";
     mount(true, MOUNT_ARGS_UPGRADE_CHROMIUM);
+    if (LwipcEventDone(kChromiumUpgradeMountReady) < 0) {
+      // The Lwipc api simply calls the ioctl() inside the function.
+      // Failure of this API means that there are some kernel issues.
+      LOG(ERROR) << kChromiumUpgradeMountReady << " Event Failed.";
+    }
   } else {
     LOG(INFO) << "No WebEngine Upgrade TPK found";
   }
@@ -241,6 +269,7 @@ int main(int argc, char* argv[]) {
   }
 
   if (option == InstallTpk) {  // InstallTpk
+    AlertUpgradeTPK();
     // TV does not install tpk. Built-in installer installs.
     // To avoid concurrency problem, a lock must be shared with installer.
     //