Remove wrapper. Old API is not supported anymore. 96/50296/3
authorDariusz Michaluk <d.michaluk@samsung.com>
Tue, 27 Oct 2015 13:39:54 +0000 (14:39 +0100)
committerDariusz Michaluk <d.michaluk@samsung.com>
Wed, 28 Oct 2015 15:38:41 +0000 (08:38 -0700)
[Feature]       Remove wrapper. Old API is not supported anymore.
                Fix release build.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build.

Change-Id: Ibd3378dee3b7597d7d27c2b8e0a963167d9b296f

12 files changed:
CMakeLists.txt
client/vasum-client.h
packaging/vasum.spec
tests/cppcheck/cppcheck.suppress
tests/unit_tests/lxcpp/ut-cgroups.cpp
wrapper/CMakeLists.txt [deleted file]
wrapper/vasum.h [deleted file]
wrapper/vasum.pc.in [deleted file]
wrapper/vasum_list.h [deleted file]
wrapper/wrapper-compatibility.cpp [deleted file]
wrapper/wrapper-compatibility.h [deleted file]
wrapper/wrapper.cpp [deleted file]

index c0c800c..b1b6ed5 100644 (file)
@@ -155,7 +155,6 @@ SET(ZONE_SUPPORT_FOLDER ${PROJECT_SOURCE_DIR}/zone-support)
 SET(ZONE_DAEMON_FOLDER ${PROJECT_SOURCE_DIR}/zone-daemon)
 SET(TESTS_FOLDER ${PROJECT_SOURCE_DIR}/tests)
 SET(CLI_FOLDER ${PROJECT_SOURCE_DIR}/cli)
-SET(WRAPPER_FOLDER ${PROJECT_SOURCE_DIR}/wrapper)
 
 
 IF(NOT DEFINED SYSCONF_INSTALL_DIR)
@@ -210,4 +209,3 @@ ADD_SUBDIRECTORY(${ZONE_DAEMON_FOLDER})
 ENDIF(NOT WITHOUT_DBUS)
 ADD_SUBDIRECTORY(${TESTS_FOLDER})
 ADD_SUBDIRECTORY(${CLI_FOLDER})
-ADD_SUBDIRECTORY(${WRAPPER_FOLDER})
index 253306d..47bac7b 100644 (file)
@@ -257,8 +257,6 @@ typedef enum {
     VSMDISPATCHER_INTERNAL          /**< Library will take care of dispatching messages */
 } VsmDispacherType;
 
-#ifndef __VASUM_WRAPPER_SOURCE__
-
 /**
  * Get file descriptor associated with event dispatcher of zone client
  *
@@ -986,8 +984,6 @@ const void *vsm_addrlist_get_addr(VsmAddrList addrs, unsigned int i);
  */
 unsigned int vsm_addrlist_get_prefix(VsmAddrList addrs, unsigned int i);
 
-#endif /* __VASUM_WRAPPER_SOURCE__ */
-
 #ifdef __cplusplus
 }
 #endif
index 447bbcf..7249493 100644 (file)
@@ -44,7 +44,7 @@ Requires:       lxc-templates
 Requires:       iproute
 Requires(post): libcap
 %endif
-Obsoletes:      vasum-daemon < 1:0
+Conflicts:      vasum-daemon < 1:0
 
 %description
 This package provides a daemon used to manage zones - start, stop and switch
@@ -154,7 +154,7 @@ fi
 Summary:          Vasum Client
 Group:            Development/Libraries
 Requires:         vasum = %{epoch}:%{version}-%{release}
-Obsoletes:        vasum < 1:0
+Conflicts:        vasum < 1:0
 Requires(post):   /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
@@ -172,9 +172,6 @@ Library interface to the vasum daemon
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/libvasum-client.so.%{version}
 %{_libdir}/libvasum-client.so.0
-%attr(755,root,root) %{_libdir}/libvasum.so.%{version}
-%{_libdir}/libvasum.so.0
-
 
 ## Devel Package ###############################################################
 %package devel
@@ -192,10 +189,8 @@ Development package including the header files for the client library
 %endif
 %defattr(644,root,root,755)
 %{_libdir}/libvasum-client.so
-%{_libdir}/libvasum.so
 %{_includedir}/vasum
 %{_libdir}/pkgconfig/vasum-client.pc
-%{_libdir}/pkgconfig/vasum.pc
 
 %if !%{without_dbus}
 ## Zone Support Package ###################################################
index 8d7380b..097496a 100644 (file)
@@ -1,6 +1,4 @@
 // public API functions (or write tests to use them all)
-unusedFunction:wrapper/wrapper-compatibility.cpp
-unusedFunction:wrapper/wrapper.cpp
 unusedFunction:libs/config/kvstore.cpp
 unusedFunction:libs/ipc/internals/processor.cpp
 unusedFunction:server/zones-manager.cpp
