Fix Makefiles and the manifest to include all the files needed.
[util-vserver.git] / ensc_wrappers / wrappers-vserver.hc
1 // $Id$    --*- c++ -*--
2
3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19 #ifndef H_ENSC_IN_WRAPPERS_H
20 #  error wrappers_handler.hc can not be used in this way
21 #endif
22
23 #if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY)
24
25 inline static WRAPPER_DECL xid_t
26 Evc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
27 {
28   register xid_t        res = vc_new_s_context(ctx,remove_cap,flags);
29   FatalErrnoError(res==VC_NOCTX, "vc_new_s_context()");
30   return res;
31 }
32
33 #endif
34
35 inline static WRAPPER_DECL xid_t
36 Evc_get_task_xid(pid_t pid)
37 {
38   register xid_t        res = vc_get_task_xid(pid);
39   FatalErrnoError(res==VC_NOCTX, "vc_get_task_xid()");
40   return res;
41 }
42
43 inline static WRAPPER_DECL xid_t
44 Evc_ctx_create(xid_t xid)
45 {
46   register xid_t        res = vc_ctx_create(xid);
47   FatalErrnoError(res==VC_NOCTX, "vc_ctx_create()");
48   return res;
49 }
50
51 inline static WRAPPER_DECL void
52 Evc_ctx_migrate(xid_t xid)
53 {
54   FatalErrnoError(vc_ctx_migrate(xid)==-1, "vc_ctx_migrate()");
55 }
56
57 inline static WRAPPER_DECL void
58 Evc_get_cflags(xid_t xid, struct vc_ctx_flags *flags)
59 {
60   FatalErrnoError(vc_get_cflags(xid, flags)==-1, "vc_get_cflags()");
61 }
62
63 inline static WRAPPER_DECL void
64 Evc_set_cflags(xid_t xid, struct vc_ctx_flags const *flags)
65 {
66   FatalErrnoError(vc_set_cflags(xid, flags)==-1, "vc_set_cflags()");
67 }
68
69 inline static WRAPPER_DECL void
70 Evc_set_vhi_name(xid_t xid, vc_uts_type type,
71                  char const *val, size_t len)
72 {
73   FatalErrnoError(vc_set_vhi_name(xid,type,val,len)==-1, "vc_set_vhi_name()");
74 }
75
76 inline static WRAPPER_DECL void
77 Evc_get_ccaps(xid_t xid, struct vc_ctx_caps *caps)
78 {
79   FatalErrnoError(vc_get_ccaps(xid, caps)==-1, "vc_get_ccaps()");
80 }
81
82 inline static WRAPPER_DECL void
83 Evc_set_ccaps(xid_t xid, struct vc_ctx_caps const *caps)
84 {
85   FatalErrnoError(vc_set_ccaps(xid, caps)==-1, "vc_set_ccaps()");
86 }
87
88 inline static WRAPPER_DECL void
89 Evc_set_namespace()
90 {
91   FatalErrnoError(vc_set_namespace()==-1, "vc_set_namespace()");
92 }
93
94 inline static WRAPPER_DECL void
95 Evc_enter_namespace(xid_t xid)
96 {
97   FatalErrnoError(vc_enter_namespace(xid)==-1, "vc_enter_namespace()");
98 }
99
100 inline static WRAPPER_DECL xid_t
101 Evc_xidopt2xid(char const *id, bool honor_static)
102 {
103   char const *  err;
104   xid_t         rc = vc_xidopt2xid(id, honor_static, &err);
105   if (__builtin_expect(rc==VC_NOCTX,0)) {
106     ENSC_DETAIL1(msg, "vc_xidopt2xid", id, 1);
107 #if 1
108     FatalErrnoErrorFail(msg);
109 #else
110     {
111       size_t    l1 = strlen(msg);
112       size_t    l2 = strlen(err);
113       char      buf[l1 + l2 + sizeof(": ")];
114       memcpy(buf,       msg, l1);
115       memcpy(buf+l1,   ": ", 2);
116       memcpy(buf+l1+2,  err, l2+1);
117
118       FatalErrnoErrorFail(buf);
119     }
120 #endif    
121   }
122
123   return rc;
124 }