fixed warnings when compiled without legacy-mode
[util-vserver.git] / util-vserver / lib_internal / switchtowatchxid.c
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 #ifdef HAVE_CONFIG_H
20 #  include <config.h>
21 #endif
22
23 #include <vserver.h>
24 #include <errno.h>
25
26   // try to switch in context 1
27 bool
28 switchToWatchXid(char const **errptr)
29 {
30 #if 0
31 #  warning Compiling in debug-code
32   return;
33 #endif
34   if (vc_get_task_xid(0)==1) return true;
35
36   if (vc_isSupported(vcFEATURE_MIGRATE)) {
37     if (vc_ctx_create(1)==VC_NOCTX) {
38       if (errno!=EEXIST) {
39         if (errptr) *errptr = "vc_create_context()";
40         return false;
41       }
42
43       if (vc_ctx_migrate(1)==-1) {
44         if (errptr) *errptr = "vc_migrate_context()";
45         return false;
46       }
47     }
48   }
49   else {
50 #if VC_ENABLE_API_COMPAT
51     if (vc_new_s_context(1,0,0)==VC_NOCTX) {
52       if (errptr) *errptr = "vc_new_s_context()";
53       return false;
54     }
55 #else
56     if (errptr) *errptr = "can not change context: migrate kernel feature missing and 'compat' API disabled";
57     errno = ENOSYS;
58     return false;
59 #endif
60   }
61
62   return true;
63 }
64