index bc5be16..5bde171 100644 (file)
@@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(DevicesParams)
 {
     DevicesCGroup devcg("/");
     std::vector<DevicePermission> list = devcg.list();
-    for (const auto& i : list) {
+    for (__attribute__((unused)) const auto& i : list) {
         LOGD(std::string("perm = ") + i.type + " " +
              std::to_string(i.major) + ":" + std::to_string(i.minor) + " " + i.permission);
     }
diff --git a/wrapper/CMakeLists.txt b/wrapper/CMakeLists.txt
deleted file mode 100644 (file)
index 7e70765..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-#
-#
-# @file   CMakeLists.txt
-# @author Mateusz Malicki (m.malicki2@samsung.com)
-#
-
-PROJECT(vasum)
-MESSAGE(STATUS "")
-MESSAGE(STATUS "Generating makefile for the Vasum wrapper...")
-
-## set wrapper library sources (without vasum-client.cpp)
-FILE(GLOB wrapper_SRCS *.cpp *.hpp *.h
-     ${CLIENT_FOLDER}/vasum-client-impl.hpp     ${CLIENT_FOLDER}/vasum-client-impl.cpp
-     ${CLIENT_FOLDER}/host-ipc-connection.hpp   ${CLIENT_FOLDER}/host-ipc-connection.cpp
-     ${CLIENT_FOLDER}/utils.hpp                 ${CLIENT_FOLDER}/utils.cpp)
-
-SET(_LIB_VERSION_ "${VERSION}")
-SET(_LIB_SOVERSION_ "0")
-SET(PC_FILE "${PROJECT_NAME}.pc")
-
-## Set the default ELF image symbol visibility to hidden. Using this feature
-## can very substantially improve linking and load times of shared object
-## libraries, produce more optimized code, provide near-perfect API export
-## and prevent symbol clashes
-ADD_DEFINITIONS(-fvisibility=hidden)
-ADD_DEFINITIONS(-D__STDC_FORMAT_MACROS)
-
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${wrapper_SRCS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
-        SOVERSION ${_LIB_SOVERSION_}
-        VERSION ${_LIB_VERSION_}
-        COMPILE_DEFINITIONS HOST_IPC_SOCKET="${VSM_SERVER_IPC_SOCKET_PATH}")
-
-ADD_DEPENDENCIES(${PROJECT_NAME} Common Config Ipc)
-
-## Link libraries ##############################################################
-FIND_PACKAGE(Boost COMPONENTS system filesystem)
-PKG_CHECK_MODULES(LIB_DEPS REQUIRED gio-2.0)
-INCLUDE_DIRECTORIES(SYSTEM ${LIB_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${JSON_C_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES(${COMMON_FOLDER})
-INCLUDE_DIRECTORIES(${LIBS_FOLDER})
-INCLUDE_DIRECTORIES(${SERVER_FOLDER})
-INCLUDE_DIRECTORIES(${CLIENT_FOLDER})
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} Common ${LIB_DEPS_LIBRARIES} ${Boost_LIBRARIES} Config Ipc)
-IF(NOT WITHOUT_DBUS)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} SimpleDbus)
-ENDIF(NOT WITHOUT_DBUS)
-
-## Generate the pc file ########################################################
-CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
-
-
-## Install #####################################################################
-INSTALL(FILES       ${CMAKE_BINARY_DIR}/${PC_FILE}
-        DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-
-INSTALL(TARGETS     ${PROJECT_NAME}
-        DESTINATION ${LIB_INSTALL_DIR}
-        COMPONENT   RuntimeLibraries)
-
-INSTALL(FILES       vasum.h vasum_list.h
-        DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME})
diff --git a/wrapper/vasum.h b/wrapper/vasum.h
deleted file mode 100644 (file)
index 0cb245e..0000000
+++ /dev/null
@@ -1,999 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Krzysztof Dynowski <k.dynowski@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Krzysztof Dynowski (k.dynowski@samsung.com)
- * @brief   Vasum old API
- */
-
-#ifndef __VASUM_H__
-#define __VASUM_H__
-
-#include <unistd.h>
-#include <limits.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <sys/mount.h>
-
-#include "vasum_list.h"
-
-#ifndef API
-#define API __attribute__((visibility("default")))
-#endif // API
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * <tt>
- * Revision History:
- * </tt>
- */
-
-/**
- * @addtogroup CONTEXT vasum context
- * @{
-*/
-
-/**
- *@brief vasum handle for interact with vasum server process. This is opaque data type.
- */
-typedef struct vsm_context* vsm_context_h;
-
-/**
- * @brief Create vsm context
- * \par Description:
- * The vsm context is an abstraction of the logical connection between the zone controller and it's clients.
- * and vsm_context_h object should be finalized when interaction with the vasum server is no longer required.\n
- * \return An instance of vsm context on success, or NULL
- * \retval vsm_context_h     successful
- * \retval NULL               get vasum context failed.
- * \par Known issues/bugs:
- *  Only a host process has permission for vsm_create_context();
- * \pre vsm-zone-svc must be started
- * \see vsm_cleanup_context()
-*/
-API vsm_context_h vsm_create_context(void);
-
-/**
- * @brief Cleanup zone control context
- * \par Description:
- * vsm_cleanup_context() finalizes vsm context and release all resources allocated to the vsm context.\n
- * This function should be called if interaction with the zone controller is no longer required.
- * \param[in] ctx vsm context
- * \return #VSM_ERROR_NONE on success.
- * \pre vsm_context_h must be initialized by vsm_create_context()
- * \post vsm context_h will not be valid after calling this API
- * \see vsm_create_context()
-*/
-API int vsm_cleanup_context(vsm_context_h ctx);
-
-/**
- * @brief Get file descriptor associated with event dispatcher of zone control context
- * \par Description:
- * The function vsm_get_poll_fd() returns the file descriptor associated with the event dispatcher of vsm context.\n
- * The file descriptor can be bound to another I/O multiplexing facilities like epoll, select, and poll.
- * \param[in] ctx vsm context
- * \return On success, a nonnegative file descriptor is returned. On negative error code is returned.
- * \retval fd nonnegative integer fd value for getting vasum event and refresh vsm_context_h.
- * \retval #VSM_ERROR_INVALID invalid vsm_context_h
- * \pre vsm_context_h must be initialized by vsm_create_context()
- * \see vsm_create_context()
-*/
-API int vsm_get_poll_fd(vsm_context_h ctx);
-
-/**
- * @brief Wait for an I/O event on a VSM context
- * \par Description:
- * vsm_enter_eventloop() waits for event on the vsm context.\n
- *\n
- * The call waits for a maximum time of timout milliseconds. Specifying a timeout of -1 makes vsm_enter_eventloop() wait indefinitely,
- * while specifying a timeout equal to zero makes vsm_enter_eventloop() to return immediately even if no events are available.
- * \param[in] ctx vsm context
- * \param[in] flags Reserved
- * \param[in] timeout Timeout time (milisecond), -1 is infinite
- * \return 0 on success,  or negative error code.
- * \pre vsm context must be initialized by vsm_create_context()
- * \see vsm_create_context(), vsm_get_poll_fd()
-*/
-API int vsm_enter_eventloop(vsm_context_h ctx, int flags, int timeout);
-
-/**
- * @brief Enumeration for vasum error.
- */
-typedef enum {
-    VSM_ERROR_NONE,            /**< The operation was successful */
-    VSM_ERROR_GENERIC,        /**< Non-specific cause */
-    VSM_ERROR_INVALID,        /**< Invalid argument */
-    VSM_ERROR_CANCELED,        /**< The requested operation was cancelled */
-    VSM_ERROR_ABORTED,        /**< Operation aborted */
-    VSM_ERROR_REFUSED,        /**< Connection refused */
-    VSM_ERROR_EXIST,        /**< Target exists */
-    VSM_ERROR_BUSY,            /**< Resource is busy */
-    VSM_ERROR_IO,            /**< I/O error*/
-    VSM_ERROR_TIMEOUT,        /**< Timer expired */
-    VSM_ERROR_OVERFLOW,        /**< Value too large to be stored in data type */
-    VSM_ERROR_OUT_OF_MEMORY,    /**< No memory space */
-    VSM_ERROR_OUT_OF_RANGE,        /**< Input is out of range */
-    VSM_ERROR_NOT_PERMITTED,        /**< Operation not permitted */
-    VSM_ERROR_NOT_IMPLEMENTED,    /**< Function is not implemented yet */
-    VSM_ERROR_NOT_SUPPORTED,    /**< Operation is not supported */
-    VSM_ERROR_ACCESS_DENIED,    /**< Access privilege is not sufficient */
-    VSM_ERROR_NO_OBJECT,        /**< Object not found */
-    VSM_ERROR_BAD_STATE,        /**< Bad state */
-    VSM_MAX_ERROR = VSM_ERROR_BAD_STATE
-}vsm_error_e;
-
-/**
- * @brief Get last vasum error code from vsm_context.
- * \param[in] ctx vsm context
- * \return vasum error enum value.
- * \par Known issues/bugs:
- *     thread non-safe
- * \see vsm_error_string()
-*/
-API vsm_error_e vsm_last_error(vsm_context_h ctx);
-
-/**
- * @brief Get vasum error string.
- * \par Description:
- * return string pointer for vasum error string.
- * \param[in] error vsm_error_e.
- * \return string pointer value represent to error code.
- * \warning Do not free returned pointer.
-*/
-API const char *vsm_error_string(vsm_error_e error);
-
-/// @}
-
-/**
- * @addtogroup LIFECYCLE Vasum Lifecycle
- * @{
- */
-
-/**
- * @brief vsm_zone_h opaque datatype which is used to represent an instance of zone.
- */
-
-typedef struct vsm_zone* vsm_zone_h;
-
-/**
- * @brief Definition for default zone name.
- * Default zone is started at boot sequence by systemd.
-*/
-#define VSM_DEFAULT_ZONE "personal"
-
-
-/**
- * @brief Create a new persistent zone
- * \par Description:
- * vsm_create_zone() triggers zone controller to create new persistent zone.\n\n
- * The zone controller distinguishes two types of zones: peristent and transient.
- * Persistent zones exist indefinitely in storage.
- * While, transient zones are created and started on-the-fly.\n\n
- * Creating zone requires template.\n
- * In general, creating a zone involves constructing root file filesystem and
- * generating configuration files which is used to feature the zone.
- * Moreover, it often requires downloading tools and applications pages,
- * which are not available in device.
- * In that reason, Vasum Framework delegates this work to templates.
- * \param[in] ctx vsm context
- * \param[in] zone_name zone name
- * \param[in] template_name template name to be used for constructing the zone
- * \param[in] flag Reserved
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE     Successful
- * \retval #VSM_ERROR_INVALID  Invalid arguments
- * \retval #VSM_ERROR_EXIST    The same name zone is existed.
- * \retval #VSM_ERROR_GENERIC  Lxc failed to create zone.
- * \retval #VSM_ERROR_IO       Database access failed
-*/
-API int vsm_create_zone(vsm_context_h ctx, const char *zone_name, const char *template_name, int flag);
-
-/**
- * @brief Destroy persistent zone
- * \par Description:
- * The function vsm_destroy_zone() triggers zone controller to destroy persistent zone corresponding to the given name.\n
- * All data stored in the repository of the zone are also deleted if force argument is set.
- * Once the zone repository is deleted, it cannot be recovered.
- * \param[in] ctx vsm context
- * \param[in] zone_name zone name
- * \param[in] force forced flags
- * - 0 : do not destory running zone.
- * - non-zero : if zone is running, shutdown forcefully, and destroy.
- * \return 0 on success, or negative integer error code on error.i
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_BUSY       Target zone is running
- * \retval #VSM_ERROR_NO_OBJECT  Target zone does not exist
- * \retval #VSM_ERROR_GENERIC    Lxc failed to destroy zone
- * \retval #VSM_ERROR_IO         Database access failed
-*/
-API int vsm_destroy_zone(vsm_context_h ctx, const char *zone_name, int force);
-
-/**
- * @brief Start an execution of a persistent zone
- * \par Description:
- * The function vsm_start_zone() triggers zone controller to start zone corresponding to the given name.\n
- * Caller can speficy the type of zones: transient and peristent.
- * Persistent zones need to be defined before being start up(see vsm_create_zone())
- * While, transient zones are created and started on-the-fly.
- * \param[in] ctx vsm context
- * \param[in] zone_name zone name
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_INVALID    Invalid argument.
- * \retval #VSM_ERROR_BUSY       Target zone is already running state.
- * \retval #VSM_ERROR_NO_OBJECT  Target zone does not exist
- * \retval #VSM_ERROR_GENERIC    Lxc failed to start zone
-*/
-API int vsm_start_zone(vsm_context_h ctx, const char *zone_name);
-
-/**
- * @brief Stop an execution of running zone
- * \par Description:
- * Send request to stop running zone.\n
- * \param[in] ctx vsm context
- * \param[in] zone_name zone name
- * \param[in] force option to shutdown.
- *    - 0 : send SIGPWR signal to init process of target zone.
- *  - non-zero : terminate all processes in target zone.
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_INVALID    Invalid argument.
- * \retval #VSM_ERROR_BAD_STATE  Failed to lookup running zone.
- * \retval #VSM_ERROR_NO_OBJECT  Target zone does not exist
- * \retval #VSM_ERROR_GENERIC    Lxc failed to destroy zone
-*/
-API int vsm_shutdown_zone(vsm_context_h ctx, const char *zone_name, int force);
-
-/**
- * @brief Shutdown zone and prevent starting zone
- * \par Description:
- *  Prevent starting target zone.
- *  If target zone is running, shutdown the zone first.
- * \param[in] ctx vsm context
- * \param[in] zone_name zone name
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_NO_OBJECT  Target zone does not exist
- * \retval #VSM_ERROR_GENERIC    Locking failed.
-*/
-API int vsm_lock_zone(vsm_context_h ctx, const char *zone_name, int shutdown);
-
-/**
- * @brief Allow a zone to be launched
- * \par Description:
- * Remove lock applied to the zone corresponding to the given name.
- * \param[in] ctx vsm context
- * \param[in] zone_name zone name
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_GENERIC    Unlocking failed.
-*/
-API int vsm_unlock_zone(vsm_context_h ctx, const char *zone_name);
-
-/**
- * @brief Switch target zone to foreground
- * \par Description:
- * Switch target zone to foreground on device.
- * \param[in] zone vsm_zone_h
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_INVALID    vsm_zone_h is invalid
- */
-API int vsm_set_foreground(vsm_zone_h zone);
-
-/**
- * @brief Get current foreground zone on device
- * \par Description:
- * Get foreground zone handle.
- * \param[in] ctx vsm_context_h
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE       Successful
- * \retval #VSM_ERROR_INVALID    vsm_context_h is invalid
- */
-API vsm_zone_h vsm_get_foreground(vsm_context_h ctx);
-
-/// @}
-/**
- * @addtogroup ACCESS Vasum Access
- * @{
-*/
-
-/**
- * @brief Definition for zone states.
- * This definition shows the available states.
-*/
-typedef enum {
-    VSM_ZONE_STATE_STOPPED,  /**< Zone stopped */
-    VSM_ZONE_STATE_STARTING, /**< Zone is prepare for running */
-    VSM_ZONE_STATE_RUNNING,  /**< Zone is running on device */
-    VSM_ZONE_STATE_STOPPING, /**< Zone is stopping by request */
-    VSM_ZONE_STATE_ABORTING, /**< Zone is failed to start */
-    VSM_ZONE_STATE_FREEZING, /**< Reserved State */
-    VSM_ZONE_STATE_FROZEN,   /**< Reserved State */
-    VSM_ZONE_STATE_THAWED,   /**< Reserved State */
-    VSM_ZONE_MAX_STATE = VSM_ZONE_STATE_THAWED
-} vsm_zone_state_t;
-
-
-/**
- * @brief Definition for zone events
-*/
-typedef enum {
-    VSM_ZONE_EVENT_NONE,      /**< Zone has no event */
-    VSM_ZONE_EVENT_CREATED,   /**< Zone is created */
-    VSM_ZONE_EVENT_DESTROYED, /**< Zone is destroted */
-    VSM_ZONE_EVENT_SWITCHED,  /**< Foreground is switched */
-    VSM_ZONE_MAX_EVENT = VSM_ZONE_EVENT_SWITCHED
-} vsm_zone_event_t;
-
-
-/**
- * @brief Definition for zone iteration callback function.
- */
-typedef void (*vsm_zone_iter_cb)(vsm_zone_h zone, void *user_data);
-/**
- * @brief Definition for zone state changed callback function.
- */
-typedef int (*vsm_zone_state_changed_cb)(vsm_zone_h zone, vsm_zone_state_t state,  void *user_data);
-/**
- * @brief Definition for zone event callback function.
- */
-typedef int (*vsm_zone_event_cb)(vsm_zone_h zone, vsm_zone_event_t event, void *user_data);
-
-/**
- * @brief Interate all zone instances which are in running state
- * \par Description:
- * This API traverses all zones which are in running state, and callback function will be called on every entry.
- * \param[in] ctx vsm context
- * \param[in] callback Function to be executed in iteration, which can be NULL
- * \param[in] user_data Parameter to be passed to callback function
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_OUT_OF_MEMORY  Zone handle allocation failed
- * \retval #VSM_ERROR_GENERIC        Zone initialize failed
- * \remark In case of callback and is NULL,
- *  This API refresh vsm_context which means reloading current running zone to vsm_context again.
-*/
-API int vsm_iterate_zone(vsm_context_h ctx, vsm_zone_iter_cb callback, void *user_data);
-
-/**
- * @brief Find zone corresponding to the name
- * The function vsm_lookup_zone_by_name() looks for the zone instance corresponding to the given name.
- * \param[in] ctx vsm context
- * \param[in] name zone name
- * \return Zone instance on success, or NULL on error.
- * \retval vsm_zone_h  Successful
- * \retval NULL        Failed to lookup
- * \pre  vsm_context_h have to bind by vsm_enter_eventloop() or vsm_context_h does not have current zone status.
- * \see vsm_create_context(), vsm_enter_eventloop()
-*/
-API vsm_zone_h vsm_lookup_zone_by_name(vsm_context_h ctx, const char *name);
-
-/**
- * @brief Find zone instance associated with the process id
- * \par Description:
- * The function vsm_lookup_zone_by_pid() looks for the zone instance associated with the given pid.
- * \param[in] ctx vsm context
- * \param[in] pid Process id
- * \return Zone instance on success, or NULL on error.
- * \retval vsm_zone_h  Successful
- * \retval NULL        Failed to lookup
- * \pre  vsm_context_h have to bind by vsm_enter_eventloop() or vsm_context_h does not have current zone status.
- * \see vsm_create_context(), vsm_enter_eventloop()
-*/
-API vsm_zone_h vsm_lookup_zone_by_pid(vsm_context_h ctx, pid_t pid);
-
-/**
- * @brief Register zone status changed callback
- * \par Description:
- * Register a callback function for zone status change.
- * \param[in] ctx vsm context
- * \param[in] callback Callback function to invoke when zone satte event occurs
- * \return Callback handle on success, or negative error code on error.
- * \retval handle nonnegative handle id for callback.
- * \retval #VSM_ERROR_OUT_OF_MEMORY  Callback hanlder allocation failed.
- * \pre  vsm_context_h have to bind by vsm_enter_eventloop() or callback function does not called.
- * \see vsm_create_context(), vsm_enter_eventloop(), vsm_del_state_changed_callback()
-*/
-API int vsm_add_state_changed_callback(vsm_context_h ctx, vsm_zone_state_changed_cb callback, void *user_data);
-
-/**
- * @brief Deregister zone status changed callback handler
- * \par Description:
- * Remove an event callback from the zone control context.
- * \param[in] ctx vsm context
- * \param[in] handle Callback Id to remove
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE Successful
- * \retval #VSM_ERROR_NO_OBJECT Failed to lookup callback handler
-*/
-API int vsm_del_state_changed_callback(vsm_context_h ctx, int handle);
-
-/**
- * @brief Register zone event callback
- * \par Description:
- * Register a callback function for zone event.
- * \param[in] ctx vsm context
- * \param[in] callback callback function to invoke when zone event occurs
- * \return positive callback handle on success, or negative error code on error.
- * \retval handle nonnegative handle id for callback.
- * \retval #VSM_ERROR_OUT_OF_MEMORY  Callback hanlder allocation failed.
- * \pre  vsm_context_h have to bind by vsm_enter_eventloop() or callback function does not called.
- * \see vsm_create_context(), vsm_enter_eventloop(), vsm_del_state_changed_callback()
-*/
-API int vsm_add_event_callback(vsm_context_h ctx, vsm_zone_event_cb callback, void *user_data);
-
-/**
- * @brief Deregister zone event callback handler
- * \par Description:
- * Remove an event callback from the zone control context.
- * \param[in] ctx vsm context
- * \param[in] handle callback handle to remove
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE Successful
- * \retval #VSM_ERROR_NO_OBJECT Failed to lookup callback handler
-*/
-API int vsm_del_event_callback(vsm_context_h ctx, int handle);
-
-/**
- * @brief Zone attach parameters
- * Arguments are same as linux system-call execv()
- */
-typedef struct vsm_attach_command_s {
-    char * exec;      /**< Program binary path */
-    char ** argv;     /**< An array of argument pointers to null-terminated strings include program path */
-} vsm_attach_command_s;
-
-/**
- * @brief Zone attach option
- */
-typedef struct vsm_attach_options_s {
-    uid_t uid;        /**< requested uid*/
-    gid_t gid;        /**< requested gid*/
-    int env_num;      /**< requested environ count */
-    char **extra_env; /**< requested environ string pointer array. */
-} vsm_attach_options_s;
-
-/**
- * @brief default attach options
- * \n
- * uid = root\n
- * gid = root\n
- * env = no extra env\n
- */
-
-#define VSM_ATTACH_OPT_DEFAULT {  (uid_t)0, (gid_t)0,  0, NULL }
-
-/**
- * @brief Launch a process in a running zone.
- * \par Description:
- * Execute specific command inside the zone with given arguments and environment
- * \param[in] zone_name vsm_zone_h
- * \param[in] command vsm attach command
- * \param[in] opt vsm attach options (can be NULL), using VSM_ATTACH_OPT_DEFAULT
- * \param[out] attached_process process pid
- * \return On sucess 0, otherwise, a negative integer error code on error
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_NO_OBJECT      Target zone is not running state
- * \retval #VSM_ERROR_GENERIC        IPC failed
- */
-API int vsm_attach_zone(vsm_context_h ctx, const char * zone_name, vsm_attach_command_s * command, vsm_attach_options_s * opt, pid_t *attached_process);
-
-/**
- * @brief Launch a process in a running zone and wait till child process exited.
- * \par Description:
- * Execute specific command inside the zone with given arguments and environment
- * \param[in] zone_name vsm_zone_h
- * \param[in] command vsm attach command
- * \param[in] opt vsm attach options (can be NULL), using VSM_ATTACH_OPT_DEFAULT
- * \return On sucess waitpid exit code or attached process, or a negative error code
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_NO_OBJECT      Target zone is not running state
- * \retval #VSM_ERROR_GENERIC        IPC failed or waitpid error
- */
-API int vsm_attach_zone_wait(vsm_context_h ctx, const char * zone_name, vsm_attach_command_s * command, vsm_attach_options_s * opt);
-
-/**
- * @brief Get name string of zone.
- * \par Description:
- * Get name string of zone.
- * \param[in] zone vsm zone handle
- * \return a pointer of zone name string on sucess or NULL on fail.
- * \retval name string value of zone.
- * \retval NULL vsm_zone_h is invalid.
- * \warning Do not modify or free returned pointer memroy.
- *          This memory will be cleanup by vsm_cleanup context()
-*/
-API const char * vsm_get_zone_name(vsm_zone_h zone);
-
-/**
- * @brief Get zone root ablsolute path on host side.
- * \par Description:
- * Get rootpath string of zone.
- * \param[in] zone vsm zone handle
- * \return a pointer of zone rootpath string on sucess or NULL on fail.
- * \retval rootpath string value of zone.
- * \retval NULL vsm_zone_h is invalid.
- * \warning Do not modify or free returned memroy.
- *          This memory will be cleanup by vsm_cleanup context()
-*/
-API const char * vsm_get_zone_rootpath(vsm_zone_h zone);
-
-/**
- * @brief Get type of running zone.
- * \par Description:
- * Get type string of zone. This value is defined in template file when using vsm_create_zone()
- * \param[in] zone vsm zone handle
- * \return a pointer of zone path string on sucess or NULL on fail.
- * \retval rootpath string value of zone.
- * \retval NULL vsm_zone_h is invalid.
- * \see vsm_create_zone()
- * \warning Do not modify or free returned memroy.
- *          This memory will be cleanup by vsm_cleanup context()
-*/
-API const char * vsm_get_zone_type(vsm_zone_h zone);
-
-/**
- * @brief Check zone handle, a host or a normal zone by zone handle.
- * \param[in] zone vsm zone handle
- * \return positive integer on host case, or 0 on normal zone.
- * \retval positive target zone is host zone.
- * \retval NULL     target zone is NOT host.
-*/
-API int vsm_is_host_zone(vsm_zone_h zone);
-
-/**
- * @brief get zone state.
- * \par Description:
- * Get zone state value by zone handle.
- * \param[in] zone vsm zone handle
- * \return vsm_zone_state_t value, or negative value.
- * \retval state vsm_zone_state_t value of zone
- * \retval #VSM_ERROR_INVALID vsm_zone_h is invalid
-*/
-
-API vsm_zone_state_t vsm_get_zone_state(vsm_zone_h zone);
-
-/**
- * @brief get zone id by handle.
- * \par Description:
- * Get zone id value by zone handle.
- * \param[in] zone vsm zone handle
- * \return interger id value of zone or negative error.
- * \retval id nonnegative interger value.
- * \retval #VSM_ERROR_INVALID vsm_zone_h is invalid
- * \remarks id '0' is reserved for host.
-*/
-API int vsm_get_zone_id(vsm_zone_h zone);
-
-/**
- * @brief Set userdata pointer value in vsm_zone_h.
- * \par Description:
- * Get zone id value by zone handle.
- * \param[in] zone vsm zone handle
- * \return On success 0, or negative error.
- * \retval #VSM_ERROR_NONE     Successful.
- * \retval #VSM_ERROR_INVALID  vsm_zone_h is invalid
- * \warning This userdata have to be free before vsm_cleanup_context() or VSM_ZONE_STATE_STOPPED callback handler
-*/
-API int vsm_set_userdata(vsm_zone_h zone, void * userdata);
-
-/**
- * @brief Set userdata pointer value in vsm_zone_h.
- * \par Description:
- * Get zone id value by zone handle.
- * \param[in] zone vsm zone handle
- * \return On success pointer of userdata, or NULL pointer
- * \retval userdata pointer of userdata.
- * \retval NULL invalid vsm_zone_h.
- * \remark initial value is pointer of self vsm_zone_h
-*/
-API void * vsm_get_userdata(vsm_zone_h zone);
-
-
-/**
- * @brief join current process into zone.
- * \par Synopsys:
- * Change self peer credential to target zone
- * \param[in] zone vsm_zone_h
- * \return before vsm_zone on success, or NULL on error.
- * \retval vsm_zone_h before zone handle, If caller process running in host, then host handle returned.
- * \retval NULL       invalid zone handle.
- * \pre parameter vsm zone must be lookup by vsm lookup APIs
- * \post  After finish target zone procedure, must join again before zone by same API.
- * \warning This function is not thread-safe. \n
- *   All requests of threads in same process are considered target zone request to other host processes.
- */
-API vsm_zone_h vsm_join_zone(vsm_zone_h zone);
-
-/**
- * @brief get canonical file path based on current zone.
- * \par Description:
- *    get canonical file path based on current zone.
- * \param[in] input_path requested zone path
- * \param[out] output_path string pointer for canonicalized output path
- * \return int positive string length of output_path, or negative error code on error.
- * \retval #VSM_ERROR_INVALID Invalid arguments.
- * \retval #VSM_ERROR_GENERIC gethostname() is failed.
- * \post Out buffer(*output_path) have to be freed by caller after use.
- * \remarks This API can call inside zone without vsm_context_h
- *   It means this API can call library side for apps.
- */
-API int vsm_canonicalize_path(const char *input_path, char **output_path);
-
-/**
- * @brief Check current environment, a host or virtualized zone.
- * \par Description:
- *    Check current caller process environment.
- * \return positive integer on running in zone, or 0 on running in host.
- * \retval NULL     Current process running in host.
- * \remarks This API can call inside zone without vsm_context_h
- *   It means this API can call library side for apps.
- */
-API int vsm_is_virtualized(void);
-
-/**
- * @brief Check equivalence between caller and target pid.
- * \par Description:
- *    Check API caller process and target pid running in same zone.
- * \retval NULL       target process is running in another zone.
- * \retval 1        target process is running in same zone.
- * \retval -1       failed to check target process.
- * \remarks This API can check real zone of target pid.
-            Real zone is not changed by even join API.
- */
-API int vsm_is_equivalent_zone(vsm_context_h ctx, pid_t pid);
-
-/**
- * @brief Translate zone pid to host pid.
- * \par Description:
- *    This API would translate zone namespace pid to host namespace pid.
- * \param[in] zone  the zone of target process
- * \param[in] pid   target process id of zone namespace
- * \return positive pid or negative error code.
- * \retval pid                       translated host pid of zone process.
- * \retval #VSM_ERROR_NO_OBJECT      No such process in a target zone.
- * \retval #VSM_ERROR_NOT_PERMITTED  Permission denied to get target pid info.
- * \retval #VSM_ERROR_NOT_SUPPORTED  Kernel config is not enabled about pid namespace.
- * \retval #VSM_ERROR_INVALID        Arguments is invalid.
- * \retval #VSM_ERROR_IO             Failed to get process info.
- * \retval #VSM_ERROR_GENERIC        Failed to matching zone pid to host pid.
- */
-API int vsm_get_host_pid(vsm_zone_h zone, pid_t pid);
-
-
-/// @}
-
-/**
- * @addtogroup NETWORK Vasum Network
- * @{
-*/
-
-/**
- * @brief Types of virtual network interfaces
- */
-typedef enum {
-    VSM_NETDEV_VETH, /**< Virtual Ethernet(veth), this type device will be attached to host-side network bridge */
-    VSM_NETDEV_PHYS, /**< Physical device */
-    VSM_NETDEV_MACVLAN /**< Mac VLAN, this type isn't implemented yet */
-} vsm_netdev_type_t;
-
-typedef enum {
-    VSM_NETDEV_ADDR_IPV4, /**< IPV4 Address family */
-    VSM_NETDEV_ADDR_IPV6 /**< IPV6 Address family */
-} vsm_netdev_addr_t;
-
-/**
- * @brief Network device information
- */
-typedef struct vsm_netdev *vsm_netdev_h;
-
-/**
- * @brief Definition for zone network devince iteration callback function.
- */
-typedef void (*vsm_zone_netdev_iter)(struct vsm_netdev *, void *user_data);
-
-/**
- * @brief Create a new network device and assisgn it to zone
- * \par Description:
- * This function creates net netdev instance and assign it to the given zone.
- * \param[in] zone Zone
- * \param[in] type Type of network device to be create
- * \param[in] target
- * - If type is veth, this will be bridge name to attach.
- * - If type is phys, this will be ignored.
- * \param[in] netdev Name of network device to be create
- * \return Network devce on success, or NULL on error.
- * \retval vsm_netdev_h New net device handle
- * \retval NULL         Failed to create netdev
- * \see vsm_create_netdev()
- * \par Known Issues:
- *  Macvlan is not implemented yet.
- */
-API vsm_netdev_h vsm_create_netdev(vsm_zone_h zone, vsm_netdev_type_t type, const char *target, const char *netdev);
-
-/**
- * @brief Removes a network device from zone
- * \par Description:
- * This function remove the given netdev instance from the zone control context.
- * \param[in] netdev network device to be removed
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_destroy_netdev()
- */
-API int vsm_destroy_netdev(vsm_netdev_h netdev);
-
-/**
- * @brief Iterates network devices found in the zone vsm context and executes callback() on each interface.
- * \par Description:
- * vsm_destroy_netdev() scans all network interfaces which are registered in the vsm context, and calls callback() on each entry.
- * \param[in] zone Zone
- * \param[in] callback Function to be executed in iteration, which can be NULL
- * \param[in] user_data Parameter to be delivered to callback function
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_create_netdev(), vsm_destroy_netdev()
- */
-API int vsm_iterate_netdev(vsm_zone_h zone, vsm_zone_netdev_iter callback, void *user_data);
-
-/**
- * @brief Find a network device corresponding to the name
- * \par Description:
- * The function vsm_lookup_netdev_by_name() looks for a network interface.
- * \param[in] name Network device name to search
- * \return Network device on success, or NULL on error.
- * \retval vsm_netdev_h Target net device handle
- * \retval NULL         Failed to lookup netdev
- */
-
-API vsm_netdev_h vsm_lookup_netdev_by_name(vsm_zone_h zone, const char *name);
-
-/**
- * @brief Turn up a network device in the zone
- * \par Description:
- * This function turns up the given netdev instance in the zone.
- * \param[in] netdev network device to be removed
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_down_netdev()
- */
-API int vsm_up_netdev(vsm_netdev_h netdev);
-
-/**
- * @brief Turn down a network device in the zone
- * \par Description:
- * This function turns down the given netdev instance in the zone.
- * \param[in] netdev network device to be removed
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_down_netdev()
- */
-API int vsm_down_netdev(vsm_netdev_h netdev);
-
-/**
- * @brief Get ip address from a network device
- * \par Description:
- * The function vsm_get_ip_addr_netdev() get ip address from a network interface
- * \param[in] netdev Network device to get address
- * \param[in] addr_family Address family
- * \param[out] addr Buffer to get address from a network device
- * \param[out] size Size of buffer
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_OVERFLOW       Parameter overflow
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_set_ip_addr_netdev()
- */
-API int vsm_get_ip_addr_netdev(vsm_netdev_h netdev, vsm_netdev_addr_t addr_family, char *addr, int size);
-
-/**
- * @brief Set ip address to a network device
- * \par Description:
- * The function vsm_set_ip_addr_netdev() set ipv4 address to a network interface
- * \param[in] netdev Network device to set address
- * \param[in] addr_family Address family
- * \param[in] addr IP address string to be set
- * \param[in] prefix prefix ( ex> 192.168.122.1/24, 24 is prefix )
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_OVERFLOW       Parameter overflow
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_get_ip_addr_netdev()
- */
-API int vsm_set_ip_addr_netdev(vsm_netdev_h netdev, vsm_netdev_addr_t addr_family, const char *addr, int prefix);
-
-
-
-/// @}
-
-/**
- * @addtogroup DEVICE Vasum Device
- * @{
-*/
-
-/**
- * @brief Grant device to zone
- * \par Description:
- * Request permission device file node to target zone.
- * \param[in] zone vsm_zone_h
- * \param[in] path device node path
- * \param[in] flags requested permission O_RDWR, O_WRONLY, O_RDONLY
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_NOT_PERMITTED  Change cgroup is not permitted
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_revoke_device()
- */
-API int vsm_grant_device(vsm_zone_h zone, const char *path, uint32_t flags);
-
-/**
- * @brief Revoke device from the zone
- * \par Description:
- * Revoke device node permissions from target zone.
- * \param[in] zone vsm_zone_h
- * \param[in] path device node path
- * \return 0 on success, or negative integer error code on error.
- * \retval #VSM_ERROR_NONE           Successful
- * \retval #VSM_ERROR_INVALID        Invalid arguments
- * \retval #VSM_ERROR_NOT_PERMITTED  Change cgroup is not permitted
- * \retval #VSM_ERROR_GENERIC        Failed to interact with vasum server
- * \see vsm_grant_device()
- */
-API int vsm_revoke_device(vsm_zone_h zone, const char *path);
-/// @}
-
-
-/**
- * @addtogroup RESOURCE Vasum Resource
- * @{
- */
-
-/**
- * @brief Definition for declare file type.
-*/
-typedef enum {
-    VSM_FSO_TYPE_DIR,  /**< Directoy type */
-    VSM_FSO_TYPE_REG,  /**< Regular file type */
-    VSM_FSO_TYPE_FIFO, /**< Fifo file type */
-    VSM_FSO_TYPE_SOCK, /**< Socket file type */
-    VSM_FSO_TYPE_DEV,  /**< Device node type */
-    VSM_FSO_MAX_TYPE = VSM_FSO_TYPE_DEV
-} vsm_fso_type_t;
-
-
-/**
- * @brief Declare file mode.
-*/
-typedef mode_t vsm_mode_t;
-
-/**
- * @brief Declare specific file object to every zone.
- * \par Description:
- * Declare host file system to every running zone.
- * In case of host target file exist, create new file in running zone. or create a new file in running zone.
- * And add hook info in vsm-resource-provier for automatically link host target file to starting zone.
- * Smack labels are also copied as same as host labels.
- * \param[in] ctx vsm context
- * \param[in] ftype Type of file system object
- * \param[in] path Path for the file system object
- * \param[in] flags Flasg
- * \param[in] mode mode
- * \return zero on success, or negative value on error.
- * \retval #VSM_ERROR_NONE      successful.
- * \retval #VSM_ERROR_INVALID   Invalid file type or path.
- * \retval #VSM_ERROR_GENERIC   Error in vasum server side.
- * \retval #VSM_ERROR_NO_OBJECT Source file is not exist in host filesystem
-*/
-API int vsm_declare_file(vsm_context_h ctx, vsm_fso_type_t ftype, const char *path, int flags, vsm_mode_t mode);
-
-/**
- * @brief Declare hardlink to every zone.
- * \par Description:
- * Declare hardlink to host file to every running zone.
- * And add hook info in vsm-resource-provier for automatically link host target file to starting zone.
- * In general, this function is used to share file host and all running zones.
- * Smack labels are also copied as same as host labels.
- * \param[in] ctx vsm context
- * \param[in] source source
- * \param[in] target target
- * \return zero on success, or negative value on error.
- * \retval #VSM_ERROR_NONE      successful
- * \retval #VSM_ERROR_INVALID   Invalid provision type to db.
- * \retval #VSM_ERROR_GENERIC   Error in vasum server side.
- * \retval #VSM_ERROR_NO_OBJECT Source file is not exist in host filesystem
-*/
-API int vsm_declare_link(vsm_context_h ctx , const char *source, const char *target);
-/// @}
-
-
-/*
-    Below datatypes will be opaque.
-*/
-typedef struct vsm_context {
-    void * signal_channel;
-    void * manage_method_channel;
-    void * unpriv_method_channel;
-    vsm_error_e error;
-    pthread_rwlock_t lock;
-    struct adt_list listeners;
-    struct vsm_zone *root_zone;
-    struct vsm_zone *foreground_zone;
-    struct adt_list sc_listeners;
-    struct adt_list ev_listeners;
-    void * vsm_ops;
-} vsm_context_s;
-
-typedef struct vsm_zone {
-    struct vsm_zone *parent;
-    char *name;
-    char *type;
-    int terminal;
-    vsm_zone_state_t state;
-    char *rootfs_path;
-    pthread_rwlock_t lock;
-    struct adt_list children;
-    struct adt_list devices;
-    struct adt_list netdevs;
-    void *user_data;
-    struct adt_list list;
-    struct vsm_context *ctx;
-    int id;
-} vsm_zone_s;
-
-typedef struct vsm_netdev {
-    struct vsm_zone *zone;
-    char *name;
-    vsm_netdev_type_t type;
-    struct adt_list list;
-} vsm_netdev_s;
-
-/*
-    Below APIs will be removed.
-*/
-
-typedef int (*vsm_zone_state_cb)(vsm_zone_h zone, vsm_zone_state_t state ,vsm_zone_event_t event, void *user_data);
-
-API int vsm_add_state_callback(vsm_context_h ctx, vsm_zone_state_cb callback, void *user_data);
-
-API int vsm_del_state_callback(vsm_context_h ctx, int handle);
-
-API int vsm_get_zone_terminal(vsm_zone_h zone);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*! __VASUM_H__ */
diff --git a/wrapper/vasum.pc.in b/wrapper/vasum.pc.in
deleted file mode 100644 (file)
index 2f2247b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Package Information for pkg-config
-
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=@LIB_INSTALL_DIR@
-includedir=${prefix}/include
-
-Name: vasum
-Description: Vasum library
-Version: @_LIB_VERSION_@
-Libs: -L${libdir} -lvasum
-Cflags: -I${includedir}/vasum
diff --git a/wrapper/vasum_list.h b/wrapper/vasum_list.h
deleted file mode 100644 (file)
index 5e9c82e..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef __VASUM_ADT_LIST_H__
-#define __VASUM_ADT_LIST_H__
-
-struct adt_list {
-    struct adt_list* next;
-    struct adt_list* prev;
-};
-
-#undef offsetof
-#ifdef __compiler_offsetof
-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
-#else
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-#define container_of(ptr, type, member) ({                      \
-        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
-        (type *)( (char *)__mptr - offsetof(type,member) );})
-
-#define adt_iterate_list(__iterator, __list)    \
-    for (__iterator = (__list)->next;   \
-         __iterator != __list;      \
-         __iterator = (__iterator)->next)
-
-#define adt_reverse_iterate_list(__iterator, __list)    \
-    for (__iterator = __list;    \
-         (__iterator)->next != __list;      \
-         __iterator = (__iterator)->next);    \
-    for ( ;    \
-         __iterator != __list;      \
-         __iterator = (__iterator)->prev)
-
-#define ADT_INIT_LIST(name) { &(name), &(name) }
-
-static inline void adt_init_list(struct adt_list* list)
-{
-    list->next = list->prev = list;
-}
-
-static inline int adt_empty_list(struct adt_list* list)
-{
-    return (list == list->next) && (list == list->prev);
-}
-
-static inline void __adt_list_add(struct adt_list* _new,
-                                  struct adt_list* prev,
-                                  struct adt_list* next)
-{
-    next->prev = _new;
-    _new->next = next;
-    _new->prev = prev;
-    prev->next = _new;
-}
-
-static inline void adt_link_list(struct adt_list* head, struct adt_list* list)
-{
-    __adt_list_add(list, head, head->next);
-}
-
-static inline void adt_unlink_list(struct adt_list* list)
-{
-    struct adt_list* next, *prev;
-
-    next = list->next;
-    prev = list->prev;
-    next->prev = prev;
-    prev->next = next;
-}
-
-static inline void adt_sort_list(struct adt_list* head,
-        int (*compare_func)(struct adt_list *, struct adt_list *))
-{
-    struct adt_list *it, *jt, *kt;
-
-    if (adt_empty_list(head))
-        return;
-
-    for (it = head->next->next; it != head; it = it->next) {
-        for (jt = head->next; jt != it; jt = jt->next) {
-            if (compare_func(it, jt) < 0) {
-                kt = it;
-                it = it->prev;
-                adt_unlink_list(kt);
-                adt_link_list(jt->prev, kt);
-                break;
-            }
-        }
-    }
-}
-
-static inline struct adt_list *adt_find_list(struct adt_list* head,
-        int (*equal_func)(struct adt_list *, void *), void *value)
-{
-    struct adt_list *it;
-    adt_iterate_list(it, head) {
-        if (equal_func(it, value))
-            return it;
-    }
-    return NULL;
-}
-
-#endif /*!__VASUM_ADT_LIST_H__*/
diff --git a/wrapper/wrapper-compatibility.cpp b/wrapper/wrapper-compatibility.cpp
deleted file mode 100644 (file)
index 04c043d..0000000
+++ /dev/null
@@ -1,1671 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Krzysztof Dynowski <k.dynowski@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Krzysztof Dynowski (k.dynowski@samsung.com)
- * @brief   Vasum old API compatibility functions
- */
-
-#include "wrapper-compatibility.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <regex.h>
-#include <limits.h>
-#include <dirent.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <inttypes.h> //PRIx64
-#include <sys/mount.h>
-#include <sys/xattr.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <asm/unistd.h>
-#include <linux/un.h>
-
-#include "logger/logger.hpp"
-#include "logger/logger-scope.hpp"
-
-#define UNUSED(x) ((void)(x))
-
-extern "C" {
-
-// find_container_by_pid
-API char *find_container_by_pid(pid_t  /*pid*/) {
-    LOGS("");
-    return NULL;
-}
-// get_domain_pid
-API pid_t get_domain_pid(const char * /*name*/, const char * /*target*/) {
-    LOGS("");
-    return -1;
-}
-
-// sock_close_socket
-API int sock_close_socket(int fd) {
-    LOGS("");
-    struct sockaddr_un addr;
-    socklen_t addrlen = sizeof(addr);
-
-    if (!getsockname(fd, (struct sockaddr *)&addr, &addrlen) && addr.sun_path[0]) {
-        unlink(addr.sun_path);
-    }
-
-    close(fd);
-
-    return 0;
-}
-// sock_connect
-API int sock_connect(const char *path) {
-    LOGS("");
-    size_t len;
-    int fd, idx = 0;
-    struct sockaddr_un addr;
-
-    fd = socket(PF_UNIX, SOCK_STREAM, 0);
-    if (fd < 0) {
-        return -1;
-    }
-
-    memset(&addr, 0, sizeof(addr));
-
-    addr.sun_family = AF_UNIX;
-
-    /* Is it abstract address */
-    if (path[0] == '\0') {
-        idx++;
-    }
-    LOGD("socket path=" << &path[idx]);
-    len = strlen(&path[idx]) + idx;
-    if (len >= sizeof(addr.sun_path)) {
-        close(fd);
-        errno = ENAMETOOLONG;
-        return -1;
-    }
-
-    strncpy(&addr.sun_path[idx], &path[idx], strlen(&path[idx]));
-    if (connect
-        (fd, (struct sockaddr *)&addr,
-         offsetof(struct sockaddr_un, sun_path) + len)) {
-        close(fd);
-        return -1;
-    }
-
-    return fd;
-}
-
-// sock_create_socket
-API int sock_create_socket(const char *path, int type, int flags) {
-    LOGS("");
-    size_t len;
-    int fd, idx = 0;
-    struct sockaddr_un addr;
-
-    if (!path)
-        return -1;
-
-    if (flags & O_TRUNC)
-        unlink(path);
-
-    fd = socket(PF_UNIX, type, 0);
-    if (fd < 0) {
-        return -1;
-    }
-
-    memset(&addr, 0, sizeof(addr));
-
-    addr.sun_family = AF_UNIX;
-
-    /* Is it abstract address */
-    if (path[0] == '\0') {
-        idx++;
-    }
-    LOGD("socket path=" << &path[idx]);
-    len = strlen(&path[idx]) + idx;
-    if (len >= sizeof(addr.sun_path)) {
-        close(fd);
-        errno = ENAMETOOLONG;
-        return -1;
-    }
-
-    strncpy(&addr.sun_path[idx], &path[idx], strlen(&path[idx]));
-
-    if (bind (fd, (struct sockaddr *)&addr, offsetof(struct sockaddr_un, sun_path) + len)) {
-        close(fd);
-        return -1;
-    }
-
-    if (type == SOCK_STREAM && listen(fd, 100)) {
-        close(fd);
-        return -1;
-    }
-
-    return fd;
-}
-
-// "Fowler–Noll–Vo hash function" implementation (taken from old API source)
-#define FNV1A_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
-static uint64_t hash_fnv_64a(void *buf, size_t len, uint64_t hval)
-{
-    unsigned char *bp;
-
-    for (bp = (unsigned char *)buf; bp < (unsigned char *)buf + len; bp++) {
-        hval ^= (uint64_t) * bp;
-        hval += (hval << 1) + (hval << 4) + (hval << 5) +
-            (hval << 7) + (hval << 8) + (hval << 40);
-    }
-
-    return hval;
-}
-
-// sock_monitor_address
-API int sock_monitor_address(char *buffer, int len, const char *lxcpath) {
-    LOGS("");
-    int ret;
-    uint64_t hash;
-    char *sockname;
-    char path[PATH_MAX];
-
-    memset(buffer, 0, len);
-    sockname = &buffer[1];
-
-    ret = snprintf(path, sizeof(path), "lxc/%s/monitor-sock", lxcpath);
-    if (ret < 0) {
-        errno = ENAMETOOLONG;
-        return -1;
-    }
-
-    hash = hash_fnv_64a(path, ret, FNV1A_64_INIT);
-    ret = snprintf(sockname, len, "lxc/%016" PRIx64 "/%s", hash, lxcpath);
-    if (ret < 0) {
-        errno = ENAMETOOLONG;
-        return -1;
-    }
-
-    return 0;
-}
-// sock_recv_fd (intern)
-API int sock_recv_fd(int fd, int *recvfd, void *data, size_t size) {
-    LOGS("");
-    struct msghdr msg;
-    struct iovec iov;
-    int ret;
-    union {
-        struct cmsghdr cm;
-        char control[CMSG_SPACE(sizeof(int))];
-    } control_un;
-    struct cmsghdr *cmsg;
-    char dummy=1;
-
-    memset(&msg, 0, sizeof(msg));
-    msg.msg_name = NULL;
-    msg.msg_namelen = 0;
-
-    msg.msg_control = control_un.control;
-    msg.msg_controllen = sizeof(control_un.control);
-
-    iov.iov_base = data ? data : &dummy;
-    iov.iov_len = data ? size : sizeof(dummy);
-    msg.msg_iov = &iov;
-    msg.msg_iovlen = 1;
-
-    ret = recvmsg(fd, &msg, 0);
-    if (ret <= 0)
-        return ret;
-
-    cmsg = CMSG_FIRSTHDR(&msg);
-    if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(int)) &&
-        cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
-        *recvfd = *((int *)CMSG_DATA(cmsg));
-    }
-    else
-        *recvfd = -1;
-
-    return ret;
-}
-// sock_send_fd
-API int sock_send_fd(int fd, int sendfd, void *data, size_t size) {
-    LOGS("");
-    struct msghdr msg;
-    struct iovec iov;
-    union {
-        struct cmsghdr cm;
-        char control[CMSG_SPACE(sizeof(int))];
-    } control_un;
-    struct cmsghdr *cmsg;
-    char dummy=1;
-
-    memset(&msg, 0, sizeof(msg));
-    msg.msg_control = control_un.control;
-    msg.msg_controllen = sizeof(control_un.control);
-
-    cmsg = CMSG_FIRSTHDR(&msg);
-    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-    cmsg->cmsg_level = SOL_SOCKET;
-    cmsg->cmsg_type = SCM_RIGHTS;
-    *((int *)CMSG_DATA(cmsg)) = sendfd;
-
-    msg.msg_name = NULL;
-    msg.msg_namelen = 0;
-
-    iov.iov_base = data ? data : &dummy;
-    iov.iov_len = data ? size : sizeof(dummy);
-    msg.msg_iov = &iov;
-    msg.msg_iovlen = 1;
-
-    return sendmsg(fd, &msg, MSG_NOSIGNAL);
-}
-// vasum_log
-API void vasum_log(__attribute__((unused)) int type,
-                   __attribute__((unused)) const char *tag,
-                   const char *fmt, ...) {
-    va_list arg_ptr;
-    char buf[255];
-    LOGS("type=" << type << " tag=" << tag);
-    va_start(arg_ptr, fmt);
-    vsnprintf(buf, sizeof(buf), fmt, arg_ptr);
-    va_end(arg_ptr);
-    buf[sizeof(buf)-1]=0;
-    LOGD("msg=" << buf);
-}
-
-#define MAX_ERROR_MSG    0x1000
-#define BUF_SIZE    4096
-
-#define SMACK_LABEL_LEN 8
-#define ERROR(...) do{}while(0)
-#define WARN(...) do{}while(0)
-#define DEBUG(...) do{}while(0)
-#define INFO(...) do{}while(0)
-
-// lib/utils.c
-const char *const fso_type_strtab[] = {
-    "Directory",
-    "Regular file",
-    "FIFO",
-    "Socket",
-    "Device node"
-};
-
-API const char *fso_type_to_string(vsm_fso_type_t fso)
-{
-    LOGS("");
-    if (fso < 0 || fso > VSM_FSO_MAX_TYPE) {
-        return NULL;
-    }
-
-    return fso_type_strtab[fso];
-}
-
-API int wait_for_pid_status(pid_t pid)
-{
-    LOGS("");
-    int status, ret;
-
- again:
-    ret = waitpid(pid, &status, 0);
-    if (ret == -1) {
-        if (errno == EINTR) {
-            goto again;
-        } else {
-            ERROR("waitpid pid : %d error : %s", pid, strerror(errno));
-            return -1;
-        }
-    }
-    if (ret != pid)
-        goto again;
-    return status;
-}
-
-API vsm_fso_type_t fso_string_to_type(char *str)
-{
-    LOGS("");
-    int i;
-    for (i = 0; i <= VSM_FSO_MAX_TYPE; i++) {
-        int len = strlen(fso_type_strtab[i]);
-        if (strncmp(str, fso_type_strtab[i], len) == 0)
-            return static_cast<vsm_fso_type_t>(i);
-    }
-
-    return static_cast<vsm_fso_type_t>(-1);
-}
-
-API int mkdir_p(const char *dir, mode_t mode)
-{
-    LOGS("");
-    const char *tmp = dir;
-    const char *orig = dir;
-
-    do {
-        dir = tmp + strspn(tmp, "/");
-        tmp = dir + strcspn(dir, "/");
-        char *makeme = strndup(orig, dir - orig);
-        if (*makeme) {
-            if (mkdir(makeme, mode) && errno != EEXIST) {
-                free(makeme);
-                return -1;
-            }
-        }
-        free(makeme);
-    } while (tmp != dir);
-
-    return 0;
-}
-
-API int lock_fd(int fd, int wait)
-{
-    LOGS("");
-    int ret;
-    struct flock f;
-
-    while (1) {
-        f.l_type = F_WRLCK;
-        f.l_whence = SEEK_SET;
-        f.l_start = 0;
-        f.l_len = 0;
-
-        if (wait)
-            ret = fcntl(fd, F_SETLKW, &f);
-        else
-            ret = fcntl(fd, F_SETLK, &f);
-        if (ret != -1)
-            return 0;
-        if (errno == EINTR)
-            continue;
-        return -1;
-    }
-}
-
-API int unlock_fd(int fd)
-{
-    LOGS("");
-    struct flock f;
-    f.l_type = F_UNLCK;
-    f.l_whence = SEEK_SET;
-    f.l_start = 0;
-    f.l_len = 0;
-    return fcntl(fd, F_SETLKW, &f);
-}
-
-API int copy_smacklabel(const char * /*source*/, const char * /*dest*/)
-{
-    LOGS("");
-    return 0;
-}
-
-API int remove_file(char *path)
-{
-    LOGS("");
-    struct stat path_stat;
-    int status = 0;
-
-    if (lstat(path, &path_stat) < 0) {
-        if (errno != ENOENT) {
-            ERROR("Unable to stat : %s");
-            return -1;
-        }
-    }
-
-    if (S_ISDIR(path_stat.st_mode)) {
-        struct dirent *d;
-        DIR *dp;
-        if ((dp = opendir(path)) == NULL) {
-            ERROR("Unable to opendir %s", path);
-            return -1;
-        }
-
-        while ((d = readdir(dp)) != NULL) {
-            char new_path[PATH_MAX];
-            if (strcmp(d->d_name, ".") == 0 ||
-                strcmp(d->d_name, "..") == 0)
-                continue;
-
-            snprintf(new_path, PATH_MAX, "%s/%s", path, d->d_name);
-            if (remove_file(new_path) < 0)
-                status = -1;
-        }
-
-        if (closedir(dp) < 0) {
-            ERROR("Unable to close dp : %s", path);
-            return -1;
-        }
-
-        if (rmdir(path) < 0) {
-            ERROR("Failed to remove dir : %s, cause: %s", path,
-                  strerror(errno));
-            return -1;
-        }
-
-    } else {
-        if (unlink(path) < 0) {
-            ERROR("Unable to remove %s", path);
-            return -1;
-        }
-    }
-
-    return status;
-}
-
-API int copy_file(const char *source, const char *dest, int /*flags*/)
-{
-    LOGS("");
-    int ret;
-    FILE *sfp, *dfp;
-    char buffer[BUF_SIZE];
-
-    if ((sfp = fopen(source, "r")) == NULL) {
-        ERROR("Unable to open source : %s", source);
-        return -1;
-    }
-
-    if ((dfp = fopen(dest, "w+")) == NULL) {
-        ERROR("Unable to open destination : %s", dest);
-        fclose(sfp);
-        return -1;
-    }
-
-    while (1) {
-        size_t nread, nwritten, size = BUF_SIZE;
-        nread = fread(buffer, 1, size, sfp);
-
-        if (nread != size && ferror(sfp)) {
-            ERROR("Read failed");
-            return -1;
-        } else if (nread == 0) {
-            break;
-        }
-
-        nwritten = fwrite(buffer, 1, nread, dfp);
-
-        if (nwritten != nread) {
-            if (ferror(dfp))
-                ERROR("write fail");
-            else
-                ERROR("Unable to write all data");
-            return -1;
-        }
-    }
-
-    fclose(sfp);
-    fclose(dfp);
-
-    ret = copy_smacklabel(source, dest);
-    if (ret != 0) {
-        ERROR("Unable to setting smack lable");
-        return -1;
-    }
-    return 0;
-}
-
-API int regex_compile(regex_t * r, const char *regex_text)
-{
-    LOGS("");
-    int status = regcomp(r, regex_text, REG_EXTENDED | REG_NEWLINE);
-
-    if (status != 0) {
-        char error_message[MAX_ERROR_MSG];
-
-        regerror(status, r, error_message, MAX_ERROR_MSG);
-        DEBUG("Regex error compiling '%s': %s\n",
-              regex_text, error_message);
-        return 1;
-    }
-
-    return 0;
-}
-
-API int regex_match(regex_t * r, const char *to_match)
-{
-    LOGS("");
-    const char *p = to_match;
-    const int n_matches = 10;
-    regmatch_t m[n_matches];
-
-    while (1) {
-        int i = 0;
-        int nomatch = regexec(r, p, n_matches, m, 0);
-
-        if (nomatch) {
-            DEBUG("No more matches.\n");
-            return nomatch;
-        }
-
-        for (i = 0; i < n_matches; i++) {
-            int start;
-            int finish;
-            UNUSED(start);
-            UNUSED(finish);
-
-            if (m[i].rm_so == -1) {
-                break;
-            }
-
-            start = m[i].rm_so + (p - to_match);
-            finish = m[i].rm_eo + (p - to_match);
-            if (i == 0) {
-                INFO("$& is ");
-            } else {
-                INFO("$%d is ", i);
-            }
-
-            INFO("'%.*s' (bytes %d:%d)\n", (finish - start),
-                 to_match + start, start, finish);
-        }
-
-        p += m[0].rm_eo;
-    }
-
-    return 0;
-}
-
-API int get_peer_pid(int fd)
-{
-    LOGS("");
-    struct ucred cred;
-    socklen_t cr_len = sizeof(cred);
-    if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &cr_len) < 0) {
-        return -1;
-    }
-    return cred.pid;
-}
-
-API pid_t gettid(void)
-{
-    LOGS("");
-    return syscall(__NR_gettid);
-}
-
-API int set_smacklabel_fd(int fd, const char *xattr_name, const char *label)
-{
-    LOGS("");
-    size_t len;
-    int ret;
-
-    if (fd < 0)
-        return -1;
-
-    len = strnlen(label, SMACK_LABEL_LEN + 1);
-    if (len > SMACK_LABEL_LEN)
-        return -1;
-
-    ret = fsetxattr(fd, xattr_name, label, len + 1, 0);
-    if (ret != 0) {
-        ERROR("Set Smack lable error : %s", strerror(errno));
-    }
-    return ret;
-}
-
-API int set_smacklabel(const char *path, const char *xattr_name, const char *label)
-{
-    LOGS("");
-    size_t len;
-    int ret;
-
-    if (path == NULL)
-        return -1;
-
-    len = strnlen(label, SMACK_LABEL_LEN + 1);
-    if (len > SMACK_LABEL_LEN)
-        return -1;
-
-    ret = lsetxattr(path, xattr_name, label, len + 1, 0);
-    if (ret != 0) {
-        ERROR("Set Smack lable error : %s", strerror(errno));
-    }
-    return ret;
-}
-API char *get_self_smacklabel(void)
-{
-    LOGS("");
-    int ret;
-    int fd;
-    const char *attr_path = "/proc/self/attr/current";
-    char buffer[SMACK_LABEL_LEN + 1];
-
-    bzero(buffer, SMACK_LABEL_LEN + 1);
-
-    fd = open(attr_path, O_RDONLY);
-    if (fd < 0) {
-        return NULL;
-    }
-
-    ret = read(fd, buffer, SMACK_LABEL_LEN + 1);
-    close(fd);
-    if (ret < 0) {
-        return NULL;
-    }
-
-    if (ret > SMACK_LABEL_LEN) {
-        //return NULL;
-    }
-    buffer[SMACK_LABEL_LEN] = 0;
-
-    return strdup(buffer);
-}
-
-API int get_self_cpuset(char *name, int buf_sz)
-{
-    LOGS("");
-    int fd;
-    int lxc_len, ret;
-    char cpuset_path[] = "/proc/self/cpuset";
-    char current_name[NAME_MAX];
-
-    fd = open(cpuset_path, O_RDONLY);
-    if (fd < 0) {
-        return 0;
-    }
-
-    ret = read(fd, current_name, NAME_MAX - 1);
-    if (ret < 0) {
-        close(fd);
-        return -1;
-    }
-
-    current_name[ret - 1] = '\0';
-    close(fd);
-
-    lxc_len = sizeof("/lxc");
-    if (ret < lxc_len) {
-        name[0] = '/';
-        name[1] = 0;
-        return 1;
-    } else {
-        char *p;
-        p = current_name + lxc_len;
-
-        while (*p != '\0') {
-            if (*p == '/') {
-                *p = '\0';
-                break;
-            }
-            p++;
-        }
-        snprintf(name, buf_sz, "%s", current_name + lxc_len);
-    }
-
-    return ret - lxc_len;
-}
-
-
-API char * get_pid_cpuset(int pid)
-{
-    LOGS("");
-    int fd;
-    int ret;
-    char cpuset_path[PATH_MAX];
-    char current_name[NAME_MAX];
-
-    snprintf(cpuset_path, PATH_MAX, "/proc/%d/cpuset", pid);
-
-    ret = access(cpuset_path, F_OK | R_OK);
-    if (ret != 0)
-        return NULL;
-
-    fd = open(cpuset_path, O_RDONLY);
-    if (fd < 0) {
-        return NULL;
-    }
-
-    ret = read(fd, current_name, NAME_MAX - 1);
-    if (ret < 0) {
-        close(fd);
-        return NULL;
-    }
-
-    current_name[ret - 1] = 0;
-    close(fd);
-
-    INFO("cpuset path : %s, value : %s", cpuset_path, current_name);
-
-    return strdup(current_name);
-}
-
-API char * read_namespace_link(const char *ns, int pid)
-{
-    LOGS("");
-    char ns_path[PATH_MAX];
-    char buf[NAME_MAX];
-    int ret;
-
-    snprintf(ns_path, PATH_MAX, "/proc/%d/ns/%s", pid, ns);
-
-    ret = access(ns_path, F_OK);
-    if (ret != 0)
-        return NULL;
-
-    ret = readlink(ns_path, buf, NAME_MAX);
-    if (ret == -1) {
-        ERROR("Failed to readlink ns file - [%s]", ns_path);
-        return NULL;
-    }
-
-    buf[ret] = 0;
-
-    INFO("Read ns link data -pid : %d data : %s", pid, buf);
-
-    return strdup(buf);
-}
-
-// libs/device.c
-#define DEV_ITERATE_CONTINUE    0
-API int dev_enumerate_nodes(const char *cname, dev_enumerator enumerator,
-            void *data)
-{
-    LOGS("");
-    int ret;
-    FILE *fp;;
-    char path[PATH_MAX], entry[64];
-
-    ret = snprintf(path, sizeof(path),
-               "/sys/fs/cgroup/devices/lxc/%s/devices.list", cname);
-
-    if (ret < 0) {
-        ERROR("Failed to make pathname");
-        return -1;
-    }
-
-    fp = fopen(path, "r");
-    if (fp == NULL) {
-        ERROR("File open failed: %s(%s)", path, strerror(errno));
-        return -1;
-    }
-
-    while (fgets(entry, sizeof(entry), fp) != NULL) {
-        int major, minor;
-        char *next, *ptr = &entry[2];
-
-        major = strtol(ptr, &next, 10);
-        minor = strtol(++next, (char **)NULL, 10);
-
-        ret = enumerator(entry[0], major, minor, data);
-        if (ret != DEV_ITERATE_CONTINUE)
-            break;
-    }
-
-    fclose(fp);
-
-    return ret;
-}
-
-API int dev_terminal_enumerator(int type, int major, int minor, void *data)
-{
-    LOGS("");
-    int *dev = (int*)data;
-
-    *dev = minor;
-    UNUSED(type);
-    UNUSED(major);
-
-    INFO("Matched device: %c, %d, %d\n", type, major, minor);
-
-    return 1;
-}
-
-// libs/namespace.c
-API pid_t get_init_pid(const char *name)
-{
-    LOGS("");
-    char filename[PATH_MAX];
-    FILE *fp;
-    pid_t ret = -1;
-
-    snprintf(filename, sizeof(filename),
-            "/sys/fs/cgroup/devices/lxc/%s/cgroup.procs", name);
-
-    fp = fopen(filename, "r");
-
-    if (fp != NULL) {
-        if (fscanf(fp, "%7d", &ret) < 0) {
-            ERROR("Failed to read %s\n", filename);
-            ret = -2;
-        }
-        fclose(fp);
-    } else {
-        INFO("Unable to access %s\n", filename);
-        ret = errno;
-    }
-
-    return ret;
-}
-
-
-API pid_t get_zone_pid(const char *name, const char *target)
-{
-    LOGS("");
-    char path[PATH_MAX];
-    char cmd[PATH_MAX];
-    int res = 0, len;
-    pid_t ret = -1;
-    FILE *fp;
-
-    char *line = NULL;
-    size_t line_len;
-
-    snprintf(path, PATH_MAX,
-         "/sys/fs/cgroup/cpuset/lxc/%s/cgroup.procs", name);
-
-    res = access(path, F_OK | R_OK);
-    if (res != 0) {
-        ERROR("Failed to acess zone cgroup file: %s", path);
-        return -EINVAL;
-    }
-
-    if (target == NULL) {
-        ERROR("Failed to lookup cmdline in zone proc");
-        return -EINVAL;
-    } else {
-        len = strlen(target);
-    }
-
-    fp = fopen(path, "r");
-    if (fp == NULL) {
-        ERROR("Failed to open zone cgroup");
-        return -1;
-    }
-
-    while (getline(&line, &line_len, fp) != -1) {
-        int res;
-        pid_t pid;
-        FILE *cmdfp;
-        char cmdpath[PATH_MAX];
-
-        res = sscanf(line, "%7d", &pid);
-        if (res != 1) {
-            ERROR("Failed to read %s\n", path);
-            res = -1;
-            goto out;
-        }
-
-        if (pid < 0)
-            continue;
-
-        snprintf(cmdpath, PATH_MAX, "/proc/%d/cmdline", pid);
-
-        if (access(cmdpath, F_OK | R_OK) != 0)
-            continue;
-
-        cmdfp = fopen(cmdpath, "r");
-        if (cmdfp == NULL) {
-            ERROR("Unable to access %s\n", cmdpath);
-            continue;
-        }
-
-        if (fscanf(cmdfp, "%1023s", cmd) < 0) {
-            ERROR("Failed to read cmdline - pid : %d\n", pid);
-            continue;
-        }
-
-        fclose(cmdfp);
-
-        if (strncmp(cmd, target, len) == 0) {
-            ret = pid;
-            break;
-        }
-    }
- out:
-    fclose(fp);
-    return ret;
-}
-
-API int open_ns(pid_t pid, const char *name)
-{
-    LOGS("");
-    int fd, ret;
-    char path[PATH_MAX];
-
-    ret = snprintf(path, PATH_MAX, "/proc/%d/ns/%s", pid, name);
-    if (ret < 0 || ret >= PATH_MAX) {
-        ERROR("Failed to namespace - pid %d, ns: %s ", pid, name);
-        return -EINVAL;
-    }
-
-    fd = open(path, O_RDONLY);
-    if (fd < 0) {
-        ERROR("failed to open %s\n", path);
-        return -errno;
-    }
-
-    return fd;
-}
-
-// vasum/libs/vt.c
-#include <linux/kd.h>
-#include <linux/vt.h>
-static int is_console(int fd)
-{
-    LOGS("");
-    char arg;
-
-    return (isatty(fd) &&
-        (ioctl(fd, KDGKBTYPE, &arg) == 0) &&
-        ((arg == KB_101) || (arg == KB_84)));
-}
-
-static int open_console(const char *path)
-{
-    int fd;
-
-    fd = open(path, O_RDWR);
-    if (fd < 0) {
-        fd = open(path, O_WRONLY);
-    }
-    if (fd < 0) {
-        fd = open(path, O_RDONLY);
-    }
-    if (fd < 0) {
-        return -1;
-    }
-
-    return fd;
-}
-
-API int get_console_fd(const char *path)
-{
-    LOGS("");
-    int fd;
-
-    if (path) {
-        fd = open_console(path);
-        if (fd >= 0) {
-            return fd;
-        }
-
-        return -1;
-    }
-
-    fd = open_console("/dev/tty0");
-    if (fd >= 0) {
-        return fd;
-    }
-
-    fd = open_console("/dev/console");
-    if (fd >= 0) {
-        return fd;
-    }
-
-    for (fd = 0; fd < 3; fd++) {
-        if (is_console(fd)) {
-            return fd;
-        }
-    }
-
-    return -1;
-}
-
-API int vt_switch_terminal(int id)
-{
-    LOGS("");
-    int fd, ret = -1;
-
-    fd = get_console_fd(NULL);
-    if (fd < 0) {
-        return -1;
-    }
-
-    if (ioctl(fd, VT_ACTIVATE, id) < 0) {
-        goto out;
-    }
-
-    if (ioctl(fd, VT_WAITACTIVE, id) < 0) {
-        goto out;
-    }
-
-    ret = 0;
- out:
-    close(fd);
-    return ret;
-}
-
-API int vt_find_unused_terminal(void)
-{
-    LOGS("");
-    int fd, nr = -1;
-
-    fd = get_console_fd(NULL);
-    if (fd < 0) {
-        perror("Terminal open failed");
-        return -1;
-    }
-
-    if (ioctl(fd, VT_OPENQRY, &nr) < 0) {
-        perror("VT_OPENQRY failed");
-        goto out;
-    }
-
- out:
-    close(fd);
-
-    return nr;
-}
-
-API int vt_query_active_terminal(void)
-{
-    LOGS("");
-    int fd, ret = -1;
-    struct vt_stat vtstat;
-
-    fd = get_console_fd(NULL);
-    if (fd < 0) {
-        return -1;
-    }
-
-    if (ioctl(fd, VT_GETSTATE, &vtstat) < 0) {
-        goto out;
-    }
-
-    ret = vtstat.v_active;
- out:
-    close(fd);
-    return ret;
-}
-
-// libs/parser.h
-struct unit_keyword_callback {
-    const char *name;
-    int (*func) (int nargs, char **args);
-};
-
-struct unit_parser {
-    struct unit_keyword_callback *kw;
-};
-
-API int parse_stream(const char *name, struct unit_parser *parser);
-// libs/parser.c
-#define PARSER_MAXARGS    32
-
-#define T_EOF           1
-#define T_STATEMENT     2
-#define T_ARGUMENT      3
-#define T_NEWLINE       7
-#define T_NEWBLOCK      8
-
-struct parser_context {
-    struct unit_keyword_callback *kw;
-};
-
-struct parser_state {
-    char *ptr;
-    char *stmt;
-    int line;
-    int nexttoken;
-    void *context;
-};
-
-static void parser_init_state(struct parser_state *state, char *line)
-{
-    state->line = 1;
-    state->ptr = line;
-    state->nexttoken = 0;
-    state->stmt = NULL;
-    state->context = NULL;
-}
-
-static struct unit_keyword_callback *keyword_lookup(struct parser_context *ctx,
-                            const char *kw)
-{
-    int i;
-
-    for (i = 0; ctx->kw[i].name != NULL; i++) {
-        if (!strcmp(ctx->kw[i].name, kw)) {
-            return &ctx->kw[i];
-        }
-    }
-
-    return NULL;
-}
-
-static int tokenize(struct parser_state *state)
-{
-    char *x = state->ptr;
-    char *s, *ss;
-
-    if (state->nexttoken) {
-        int t = state->nexttoken;
-        state->nexttoken = 0;
-        return t;
-    }
-
- retry:
-    state->stmt = s = x;
-    ss = x + 1;
- resume:
-    while (1) {
-        switch (*x) {
-        case 0:
-            state->nexttoken = T_EOF;
-            goto textdone;
-        case '\\':
-            x++;
-            switch (*x) {
-            case 0:
-                goto textdone;
-            case 'n':
-                *s++ = '\n';
-                break;
-            case 'r':
-                *s++ = '\r';
-                break;
-            case 't':
-                *s++ = '\t';
-                break;
-            case '\\':
-                *s++ = '\\';
-                break;
-            case '\r':
-                /* \ <cr> <lf> -> line continuation */
-                if (x[1] != '\n') {
-                    x++;
-                    continue;
-                }
-            case '\n':
-                /* \ <lf> -> line continuation */
-                state->line++;
-                x++;
-                /* eat any extra whitespace */
-                while ((*x == ' ') || (*x == '\t'))
-                    x++;
-                continue;
-            default:
-                /* unknown escape -- just copy */
-                *s++ = *x++;
-            }
-            continue;
-        case ',':
-            x++;
-            goto textdone;
-        case '=':
-            x++;
-            if (ss == x) {
-                goto retry;
-            }
-            goto textdone;
-        case ' ':
-        case '\t':
-        case '\r':
-            x++;
-            if (ss == x) {
-                goto retry;
-            }
-            goto textdone;
-        case '\n':
-            x++;
-            if (ss == x) {
-                state->ptr = x;
-                return T_NEWLINE;
-            }
-            state->nexttoken = T_NEWLINE;
-            goto textdone;
-        case '\'':
-        case '"':
-            x++;
-            for (;;) {
-                switch (*x) {
-                case 0:
-                    /* unterminated quoted thing */
-                    state->ptr = x;
-                    return T_EOF;
-                case '\'':
-                case '"':
-                    x++;
-                    goto resume;
-                default:
-                    *s++ = *x++;
-                }
-            }
-            break;
-        case '[':
-            x++;
-            goto resume;
-        case ']':
-            x++;
-            goto resume;
-        case '#':
-            while (*x && (*x != '\n'))
-                x++;
-            if (*x == '\n') {
-                state->ptr = x + 1;
-                return T_NEWLINE;
-            } else {
-                state->ptr = x;
-                return T_EOF;
-            }
-            break;
-        default:
-            *s++ = *x++;
-        }
-    }
-
- textdone:
-    state->ptr = x;
-    *s = 0;
-    return T_STATEMENT;
-}
-
-static int parse_statement(struct parser_context *ctx, int argc, char **argv,
-               int (*func) (int argc, char **argv))
-{
-    struct parser_state state;
-    char *args[PARSER_MAXARGS];
-    int i;
-    int ret = 0;
-    UNUSED(ctx);
-
-    for (i = 0; i < argc; i++) {
-        int nargs, done, rc;
-        done = nargs = 0;
-        parser_init_state(&state, argv[i]);
-
-        while (!done) {
-            int token = tokenize(&state);
-            switch (token) {
-            case T_EOF:
-                if (nargs && func) {
-                    rc = func(nargs, args);
-                    if (rc < 0) {
-                        WARN("Key word callback error");
-                    }
-                    nargs = 0;
-                }
-                done = 1;
-                break;
-            case T_STATEMENT:
-                if (nargs < PARSER_MAXARGS) {
-                    args[nargs++] = state.stmt;
-                }
-                break;
-            }
-        }
-    }
-
-    return ret;
-}
-
-API int parse_stream_core(struct parser_context *ctx, char *s)
-{
-    LOGS("");
-    struct unit_keyword_callback *kw;
-    struct parser_state state;
-    char *args[PARSER_MAXARGS];
-    int nargs, rc;
-
-    nargs = 0;
-    parser_init_state(&state, s);
-
-    for (;;) {
-        int token = tokenize(&state);
-        switch (token) {
-        case T_EOF:
-            return 0;
-        case T_NEWLINE:
-            if (nargs) {
-                if ((kw = keyword_lookup(ctx, args[0])) != NULL) {
-                    rc = parse_statement(ctx, nargs - 1,
-                                 &args[1],
-                                 kw->func);
-                    if (rc < 0) {
-                        return -EINVAL;
-                    }
-                }
-
-                nargs = 0;
-            }
-            break;
-        case T_STATEMENT:
-            if (nargs < PARSER_MAXARGS) {
-                args[nargs++] = state.stmt;
-            }
-            break;
-        }
-    }
-
-    return 0;
-}
-
-/* reads a file, making sure it is terminated with \n \0 */
-static char *open_stream(const char *name, unsigned int *_sz)
-{
-    int sz, fd;
-    char *data = NULL;
-
-    fd = open(name, O_RDONLY);
-    if (fd < 0)
-        return NULL;
-
-    sz = lseek(fd, 0, SEEK_END);
-    if (sz < 0)
-        goto oops;
-
-    if (lseek(fd, 0, SEEK_SET) != 0)
-        goto oops;
-
-    data = (char *)malloc(sz + 2);
-    if (data == 0)
-        goto oops;
-
-    if (read(fd, data, sz) != sz)
-        goto oops;
-
-    close(fd);
-
-    data[sz] = '\n';
-    data[sz + 1] = 0;
-    if (_sz)
-        *_sz = sz;
-
-    return data;
-
- oops:
-    close(fd);
-    if (data != 0)
-        free(data);
-
-    return NULL;
-}
-
-API int parse_stream(const char *name, struct unit_parser *parser)
-{
-    LOGS("");
-    char *stream;
-    struct parser_context *ctx;
-
-    ctx = (struct parser_context *)malloc(sizeof(struct parser_context));
-    if (ctx == NULL) {
-        return -ENOMEM;
-    }
-
-    ctx->kw = parser->kw;
-
-    /* File open & return file context */
-    stream = open_stream(name, NULL);
-    if (stream == NULL) {
-        free(ctx);
-        return -1;
-    }
-
-    parse_stream_core(ctx, stream);
-
-    free(stream);
-    free(ctx);
-
-    return 0;
-}
-API struct vsm_netdev *alloc_netdev(struct vsm_zone * /*zone*/, vsm_netdev_type_t  /*type*/, const char * /*netdev_name*/) {
-    LOGS("");
-    return NULL;
-}
-API void enter_to_ns(pid_t  /*pid*/, char * /*name*/) {
-    LOGS("");
-}
-
-// dummy-ops
-static int dummy_create_zone(vsm_context_h  /*ctx*/, const char * /*zone_name*/,
-                 const char * /*template*/, int  /*flags*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_destroy_zone(vsm_context_h  /*ctx*/, const char * /*zone_name*/, int  /*force*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_start_zone(vsm_context_h  /*ctx*/, const char * /*zone_name*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_shutdown_zone(vsm_context_h  /*ctx*/, const char * /*zone_name*/, int  /*force*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_lock_zone(vsm_context_h  /*ctx*/, const char * /*zone_name*/, int  /*shutdown*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_unlock_zone(vsm_context_h  /*ctx*/, const char * /*zone_name*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_set_foreground(vsm_zone_h  zone)
-{
-    if (zone == NULL)
-        return -VSM_ERROR_INVALID;
-
-    if (zone->parent == zone) {
-        return VSM_ERROR_NONE;
-    }
-    return -VSM_ERROR_NO_OBJECT;
-}
-
-static vsm_zone_h dummy_get_foreground(vsm_context_h  ctx)
-{
-    if (ctx == NULL) {
-        errno = EINVAL;
-        return NULL;
-    }
-
-    return ctx->root_zone;
-}
-
-static int dummy_iterate_zone(vsm_context_h  ctx, vsm_zone_iter_cb  callback, void *user_data)
-{
-    if (callback) {
-        callback(ctx->root_zone, user_data);
-    }
-    return VSM_ERROR_NONE;
-}
-
-static vsm_zone_h dummy_lookup_zone_by_name(vsm_context_h ctx, const char *name)
-{
-    if (strcmp(name, "") != 0) {
-        errno = ESRCH;
-        return NULL;
-    }
-
-    return ctx->root_zone;
-}
-
-static vsm_zone_h dummy_lookup_zone_by_pid(vsm_context_h ctx, pid_t  /*pid*/)
-{
-    if (ctx == NULL)
-        return NULL;
-
-    return ctx->root_zone;
-}
-
-static int dummy_attach_zone(vsm_context_h ctx, const char *zone_name,
-                 vsm_attach_command_s * command,
-                 vsm_attach_options_s * opts,
-                 pid_t * attached_process)
-{
-    pid_t pid;
-    struct vsm_attach_options_s options;
-
-    if (command == NULL || command->exec == NULL || zone_name == NULL) {
-        ERROR("Invalid arguments");
-        ctx->error = VSM_ERROR_INVALID;
-        return -VSM_ERROR_INVALID;
-    }
-
-    if (strcmp("", zone_name) != 0) {
-        ctx->error = VSM_ERROR_INVALID;
-        return -VSM_ERROR_INVALID;
-    }
-
-    if (opts == NULL) {
-        opts = &options;
-        opts->uid = getuid();
-        opts->gid = getgid();
-        opts->env_num = 0;
-        opts->extra_env = NULL;
-    }
-
-    pid = fork();
-    if (pid == 0) {
-        if (opts->extra_env != NULL) {
-            while (*opts->extra_env)
-                putenv(*opts->extra_env++);
-        }
-
-        if (getuid() == 0 && opts->uid != 0) {
-            if (setuid(opts->uid) != 0) {
-                ERROR("Failed to set uid : %d", opts->uid);
-            }
-        } else {
-            WARN("setuid() is not permitted");
-        }
-
-        if (getgid() == 0 && opts->gid != 0) {
-            if (setgid(opts->gid) != 0) {
-                ERROR("Failed to set gid : %d", opts->gid);
-            }
-        } else {
-            WARN("setgid() is not permitted");
-        }
-
-        if (execvp(command->exec, command->argv) < 0) {
-            ERROR("exevp failed : %s, %s", command->exec,
-                  strerror(errno));
-            exit(EXIT_FAILURE);
-        }
-    } else {
-        *attached_process = pid;
-    }
-
-    return VSM_ERROR_NONE;
-}
-
-static int dummy_attach_zone_wait(vsm_context_h  ctx, const char *zone_name,
-                  vsm_attach_command_s * command,
-                  vsm_attach_options_s * opts)
-{
-    pid_t pid = 0;
-    int ret, status;
-
-    ret = dummy_attach_zone(ctx, zone_name, command, opts, &pid);
-    if (ret != VSM_ERROR_NONE) {
-        ERROR("API Failed.");
-        return ret;
-    }
-
-    status = wait_for_pid_status(pid);
-    if (status == -1) {
-        ctx->error = VSM_ERROR_GENERIC;
-        return -VSM_ERROR_GENERIC;
-    }
-
-    INFO("attached process extied : pid - %d, exit code : %d", pid,
-         WEXITSTATUS(status));
-
-    return status;
-}
-
-static vsm_zone_h dummy_join_zone(vsm_zone_h zone)
-{
-    if (zone == NULL) {
-        errno = EINVAL;
-        return NULL;
-    }
-    if (zone != zone->parent) {
-        errno = EINVAL;
-        return NULL;
-    }
-
-    return zone;
-}
-
-static int dummy_is_equivalent_zone(vsm_context_h  /*ctx*/, pid_t  /*pid*/)
-{
-    return 1;
-}
-
-static int dummy_get_host_pid(vsm_zone_h zone, pid_t pid)
-{
-    if (zone == zone->parent)
-        return pid;
-
-    return -VSM_ERROR_NO_OBJECT;
-}
-
-static int dummy_grant_device(vsm_zone_h  /*zone*/, const char * /*path*/, uint32_t  /*flags*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_revoke_device(vsm_zone_h  /*zone*/, const char * /*path*/)
-{
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-
-static int dummy_declare_file(vsm_context_h  /*ctx*/, vsm_fso_type_t  /*ftype*/,
-                  const char * /*path*/, int  /*flags*/, vsm_mode_t  /*mode*/)
-{
-    return VSM_ERROR_NONE;
-}
-
-static int dummy_declare_link(vsm_context_h  /*ctx*/, const char *source,
-                  const char * /*target*/)
-{
-    int ret;
-
-    ret = access(source, F_OK);
-    if (ret != 0)
-        return -VSM_ERROR_NO_OBJECT;
-
-    return VSM_ERROR_NONE;
-}
-
-struct vasum_ops dummy_ops;
-static int dummy_ops_init() {
-    dummy_ops.create_zone = dummy_create_zone;
-    dummy_ops.destroy_zone = dummy_destroy_zone;
-    dummy_ops.start_zone = dummy_start_zone;
-    dummy_ops.shutdown_zone = dummy_shutdown_zone;
-    dummy_ops.lock_zone = dummy_lock_zone;
-    dummy_ops.unlock_zone = dummy_unlock_zone;
-    dummy_ops.set_foreground = dummy_set_foreground;
-    dummy_ops.get_foreground = dummy_get_foreground;
-    dummy_ops.iterate_zone = dummy_iterate_zone;
-    dummy_ops.lookup_zone_by_name = dummy_lookup_zone_by_name;
-    dummy_ops.lookup_zone_by_pid = dummy_lookup_zone_by_pid;
-    dummy_ops.attach_zone = dummy_attach_zone;
-    dummy_ops.attach_zone_wait = dummy_attach_zone_wait;
-    dummy_ops.join_zone = dummy_join_zone;
-    dummy_ops.is_equivalent_zone = dummy_is_equivalent_zone;
-    dummy_ops.get_host_pid = dummy_get_host_pid;
-    dummy_ops.grant_device = dummy_grant_device;
-    dummy_ops.revoke_device = dummy_revoke_device;
-    dummy_ops.declare_file = dummy_declare_file;
-    dummy_ops.declare_link = dummy_declare_link;
-    return 0;
-}
-int dummy_ops_init_i = dummy_ops_init();
-
-
-} //extern "C"
diff --git a/wrapper/wrapper-compatibility.h b/wrapper/wrapper-compatibility.h
deleted file mode 100644 (file)
index 2527289..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Krzysztof Dynowski <k.dynowski@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Krzysztof Dynowski (k.dynowski@samsung.com)
- * @brief   Vasum old API compatibility functions
- */
-
-#ifndef __CLIENT_WRAPPER_COMPAT__
-#define __CLIENT_WRAPPER_COMPAT__
-
-#include "vasum.h"
-#include <sys/epoll.h>
-
-extern "C" {
-typedef int (*fp_create_zone) (vsm_context_h ctx, const char *zone_name,
-                   const char *template_name, int flag);
-typedef int (*fp_destroy_zone) (vsm_context_h ctx, const char *zone_name,
-                int force);
-typedef int (*fp_start_zone) (vsm_context_h ctx, const char *zone_name);
-typedef int (*fp_shutdown_zone) (vsm_context_h ctx, const char *zone_name,
-                 int force);
-typedef int (*fp_lock_zone) (vsm_context_h ctx, const char *zone_name,
-                 int shutdown);
-typedef int (*fp_unlock_zone) (vsm_context_h ctx, const char *zone_name);
-typedef int (*fp_set_foreground) (vsm_zone_h zone);
-typedef vsm_zone_h(*fp_get_foreground) (vsm_context_h ctx);
-typedef int (*fp_iterate_zone) (vsm_context_h ctx, vsm_zone_iter_cb callback,
-                void *user_data);
-typedef vsm_zone_h(*fp_lookup_zone_by_name) (vsm_context_h ctx,
-                         const char *name);
-typedef vsm_zone_h(*fp_lookup_zone_by_pid) (vsm_context_h ctx, pid_t pid);
-typedef int (*fp_attach_zone) (vsm_context_h ctx, const char *zone_name,
-                   vsm_attach_command_s * command,
-                   vsm_attach_options_s * opt,
-                   pid_t * attached_process);
-typedef int (*fp_attach_zone_wait) (vsm_context_h ctx, const char *zone_name,
-                    vsm_attach_command_s * command,
-                    vsm_attach_options_s * opt);
-typedef vsm_zone_h(*fp_join_zone) (vsm_zone_h zone);
-typedef int (*fp_is_equivalent_zone) (vsm_context_h ctx, pid_t pid);
-typedef int (*fp_get_host_pid) (vsm_zone_h zone, pid_t pid);
-typedef int (*fp_grant_device) (vsm_zone_h zone, const char *path,
-                uint32_t flags);
-typedef int (*fp_revoke_device) (vsm_zone_h zone, const char *path);
-typedef int (*fp_declare_file) (vsm_context_h ctx, vsm_fso_type_t ftype,
-                const char *path, int flags, vsm_mode_t mode);
-typedef int (*fp_declare_link) (vsm_context_h ctx, const char *source,
-                const char *target);
-struct vasum_ops {
-    fp_create_zone create_zone;
-    fp_destroy_zone destroy_zone;
-    fp_start_zone start_zone;
-    fp_shutdown_zone shutdown_zone;
-    fp_lock_zone lock_zone;
-    fp_unlock_zone unlock_zone;
-    fp_set_foreground set_foreground;
-    fp_get_foreground get_foreground;
-    fp_iterate_zone iterate_zone;
-    fp_lookup_zone_by_name lookup_zone_by_name;
-    fp_lookup_zone_by_pid lookup_zone_by_pid;
-    fp_attach_zone attach_zone;
-    fp_attach_zone_wait attach_zone_wait;
-    fp_join_zone join_zone;
-    fp_get_host_pid get_host_pid;
-    fp_is_equivalent_zone is_equivalent_zone;
-    fp_grant_device grant_device;
-    fp_revoke_device revoke_device;
-    fp_declare_file declare_file;
-    fp_declare_link declare_link;
-};
-
-#define SERVICEPATH "\0/domain-control/service.sock"
-struct mainloop {
-    int     epfd;
-    pthread_mutex_t ml_mutex;
-    pthread_rwlock_t lock;
-    struct adt_list watches;
-};
-struct mxe_emple;
-struct mxe_endpoint;
-struct mxe_emple {
-    int signature;
-    int refcnt;
-    void *callback;
-    void *data;
-    struct mxe_proxy *proxy;
-    struct adt_list queue;
-};
-struct mxe_engine {
-    void *data;
-    struct mainloop *mainloop;
-    pthread_rwlock_t endpoint_lock;
-    struct adt_list endpoints;
-};
-struct mxe_endpoint {
-    int fd;
-    int type;
-    struct mxe_engine *engine;
-    pthread_rwlock_t queue_lock;
-    pthread_mutex_t rd_mutex;
-    pthread_mutex_t wr_mutex;
-    struct adt_list queue;
-    struct adt_list list;
-};
-
-typedef enum {
-    ML_EVT_IN   = EPOLLIN,
-    ML_EVT_OUT  = EPOLLOUT,
-    ML_EVT_RDHUP    = EPOLLRDHUP,
-    ML_EVT_ERROR    = EPOLLERR,
-    ML_EVT_HUP  = EPOLLHUP,
-    ML_EVT_ET   = EPOLLET
-}mainloop_event;
-
-typedef int (*dev_enumerator)(int type, int major, int minor, void *data);
-typedef int (*mainloop_callback)(int fd, mainloop_event event, void *data, struct mainloop *mainloop);
-
-struct mainloop *mainloop_create(void);
-struct mxe_endpoint *mxe_create_client(struct mxe_engine *engine, const char * /*addr*/);
-struct mxe_engine *mxe_prepare_engine(struct mainloop *mainloop, void *data);
-
-int wait_for_pid_status(pid_t  pid);
-
-int vsm_add_state_changed_callback(vsm_context_h  /*ctx*/, vsm_zone_state_changed_cb  /*callback*/, void * /*user_data*/);
-int vsm_del_state_changed_callback(vsm_context_h  /*ctx*/, int  /*id*/);
-const char * vsm_get_zone_rootpath(vsm_zone_h  /*zone*/);
-const char * vsm_get_zone_name(vsm_zone_h  /*zone*/);
-int vsm_is_host_zone(vsm_zone_h  /*zone*/);
-vsm_zone_h vsm_join_zone(vsm_zone_h zone);
-int vsm_canonicalize_path(const char *input_path, char **output_path);
-
-} //extern "C"
-
-#endif
diff --git a/wrapper/wrapper.cpp b/wrapper/wrapper.cpp
deleted file mode 100644 (file)
index c3a071f..0000000
+++ /dev/null
@@ -1,818 +0,0 @@
-/*
- *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Krzysztof Dynowski <k.dynowski@samsung.com>
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License
- */
-
-
-/**
- * @file
- * @author  Krzysztof Dynowski (k.dynowski@samsung.com)
- * @brief   Vasum old API wrapper to slp client lib
- */
-
-#define __VASUM_WRAPPER_SOURCE__
-#include <vector>
-#include <string.h>
-#include <algorithm>
-
-#include "config.hpp"
-#include "vasum-client-impl.hpp"
-#include "logger/logger.hpp"
-#include "logger/backend-journal.hpp"
-
-#include "wrapper-compatibility.h"
-
-struct WrappedZone
-{
-    Client *client;
-    VsmZone zone;
-    struct vsm_zone vz;
-    std::vector<vsm_netdev> netdevs;
-};
-
-struct WrappedContext
-{
-    Client *client;
-    vsm_context hq_ctx;
-    struct vsm_zone hq_root;
-    std::vector<WrappedZone> zones;
-};
-
-static struct
-{
-    int done;
-} wrap;
-
-
-#ifndef offsetof
-#define offsetof(type, memb) ((size_t)&((type *)0)->memb)
-#endif
-#ifdef container_of
-#undef container_of
-#endif
-#ifndef container_of
-#define container_of(ptr, type, memb) (\
-    (type *)((char *)(ptr) - offsetof(type, memb)))
-#endif
-
-#define UNUSED(x) ((void)(x))
-
-#define vsm_attach_command_t vsm_attach_command_s
-#define vsm_attach_options_t vsm_attach_options_s
-
-void __attribute__ ((constructor)) wrapper_load(void);
-void __attribute__ ((destructor)) wrapper_unload(void);
-static void init_wrapper();
-extern struct vasum_ops dummy_ops;
-
-using namespace logger;
-void wrapper_load(void)
-{
-    Logger::setLogLevel(LogLevel::TRACE);
-    Logger::setLogBackend(new SystemdJournalBackend());
-    LOGI("wrapper_load");
-    init_wrapper();
-}
-
-void wrapper_unload(void)
-{
-    LOGI("wrapper_unload");
-}
-
-static void callcheck()
-{
-    init_wrapper();
-}
-
-void init_wrapper()
-{
-    if (wrap.done) return ;
-    memset(&wrap, 0, sizeof(wrap));
-    wrap.done = 1;
-    LOGS("");
-}
-
-static struct vsm_zone* wrap_vsm_zone(WrappedContext *w, Zone zone, bool create = false)
-{
-    if (zone == NULL) {
-        return NULL;
-    }
-    for (auto& zw : w->zones) {
-        if (zw.zone == zone) {
-            return &zw.vz;
-        }
-    }
-    if (create) {
-        w->zones.push_back(WrappedZone());
-        WrappedZone& zw = w->zones.back();
-        zw.client = w->client;
-        zw.zone = zone;
-        zw.vz.name = zone->id;
-        zw.vz.id = 0;
-        zw.vz.type = NULL;
-        zw.vz.user_data = NULL;
-        zw.vz.rootfs_path = zone->rootfs_path;
-        zw.vz.parent = &zw.vz;
-        LOGI("return (create) zone " << zone->id);
-        return &w->zones.back().vz;
-    }
-    LOGE("return zone NULL");
-    return NULL;
-}
-
-static int wrap_error(VsmStatus st, const Client *c)
-{
-    if (st == VSMCLIENT_SUCCESS) LOGI("return success " << st);
-    else LOGE("return error=" << st << ", msg=" << (c ? c->vsm_get_status_message() : "n/a"));
-    switch (st) {
-        case VSMCLIENT_SUCCESS: return VSM_ERROR_NONE;
-        case VSMCLIENT_CUSTOM_ERROR: return -VSM_ERROR_GENERIC;
-        case VSMCLIENT_IO_ERROR: return -VSM_ERROR_IO;
-        case VSMCLIENT_OPERATION_FAILED: return -VSM_ERROR_NOT_PERMITTED;
-        case VSMCLIENT_INVALID_ARGUMENT: return -VSM_ERROR_INVALID;
-        case VSMCLIENT_OTHER_ERROR: return -VSM_ERROR_GENERIC;
-    }
-    return -VSM_ERROR_GENERIC;
-}
-
-static void init_context_wrap(WrappedContext *w)
-{
-    w->client = new Client();
-    VsmStatus st = w->client->connectSystem();
-    wrap_error(st, w->client);
-
-    memset(&w->hq_ctx, 0, sizeof(w->hq_ctx));
-    memset(&w->hq_root, 0, sizeof(w->hq_root));
-
-    vsm_context *ctx = &w->hq_ctx;
-    adt_init_list(&ctx->listeners);
-    //init root_zone
-    ctx->root_zone = &w->hq_root;
-    ctx->root_zone->name = (char*)"";
-    ctx->root_zone->id = 0;
-    ctx->root_zone->rootfs_path = (char*)"/";
-
-    ctx->root_zone->terminal = -1;
-    ctx->root_zone->state = VSM_ZONE_STATE_RUNNING;
-    ctx->root_zone->user_data = ctx->root_zone;
-
-    ctx->root_zone->parent = ctx->root_zone;
-    ctx->root_zone->ctx = ctx;
-
-    pthread_rwlock_init(&ctx->root_zone->lock, NULL);
-    adt_init_list(&ctx->root_zone->netdevs);
-    adt_init_list(&ctx->root_zone->devices);
-    adt_init_list(&ctx->root_zone->children);
-
-    pthread_rwlock_init(&ctx->lock, NULL);
-    adt_init_list(&ctx->listeners);
-    adt_init_list(&ctx->sc_listeners);
-    adt_init_list(&ctx->ev_listeners);
-
-    //struct mainloop *mainloop = mainloop_create();
-    //struct mxe_engine *engine = mxe_prepare_engine(mainloop, ctx);
-    //struct mxe_endpoint *ep = mxe_create_client(engine, SERVICEPATH);
-
-    ctx->foreground_zone = ctx->root_zone;
-    ctx->vsm_ops = &dummy_ops;
-    ctx->error = VSM_ERROR_NONE;
-    //ctx->data = ep;
-}
-
-extern "C" {
-API void vsm_string_free(VsmString string);
-API void vsm_array_string_free(VsmArrayString astring);
-
-API vsm_context_h vsm_create_context(void)
-{
-    LOGS("");
-    callcheck();
-    WrappedContext *w = new WrappedContext();
-    init_context_wrap(w);
-
-    vsm_context *ctx = &w->hq_ctx;
-    return ctx;
-}
-
-API int vsm_cleanup_context(vsm_context_h ctx)
-{
-    LOGS("");
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    if (w->client != NULL) {
-        delete w->client;
-        w->client = NULL;
-    }
-    for (auto& zw : w->zones) {
-        zw.netdevs.clear();
-    }
-    w->zones.clear();
-    pthread_rwlock_destroy(&ctx->lock);
-    delete w;
-    return VSM_ERROR_NONE;
-}
-
-static const char *const vsm_error_strtab[] = {
-    "No error",
-    "Undefined error",
-    "Invalid",
-    "Operation cancelled",
-    "Operation aborted",
-    "Connection refused",
-    "Object exists",
-    "Resource busy",
-    "Input/Output error",
-    "Timeout",
-    "Overflow",
-    "Out of memory",
-    "Out of range",
-    "Operation not permitted",
-    "Function not implemented",
-    "Operation not supported",
-    "Access denied",
-    "No object found",
-    "Bad state"
-};
-
-API vsm_error_e vsm_last_error(struct vsm_context *ctx)
-{
-    if (ctx)
-        return ctx->error;
-    return static_cast<vsm_error_e>(-1);
-}
-
-API int vsm_get_poll_fd(struct vsm_context *ctx)
-{
-    LOGS("");
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    UNUSED(w);
-    //FIXME Client should create Dispatcher and pass to IPCConnection
-    //      now: IPCConnection has field ThreadWrapper
-    //return w->client->getEventPoll().getPollFD();
-    return -1;
-}
-API int vsm_enter_eventloop(struct vsm_context *ctx, int flags, int timeout)
-{
-    LOGS("");
-    callcheck();
-    UNUSED(flags);
-    UNUSED(timeout);
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    UNUSED(w);
-    //FIXME Client should create Dispatcher and pass to IPCConnection
-    //      now: IPCConnection has field ThreadWrapper
-    //TODO Use EventPoll from Dispatcher
-    return 0;
-}
-
-API int vsm_create_zone(struct vsm_context *ctx, const char *zone_name, const char *template_name, int flag)
-{
-    LOGS("create_zone " << zone_name);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    UNUSED(flag);
-    //template_name = NULL; //template name not supported by libvasum-client
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_create_zone(zone_name, template_name);
-    if (st != VSMCLIENT_SUCCESS) {
-        LOGE("vsm_create_zone(" << zone_name << ") = " << st);
-    }
-    return wrap_error(st, w->client);
-}
-
-API int vsm_destroy_zone(struct vsm_context *ctx, const char *zone_name, int force)
-{
-    LOGS("zone=" << zone_name);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    UNUSED(force);
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_destroy_zone(zone_name);
-    if (st == VSMCLIENT_SUCCESS) {
-        auto zonebyname = [zone_name](const WrappedZone& v) {
-            return static_cast<Zone>(v.zone)->id == zone_name;
-        };
-        auto zonelist = std::remove_if(w->zones.begin(), w->zones.end(), zonebyname);
-        w->zones.erase(zonelist);
-    }
-    return wrap_error(st, w->client);
-}
-
-API int vsm_start_zone(struct vsm_context *ctx, const char *zone_name)
-{
-    LOGS("zone=" << zone_name);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_start_zone(zone_name);
-    return wrap_error(st, w->client);
-}
-
-API int vsm_shutdown_zone(struct vsm_context *ctx, const char *zone_name, int force)
-{
-    LOGS("zone=" << zone_name);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    UNUSED(force);
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_shutdown_zone(zone_name);
-    return wrap_error(st, w->client);
-}
-
-API int vsm_lock_zone(struct vsm_context *ctx, const char *zone_name, int shutdown)
-{
-    LOGS("zone=" << zone_name);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    UNUSED(shutdown);
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_lock_zone(zone_name);
-    return wrap_error(st, w->client);
-}
-
-API int vsm_unlock_zone(struct vsm_context *ctx, const char *zone_name)
-{
-    LOGS("zone=" << zone_name);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_lock_zone(zone_name);
-    return wrap_error(st, w->client);
-}
-
-API int vsm_set_foreground(struct vsm_zone *zone)
-{
-    LOGS("");
-    callcheck();
-    WrappedZone *w = container_of(zone, WrappedZone, vz);
-    if (!w->client) return VSM_ERROR_GENERIC;
-    VsmStatus st = w->client->vsm_set_active_zone(zone->name);
-    return wrap_error(st, w->client);
-}
-
-//execute command in specified zone
-API int vsm_attach_zone(struct vsm_context *ctx,
-                        const char *zone_name,
-                        vsm_attach_command_t *command,
-                        vsm_attach_options_t *opts,
-                        pid_t *attached_process)
-{
-    return dummy_ops.attach_zone(ctx, zone_name, command, opts,
-                     attached_process);
-}
-
-//execute command in specified zone and wait
-API int vsm_attach_zone_wait(struct vsm_context *ctx,
-                             const char *zone_name,
-                             vsm_attach_command_t *command,
-                             vsm_attach_options_t *opts)
-{
-    return dummy_ops.attach_zone_wait(ctx, zone_name, command, opts);
-}
-
-API int vsm_iterate_zone(struct vsm_context *ctx, void (*callback)(struct vsm_zone *zone, void *user_data), void *user_data)
-{
-    LOGS("");
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    if (!w->client) return -VSM_ERROR_GENERIC;
-    callback(ctx->root_zone, user_data);
-    for (auto& z : w->zones) {
-        LOGI("iterate callback zone: " << static_cast<Zone>(z.zone)->id);
-        callback(&z.vz, user_data);
-    }
-    return 0;
-}
-
-API struct vsm_zone *vsm_lookup_zone_by_name(struct vsm_context *ctx, const char *path)
-{
-    LOGS("name=" << path);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    Zone zone;
-    if (!w->client) return NULL;
-    //CHECK if path is same as zone_name
-    if (w->client->vsm_lookup_zone_by_id(path, &zone) != VSMCLIENT_SUCCESS)
-        return NULL;
-    return wrap_vsm_zone(w, zone, true);
-}
-
-//supposed return ref to internal struct
-API struct vsm_zone *vsm_lookup_zone_by_pid(struct vsm_context *ctx, pid_t pid)
-{
-    LOGS("pid=" << pid);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    Zone zone;
-    VsmString id;
-    VsmStatus st;
-    if (!w->client) return NULL;
-    if ((st = w->client->vsm_lookup_zone_by_pid(pid, &id)) != VSMCLIENT_SUCCESS) {
-        wrap_error(st, w->client);
-        return NULL;
-    }
-    LOGI("found zone(pid=" << pid << ")='" << id << "'");
-    if (::strcmp(id, "host") == 0) {
-        return w->hq_ctx.root_zone;
-    }
-    w->client->vsm_lookup_zone_by_id(id, &zone); //zone is malloced
-    return wrap_vsm_zone(w, zone);
-}
-
-API int vsm_add_state_changed_callback(struct vsm_context *ctx, vsm_zone_state_changed_cb callback, void *user_data)
-{
-    LOGS("");
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    VsmSubscriptionId subscriptionId;
-
-    auto dbus_cb = [=](const char* id, const char* dbusAddress, void* data) ->
-    void {
-        Zone zone;
-        //TODO what are valid state, event
-        vsm_zone_state_t t = VSM_ZONE_STATE_RUNNING;
-        UNUSED(dbusAddress);
-        w->client->vsm_lookup_zone_by_id(id, &zone);
-        callback(wrap_vsm_zone(w, zone), t, data);
-    };
-    w->client->vsm_add_state_callback(dbus_cb, user_data, &subscriptionId);
-    return (int)subscriptionId;
-}
-
-API int vsm_del_state_changed_callback(struct vsm_context *ctx, int handle)
-{
-    LOGS("");
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    VsmSubscriptionId subscriptionId = (VsmSubscriptionId)handle;
-    VsmStatus st = w->client->vsm_del_state_callback(subscriptionId);
-    return wrap_error(st, w->client);
-}
-
-API int vsm_grant_device(struct vsm_zone *dom, const char *name, uint32_t flags)
-{
-    LOGS("");
-    callcheck();
-    WrappedZone *w = container_of(dom, WrappedZone, vz);
-    const char *id = dom->name;
-    Zone zone;
-    w->client->vsm_lookup_zone_by_id(id, &zone);
-    VsmStatus st = w->client->vsm_grant_device(id, name, flags);
-    return wrap_error(st, w->client);
-}
-
-API int vsm_revoke_device(struct vsm_zone *dom, const char *name)
-{
-    LOGS("");
-    callcheck();
-    WrappedZone *w = container_of(dom, WrappedZone, vz);
-    const char *id = dom->name;
-    VsmStatus st = w->client->vsm_revoke_device(id, name);
-    return wrap_error(st, w->client);
-}
-
-API struct vsm_netdev *vsm_create_netdev(struct vsm_zone *zone, vsm_netdev_type_t type, const char *target, const char *netdev)
-{
-    LOGS("");
-    callcheck();
-    UNUSED(zone);
-    UNUSED(type);
-    UNUSED(target);
-    UNUSED(netdev);
-
-    WrappedZone *w = container_of(zone, WrappedZone, vz);
-    const char *id = zone->name;
-    VsmStatus st;
-    if (type == VSM_NETDEV_VETH)
-        st = w->client->vsm_create_netdev_veth(id, target, netdev);
-    else if (type == VSM_NETDEV_PHYS)
-        st = w->client->vsm_create_netdev_phys(id, netdev);
-    else if (type == VSM_NETDEV_MACVLAN) // macvlan_mode from if_link.h
-        st = w->client->vsm_create_netdev_macvlan(id, target, netdev, MACVLAN_MODE_BRIDGE);
-    else {
-        LOGE("Invalid arguments");
-        //ctx->error = VSM_ERROR_INVALID;
-        return NULL;
-    }
-
-    if (st != VSMCLIENT_SUCCESS) {
-        LOGE("vsm_create_netdev(" << netdev << ") = " << st);
-        return NULL;
-    }
-
-    vsm_netdev vnd;
-    vnd.zone = zone;
-    vnd.name = (char*)netdev; //FIXME? copy content of string
-    vnd.type = type;
-    w->netdevs.push_back(vnd); //copy pushed to vector
-    return &w->netdevs.back(); //pointer to struct on vector
-}
-
-API int vsm_destroy_netdev(vsm_netdev_h)
-{
-    LOGS("");
-    return 0;
-}
-
-API int vsm_iterate_netdev(struct vsm_zone *zone, void (*callback)(struct vsm_netdev *, void *user_data), void *user_data)
-{
-    LOGS("");
-    callcheck();
-    WrappedZone *w = container_of(zone, WrappedZone, vz);
-    for (auto nd : w->netdevs) {
-        callback(&nd, user_data);
-    }
-    return 0;
-}
-
-API struct vsm_netdev *vsm_lookup_netdev_by_name(struct vsm_zone *zone, const char *name)
-{
-    LOGS("");
-    callcheck();
-    WrappedZone *w = container_of(zone, WrappedZone, vz);
-    Netdev nd;
-    VsmStatus st = w->client->vsm_lookup_netdev_by_name(zone->name, name, &nd);
-    if (st == VSMCLIENT_SUCCESS) {
-        auto devbyname = [name](const vsm_netdev& v) {return ::strcmp(v.name, name) == 0;};
-        auto devlist = std::find_if(w->netdevs.begin(), w->netdevs.end(), devbyname);
-        if (devlist != w->netdevs.end()) {
-            return &devlist[0];
-        }
-    }
-    return NULL;
-}
-
-API int vsm_declare_file(struct vsm_context *ctx, vsm_fso_type_t ftype, const char *path, int flags, vsm_mode_t mode)
-{
-    LOGS("");
-    callcheck();
-/*  Old implementation is following: (but implemented in server)
-    args.oldpath = oldpath;
-    args.newpath = newpath;
-    ret = iterate_running_zone("/sys/fs/cgroup/cpuset/lxc", file_resource, &args);
-*/
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    VsmArrayString ids = NULL;
-    VsmFileType type;
-    switch (ftype) {
-        case VSM_FSO_TYPE_DIR:  /**< Directoy type */
-            type = VSMFILE_DIRECTORY;
-            break;
-        case VSM_FSO_TYPE_REG:  /**< Regular file type */
-            type = VSMFILE_REGULAR;
-            break;
-        case VSM_FSO_TYPE_FIFO: /**< Fifo file type */
-            type = VSMFILE_FIFO;
-            break;
-        case VSM_FSO_TYPE_SOCK: /**< Socket file type */
-            return VSM_ERROR_NONE;
-        case VSM_FSO_TYPE_DEV:  /**< Device node type */
-            return VSM_ERROR_NONE;
-        default:
-            return VSM_ERROR_NONE;
-    }
-    w->client->vsm_get_zone_ids(&ids);
-    if (ids != NULL) {
-        for (VsmString* id = ids; *id; ++id) {
-            VsmStatus st = w->client->vsm_declare_file(*id, type, path, (int32_t)flags, (mode_t)mode, NULL);
-            if (st != VSMCLIENT_SUCCESS) {
-                wrap_error(st, w->client);
-            }
-        }
-    }
-    vsm_array_string_free(ids);
-    return VSM_ERROR_NONE;
-}
-
-API int vsm_declare_link(struct vsm_context *ctx, const char *source, const char *target)
-{
-    LOGS("src=" << source << ", dst=" << target);
-    callcheck();
-/*  Old implementation is following: (but implemented in server)
-    args.oldpath = oldpath;
-    args.newpath = newpath;
-    ret = iterate_running_zone("/sys/fs/cgroup/cpuset/lxc", link_resource, &args);
-*/
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    VsmArrayString ids = NULL;
-    w->client->vsm_get_zone_ids(&ids);
-    if (ids != NULL)
-    for (VsmString* id = ids; *id; ++id) {
-        VsmStatus st = w->client->vsm_declare_link(source, *id, target, NULL);
-        if (st != VSMCLIENT_SUCCESS)
-            wrap_error(st, w->client);
-    }
-    vsm_array_string_free(ids);
-    return VSM_ERROR_NONE;
-}
-
-API int vsm_declare_mount(struct vsm_context *ctx,
-                          const char *source,
-                          const char *target,
-                          const char *fstype,
-                          unsigned long flags,
-                          const void *data)
-{
-    LOGS("");
-    callcheck();
-/*  Old implementation is following: (but implemented in server)
-    args.oldpath = oldpath;
-    args.newpath = newpath;
-    ret = iterate_running_zone("/sys/fs/cgroup/cpuset/lxc", mount_resource, &args);
-*/
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    VsmArrayString ids = NULL;
-    w->client->vsm_get_zone_ids(&ids);
-    if (ids != NULL) {
-        for (VsmString* id = ids; *id; ++id) {
-            VsmStatus st = w->client->vsm_declare_mount(source, *id, target, fstype, flags, (const char *)data, NULL);
-            if (st != VSMCLIENT_SUCCESS) {
-                wrap_error(st, w->client);
-            }
-        }
-    }
-    vsm_array_string_free(ids);
-    return VSM_ERROR_NONE;
-}
-
-API const char * vsm_get_zone_rootpath(vsm_zone_h  zone)
-{
-    LOGS("");
-    return zone == NULL ? NULL : zone->rootfs_path;
-}
-API const char * vsm_get_zone_name(vsm_zone_h zone)
-{
-    LOGS("");
-    return zone == NULL ? NULL : zone->name;
-}
-API int vsm_is_host_zone(vsm_zone_h zone)
-{
-    LOGS("");
-    if (zone == NULL)
-        return -VSM_ERROR_INVALID;
-
-    LOGI("zone->parent == zone is " << (zone->parent == zone ? 1 : 0));
-    return zone->parent == zone ? 1 : 0;
-}
-API vsm_zone_h vsm_join_zone(vsm_zone_h  /*zone*/)
-{
-    LOGS("");
-    return NULL;
-}
-API int vsm_canonicalize_path(const char *input_path, char **output_path)
-{
-    LOGS(""<<input_path);
-    *output_path = strdup(input_path);
-    int len = strlen(input_path);
-    return len;
-}
-
-// Note: support the newer API (incomaptible with older)
-API const char *vsm_error_string(vsm_error_e error)
-{
-    LOGS("");
-    callcheck();
-    if (error < 0 || error > VSM_MAX_ERROR) {
-        return NULL;
-    }
-    return vsm_error_strtab[error];
-}
-
-API struct vsm_zone *vsm_lookup_zone_by_terminal_id(struct vsm_context *ctx, int terminal)
-{
-    LOGS("terminal=" << terminal);
-    callcheck();
-    WrappedContext *w = container_of(ctx, WrappedContext, hq_ctx);
-    Zone zone;
-    VsmString id;
-    if (!w->client) return NULL;
-    if (w->client->vsm_lookup_zone_by_terminal_id(terminal, &id) != VSMCLIENT_SUCCESS)
-        return NULL;
-    w->client->vsm_lookup_zone_by_id(id, &zone);
-    return wrap_vsm_zone(w, zone);
-}
-
-API void vsm_array_string_free(VsmArrayString astring)
-{
-    if (!astring) {
-        return;
-    }
-    for (char** ptr = astring; *ptr; ++ptr) {
-        vsm_string_free(*ptr);
-    }
-    free(astring);
-}
-
-API void vsm_string_free(VsmString string)
-{
-    free(string);
-}
-
-API int vsm_add_event_callback(vsm_context_h, vsm_zone_event_cb, void*) {
-    LOGS("");
-    return 0;
-}
-API int vsm_del_event_callback(vsm_context_h, int) {
-    LOGS("");
-    return 0;
-}
-API int vsm_add_state_callback(vsm_context_h , vsm_zone_state_cb , void *) {
-    LOGS("");
-    return 0;
-}
-API int vsm_del_state_callback(vsm_context_h , int ) {
-    LOGS("");
-    return 0;
-}
-API int vsm_down_netdev(vsm_netdev_h) {
-    LOGS("");
-    return 0;
-}
-API vsm_zone* vsm_get_foreground(vsm_context_h ctx) {
-    LOGS("");
-    //return ((struct vasum_ops *)(ctx->vsm_ops))->get_foreground(ctx);
-    return dummy_ops.get_foreground(ctx);
-}
-API int vsm_get_host_pid(vsm_zone_h, pid_t) {
-    LOGS("");
-    return 0;
-}
-API int vsm_get_ip_addr_netdev(vsm_netdev_h, vsm_netdev_addr_t, char*, int) {
-    LOGS("");
-    return 0;
-}
-API void* vsm_get_userdata(vsm_zone_h) {
-    LOGS("");
-    return NULL;
-}
-API int vsm_get_zone_id(vsm_zone_h zone) {
-    LOGS("");
-    if (zone == NULL)
-        return -VSM_ERROR_INVALID;
-    return zone->id;
-}
-API vsm_zone_state_t vsm_get_zone_state(vsm_zone_h zone) {
-    LOGS("");
-    if (zone == NULL)
-        return static_cast<vsm_zone_state_t>(-VSM_ERROR_INVALID);
-    return zone->state;
-}
-API int vsm_get_zone_terminal(vsm_zone_h) {
-    LOGS("");
-    return -VSM_ERROR_NOT_SUPPORTED;
-}
-API const char *vsm_get_zone_type(vsm_zone_h zone) {
-    LOGS("");
-    return zone == NULL ? NULL : zone->type;
-}
-API int vsm_is_equivalent_zone(vsm_context_h, pid_t) {
-    LOGS("");
-    return 0;
-}
-API int vsm_is_virtualized() {
-    LOGS("");
-    return 0; /* Running in Host */
-}
-// libs/network.c
-API int vsm_set_ip_addr_netdev(vsm_netdev_h, vsm_netdev_addr_t, const char*, int) {
-    LOGS("");
-    return 0;
-}
-API int vsm_up_netdev(vsm_netdev_h) {
-    LOGS("");
-    return 0;
-}
-// libs/zone.c
-API int vsm_set_userdata(vsm_zone_h, void*) {
-    LOGS("");
-    return 0;
-}
-API int vsm_state_change_watch_callback(struct vsm_context * /*ctx*/, char * /*name*/,
-                    int  /*state*/, int  /*event*/) {
-    LOGS("");
-    return 0;
-}
-// libs/vsm_signal.c
-API int vsm_signal_state_broadcast(struct mxe_engine * /*engine*/, const char * /*zone_name*/, int  /*state*/) {
-    LOGS("");
-    return 0;
-}
-API int vsm_signal_event_broadcast(struct mxe_engine * /*engine*/, const char * /*zone_name*/, int  /*event*/) {
-    LOGS("");
-    return 0;
-}
-} // extern "C"