added chain-echo
[util-vserver.git] / util-vserver / ensc_wrappers / wrappers-vserver.hc
index 280a114..189c61c 100644 (file)
@@ -20,9 +20,7 @@
 #  error wrappers_handler.hc can not be used in this way
 #endif
 
-#include <vserver.h>
-
-inline static UNUSED xid_t
+inline static WRAPPER_DECL xid_t
 Evc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
 {
   register xid_t       res = vc_new_s_context(ctx,remove_cap,flags);
@@ -30,10 +28,81 @@ Evc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
   return res;
 }
 
-inline static UNUSED xid_t
+inline static WRAPPER_DECL xid_t
 Evc_get_task_xid(pid_t pid)
 {
   register xid_t       res = vc_get_task_xid(pid);
   FatalErrnoError(res==VC_NOCTX, "vc_get_task_xid()");
   return res;
 }
+
+inline static WRAPPER_DECL xid_t
+Evc_ctx_create(xid_t xid)
+{
+  register xid_t       res = vc_ctx_create(xid);
+  FatalErrnoError(res==VC_NOCTX, "vc_ctx_create()");
+  return res;
+}
+
+inline static WRAPPER_DECL void
+Evc_ctx_migrate(xid_t xid)
+{
+  FatalErrnoError(vc_ctx_migrate(xid)==-1, "vc_ctx_migrate()");
+}
+
+inline static WRAPPER_DECL void
+Evc_get_cflags(xid_t xid, struct vc_ctx_flags *flags)
+{
+  FatalErrnoError(vc_get_cflags(xid, flags)==-1, "vc_get_cflags()");
+}
+
+inline static WRAPPER_DECL void
+Evc_set_cflags(xid_t xid, struct vc_ctx_flags const *flags)
+{
+  FatalErrnoError(vc_set_cflags(xid, flags)==-1, "vc_set_cflags()");
+}
+
+inline static WRAPPER_DECL void
+Evc_set_vhi_name(xid_t xid, vc_uts_type type,
+                char const *val, size_t len)
+{
+  FatalErrnoError(vc_set_vhi_name(xid,type,val,len)==-1, "vc_set_vhi_name()");
+}
+
+inline static WRAPPER_DECL void
+Evc_get_ccaps(xid_t xid, struct vc_ctx_caps *caps)
+{
+  FatalErrnoError(vc_get_ccaps(xid, caps)==-1, "vc_get_ccaps()");
+}
+
+inline static WRAPPER_DECL void
+Evc_set_ccaps(xid_t xid, struct vc_ctx_caps const *caps)
+{
+  FatalErrnoError(vc_set_ccaps(xid, caps)==-1, "vc_set_ccaps()");
+}
+
+inline static WRAPPER_DECL xid_t
+Evc_xidopt2xid(char const *id, bool honor_static)
+{
+  char const * err;
+  xid_t                rc = vc_xidopt2xid(id, honor_static, &err);
+  if (__builtin_expect(rc==VC_NOCTX,0)) {
+    ENSC_DETAIL1(msg, "vc_xidopt2xid", id, 1);
+#if 1
+    FatalErrnoErrorFail(msg);
+#else
+    {
+      size_t   l1 = strlen(msg);
+      size_t   l2 = strlen(err);
+      char     buf[l1 + l2 + sizeof(": ")];
+      memcpy(buf,       msg, l1);
+      memcpy(buf+l1,   ": ", 2);
+      memcpy(buf+l1+2,  err, l2+1);
+
+      FatalErrnoErrorFail(buf);
+    }
+#endif    
+  }
+
+  return rc;
+}