Add vsm_get_zone_rootpath API function 55/39655/2
authorDariusz Michaluk <d.michaluk@samsung.com>
Wed, 20 May 2015 09:46:33 +0000 (11:46 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Wed, 20 May 2015 12:51:21 +0000 (14:51 +0200)
[Bug/Feature]   Introduce new API function: vsm_get_zone_rootpath
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, install, run tests

Change-Id: Ia4f9f6701f20d6a32878bf13c59a8ad9ade9a9bb

client/vasum-client-impl.cpp
client/vasum-client-impl.hpp
client/vasum-client.cpp
client/vasum-client.h
tests/unit_tests/client/ut-client.cpp

index b9af36f..38e4c5a 100644 (file)
@@ -241,6 +241,18 @@ VsmStatus Client::vsm_get_active_zone_id(VsmString* id) noexcept
     });
 }
 
+VsmStatus Client::vsm_get_zone_rootpath(const char* id, VsmString* rootpath) noexcept
+{
+    assert(id);
+    assert(rootpath);
+
+    return coverException([&] {
+        api::ZoneInfoOut info;
+        mHostClient.callGetZoneInfo({ id }, info);
+        *rootpath = ::strdup(info.rootPath.c_str());
+    });
+}
+
 VsmStatus Client::vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept
 {
     assert(id);
index 0b96149..86f7a5e 100644 (file)
@@ -105,6 +105,11 @@ public:
     VsmStatus vsm_get_active_zone_id(VsmString* id) noexcept;
 
     /**
+     *  @see ::vsm_get_zone_rootpath
+     */
+    VsmStatus vsm_get_zone_rootpath(const char* id, VsmString* rootpath) noexcept;
+
+    /**
      *  @see ::vsm_lookup_zone_by_pid
      */
     VsmStatus vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept;
index c12e8c6..b1028e2 100644 (file)
@@ -133,6 +133,11 @@ API VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id)
     return getClient(client).vsm_get_active_zone_id(id);
 }
 
+API VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath)
+{
+    return getClient(client).vsm_get_zone_rootpath(id, rootpath);
+}
+
 API VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id)
 {
     return getClient(client).vsm_lookup_zone_by_pid(pid, id);
index 1d43094..6c68fe2 100644 (file)
@@ -334,6 +334,17 @@ VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array);
 VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id);
 
 /**
+ * Get zone rootfs path.
+ *
+ * @param[in] client vasum-server's client
+ * @param[in] id zone name
+ * @param[out] rootpath zone rootfs path
+ * @return status of this function call
+ * @remark Use @p vsm_string_free() to free memory occupied by @p rootpath.
+ */
+VsmStatus vsm_get_zone_rootpath(VsmClient client, const char* id, VsmString* rootpath);
+
+/**
  * Get zone name of process with given pid.
  *
  * @param[in] client vasum-server's client
index 328a5bd..3e83884 100644 (file)
@@ -167,6 +167,23 @@ BOOST_AUTO_TEST_CASE(GetActiveZoneId)
     vsm_client_free(client);
 }
 
+BOOST_AUTO_TEST_CASE(GetZoneRootPath)
+{
+    const std::string zoneId = "zone1";
+
+    VsmClient client = vsm_client_create();
+    VsmStatus status = vsm_connect(client);
+    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+    VsmString rootpath;
+    status = vsm_get_zone_rootpath(client, zoneId.c_str(), &rootpath);
+    BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
+
+    BOOST_CHECK_EQUAL(rootpath, "/tmp/ut-zones/" + zoneId + "/rootfs");
+
+    vsm_string_free(rootpath);
+    vsm_client_free(client);
+}
+
 BOOST_AUTO_TEST_CASE(LookupZoneById)
 {
     const std::string activeZoneId = "zone1";