Krate: Add waiting to lock and umount TZ_USER_CONTENT when removing 56/78956/1
authorSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 7 Jul 2016 11:11:20 +0000 (20:11 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 7 Jul 2016 11:18:29 +0000 (20:18 +0900)
Change-Id: If85a50f85c80707ba08fed4a55e4b18bd46c8c0f
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
server/zone/zone.cpp

index 3490ece..6d2f063 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/inotify.h>
+#include <sys/mount.h>
 
 #include <algorithm>
 
@@ -572,24 +572,25 @@ int ZoneManager::removeZone(const std::string& name)
                return -1;
        }
 
-       try {
-               runtime::File manifest(ZONE_MANIFEST_DIR + name + ".xml");
-               manifest.remove();
-       }  catch (runtime::Exception& e) {
-               return -1;
-       }
-
        auto remove = [name, this] {
+               //wait for zone session close
+               sleep(1);
+
                try {
                        runtime::User user(name);
 
+               //umount TZ_USER_CONTENT
+                       ::tzplatform_set_user(user.getUid());
+                       ::umount2(::tzplatform_getenv(TZ_USER_CONTENT), MNT_FORCE);
+                       ::tzplatform_reset_user();
+
                        //remove zone user
                        GumUser *guser = gum_user_get_sync(user.getUid(), FALSE);
                        gboolean ret = gum_user_delete_sync(guser, TRUE);
                        g_object_unref(guser);
 
                        if (!ret) {
-                               throw runtime::Exception("Failed to remove user (" + name + ") by gumd");
+                               throw runtime::Exception("Failed to remove user " + name + "(" + std::to_string(user.getUid()) + ") by gumd");
                        }
 
                        for (std::vector<std::string>::iterator it = createdZoneList.begin();