gentoo: use /var/run for new /run compatibility
[util-vserver.git] / lib / issupported.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 "assert.h"
25
26 bool
27 vc_isSupported(vcFeatureSet feature)
28 {
29   int           ver = vc_get_version();
30   vc_vci_t      conf = vc_get_vci();
31   int           linux_ver = vc_get_kernel();
32   if (ver==-1) return false;
33   if (conf==(vc_vci_t)-1) conf = 0;
34
35   switch (feature) {
36     case vcFEATURE_COMPAT       :  return true;
37     case vcFEATURE_VSHELPER0    :  return ver >= 0x00010000 && ver < 0x00010010;
38     case vcFEATURE_VSHELPER     :  return ver >= 0x00010000;
39     case vcFEATURE_VKILL        :  return ver >= 0x00010004;
40     case vcFEATURE_RLIMIT       :  return ver >= 0x00010004;
41     case vcFEATURE_VINFO        :  return ver >= 0x00010010;
42     case vcFEATURE_VHI          :  return ver >= 0x00010010;
43     case vcFEATURE_IATTR        :  return ver >= 0x00010011;
44     case vcFEATURE_MIGRATE      :  return ver >= 0x00010012;
45     case vcFEATURE_NAMESPACE    :  return ver >= 0x00010012;
46     case vcFEATURE_VWAIT        :  return ver >= 0x00010025;
47     case vcFEATURE_SCHED        :  return ver >= 0x00020000;  // todo
48     case vcFEATURE_VNET         :  return ver >= 0x00020001;
49     case vcFEATURE_PERSISTENT   :  return ver >= 0x00020002;
50     case vcFEATURE_VSTAT        :  return ver >= 0x00020103 && ver < 0x00020306;
51     case vcFEATURE_PPTAG        :  return conf & VC_VCI_PPTAG;
52     case vcFEATURE_SPACES       :  return conf & VC_VCI_SPACES;
53     case vcFEATURE_PIVOT_ROOT   :  return ver >= 0x00020304;
54     case vcFEATURE_PIDSPACE     :  return false;
55     case vcFEATURE_MEMCG        :  return ver >= 0x00020306 && conf & VC_VCI_MEMCG;
56     case vcFEATURE_DYNAMIC      :  return ver <  0x00020300 || !(conf & VC_VCI_NO_DYNAMIC);
57     case vcFEATURE_BME          :  return linux_ver < 0x0002061a;
58     default                     :  assert(false); 
59   }
60
61   return false;
62 }