backing out to version 208 of util-vserver
[util-vserver.git] / ensc_wrappers / wrappers-vserver.hc
1 // $Id: wrappers-vserver.hc,v 1.11 2004/10/19 23:11:23 ensc Exp $    --*- 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 inline static WRAPPER_DECL xid_t
24 Evc_new_s_context(xid_t ctx, unsigned int remove_cap, unsigned int flags)
25 {
26   register xid_t        res = vc_new_s_context(ctx,remove_cap,flags);
27   FatalErrnoError(res==VC_NOCTX, "vc_new_s_context()");
28   return res;
29 }
30
31 inline static WRAPPER_DECL xid_t
32 Evc_get_task_xid(pid_t pid)
33 {
34   register xid_t        res = vc_get_task_xid(pid);
35   FatalErrnoError(res==VC_NOCTX, "vc_get_task_xid()");
36   return res;
37 }
38
39 inline static WRAPPER_DECL xid_t
40 Evc_ctx_create(xid_t xid)
41 {
42   register xid_t        res = vc_ctx_create(xid);
43   FatalErrnoError(res==VC_NOCTX, "vc_ctx_create()");
44   return res;
45 }
46
47 inline static WRAPPER_DECL void
48 Evc_ctx_migrate(xid_t xid)
49 {
50   FatalErrnoError(vc_ctx_migrate(xid)==-1, "vc_ctx_migrate()");
51 }
52
53 inline static WRAPPER_DECL void
54 Evc_get_cflags(xid_t xid, struct vc_ctx_flags *flags)
55 {
56   FatalErrnoError(vc_get_cflags(xid, flags)==-1, "vc_get_cflags()");
57 }
58
59 inline static WRAPPER_DECL void
60 Evc_set_cflags(xid_t xid, struct vc_ctx_flags const *flags)
61 {
62   FatalErrnoError(vc_set_cflags(xid, flags)==-1, "vc_set_cflags()");
63 }
64
65 inline static WRAPPER_DECL void
66 Evc_set_vhi_name(xid_t xid, vc_uts_type type,
67                  char const *val, size_t len)
68 {
69   FatalErrnoError(vc_set_vhi_name(xid,type,val,len)==-1, "vc_set_vhi_name()");
70 }
71
72 inline static WRAPPER_DECL void
73 Evc_get_ccaps(xid_t xid, struct vc_ctx_caps *caps)
74 {
75   FatalErrnoError(vc_get_ccaps(xid, caps)==-1, "vc_get_ccaps()");
76 }
77
78 inline static WRAPPER_DECL void
79 Evc_set_ccaps(xid_t xid, struct vc_ctx_caps const *caps)
80 {
81   FatalErrnoError(vc_set_ccaps(xid, caps)==-1, "vc_set_ccaps()");
82 }
83
84 inline static WRAPPER_DECL void
85 Evc_set_namespace()
86 {
87   FatalErrnoError(vc_set_namespace()==-1, "vc_set_namespace()");
88 }
89
90 inline static WRAPPER_DECL void
91 Evc_enter_namespace(xid_t xid)
92 {
93   FatalErrnoError(vc_enter_namespace(xid)==-1, "vc_enter_namespace()");
94 }
95
96 inline static WRAPPER_DECL xid_t
97 Evc_xidopt2xid(char const *id, bool honor_static)
98 {
99   char const *  err;
100   xid_t         rc = vc_xidopt2xid(id, honor_static, &err);
101   if (__builtin_expect(rc==VC_NOCTX,0)) {
102     ENSC_DETAIL1(msg, "vc_xidopt2xid", id, 1);
103 #if 1
104     FatalErrnoErrorFail(msg);
105 #else
106     {
107       size_t    l1 = strlen(msg);
108       size_t    l2 = strlen(err);
109       char      buf[l1 + l2 + sizeof(": ")];
110       memcpy(buf,       msg, l1);
111       memcpy(buf+l1,   ": ", 2);
112       memcpy(buf+l1+2,  err, l2+1);
113
114       FatalErrnoErrorFail(buf);
115     }
116 #endif    
117   }
118
119   return rc;
120 }