}
inline static WRAPPER_DECL void
-Evc_set_namespace(xid_t xid, uint_least64_t mask)
+Evc_set_namespace(xid_t xid, uint_least64_t mask, uint32_t index)
{
- FatalErrnoError(vc_set_namespace(xid, mask)==-1, "vc_set_namespace()");
+ FatalErrnoError(vc_set_namespace(xid, mask, index)==-1, "vc_set_namespace()");
}
inline static WRAPPER_DECL void
-Evc_enter_namespace(xid_t xid, uint_least64_t mask)
+Evc_enter_namespace(xid_t xid, uint_least64_t mask, uint32_t index)
{
- FatalErrnoError(vc_enter_namespace(xid, mask)==-1, "vc_enter_namespace()");
+ FatalErrnoError(vc_enter_namespace(xid, mask, index)==-1, "vc_enter_namespace()");
}
inline static WRAPPER_DECL xid_t
#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
-#define VCMD_enter_space VC_CMD(PROCALT, 1, 1)
+#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
+#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
/* XXX: This is not available in recent kernels */
#define VCMD_cleanup_namespace VC_CMD(PROCALT, 2, 0)
#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
-#define VCMD_set_space VC_CMD(PROCALT, 3, 1)
+#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
+#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
#define VCMD_get_space_mask VC_CMD(PROCALT, 4, 0)
#define VCMD_get_space_default VC_CMD(PROCALT, 7, 0)
-struct vcmd_space_mask {
+struct vcmd_space_mask_v1 {
uint64_t mask;
};
+struct vcmd_space_mask_v2 {
+ uint64_t mask;
+ uint32_t index;
+};
+
#endif /* _VX_SPACE_CMD_H */
lib/syscall_setbadness.c \
lib/syscall_setbadness-v23.hc \
lib/syscall_getspacedefault.c \
- lib/syscall_getspacedefault-v23.hc
+ lib/syscall_getspacedefault-v23.hc \
+ lib/syscall_setnamespace-v23.hc \
+ lib/syscall_enternamespace-v23.hc
if ENSC_HAVE_C99_COMPILER
lib_v13_SRCS += lib/syscall_adddlimit-v13.hc \
#include "vserver.h"
static inline ALWAYSINLINE int
-vc_enter_namespace_v13(xid_t xid, uint_least64_t mask)
+vc_enter_namespace_v13(xid_t xid, uint_least64_t mask, uint32_t index)
{
if ((mask & (CLONE_NEWNS|CLONE_FS)) == 0)
return 0;
+ if (index != 0) {
+ errno = EINVAL;
+ return -1;
+ }
return vserver(VCMD_enter_space_v0, CTX_USER2KERNEL(xid), 0);
}
#include "vserver.h"
static inline ALWAYSINLINE int
-vc_enter_namespace_spaces(xid_t xid, uint_least64_t mask)
+vc_enter_namespace_spaces(xid_t xid, uint_least64_t mask, uint32_t index)
{
- struct vcmd_space_mask data = { .mask = mask };
- return vserver(VCMD_enter_space, CTX_USER2KERNEL(xid), &data);
+ struct vcmd_space_mask_v1 data = { .mask = mask };
+ if (index != 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ return vserver(VCMD_enter_space_v1, CTX_USER2KERNEL(xid), &data);
}
--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+// Copyright (C) 2006 Daniel Hokka Zakrisson
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "vserver.h"
+
+static inline ALWAYSINLINE int
+vc_enter_namespace_v23(xid_t xid, uint_least64_t mask, uint32_t index)
+{
+ struct vcmd_space_mask_v2 data = { .mask = mask, .index = index };
+ return vserver(VCMD_enter_space, CTX_USER2KERNEL(xid), &data);
+}
#include "vserver.h"
#include "virtual.h"
-#if defined(VC_ENABLE_API_V13) && defined(VC_ENABLE_API_V21)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
+#define VC_MULTIVERSION_SYSCALL 1
#include "vserver-internal.h"
#ifdef VC_ENABLE_API_V13
# include "syscall_enternamespace-v21.hc"
#endif
+#ifdef VC_ENABLE_API_V23
+# include "syscall_enternamespace-v23.hc"
+#endif
+
#if defined(VC_ENABLE_API_V13) || defined(VC_ENABLE_API_V21)
int
-vc_enter_namespace(xid_t xid, uint_least64_t mask)
+vc_enter_namespace(xid_t xid, uint_least64_t mask, uint32_t index)
{
- CALL_VC(CALL_VC_SPACES(vc_enter_namespace, xid, mask),
- CALL_VC_V13 (vc_enter_namespace, xid, mask));
+ CALL_VC(CALL_VC_V23P (vc_enter_namespace, xid, mask, index),
+ CALL_VC_SPACES(vc_enter_namespace, xid, mask, index),
+ CALL_VC_V13 (vc_enter_namespace, xid, mask, index));
}
#endif
static inline ALWAYSINLINE uint_least64_t
vc_get_space_default_v23(int UNUSED tmp)
{
- struct vcmd_space_mask data = { .mask = 0 };
+ struct vcmd_space_mask_v1 data = { .mask = 0 };
int ret = vserver(VCMD_get_space_default, 0, &data);
if (ret)
return ret;
static inline ALWAYSINLINE uint_least64_t
vc_get_space_mask_spaces(int UNUSED tmp)
{
- struct vcmd_space_mask data = { .mask = 0 };
+ struct vcmd_space_mask_v1 data = { .mask = 0 };
int ret = vserver(VCMD_get_space_mask, 0, &data);
if (ret)
return ret;
#include "vserver.h"
static inline ALWAYSINLINE int
-vc_set_namespace_v13(xid_t xid, uint_least64_t mask)
+vc_set_namespace_v13(xid_t xid, uint_least64_t mask, uint32_t index)
{
if ((mask & (CLONE_NEWNS|CLONE_FS)) == 0)
return 0;
+ if (index != 0) {
+ errno = EINVAL;
+ return -1;
+ }
return vserver(VCMD_set_space_v0, CTX_USER2KERNEL(xid), 0);
}
#include "vserver.h"
static inline ALWAYSINLINE int
-vc_set_namespace_spaces(xid_t xid, uint_least64_t mask)
+vc_set_namespace_spaces(xid_t xid, uint_least64_t mask, uint32_t index)
{
- struct vcmd_space_mask data = { .mask = mask };
- return vserver(VCMD_set_space, CTX_USER2KERNEL(xid), &data);
+ struct vcmd_space_mask_v1 data = { .mask = mask };
+ if (index != 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ return vserver(VCMD_set_space_v1, CTX_USER2KERNEL(xid), &data);
}
--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+// Copyright (C) 2006 Daniel Hokka Zakrisson
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "vserver.h"
+
+static inline ALWAYSINLINE int
+vc_set_namespace_v23(xid_t xid, uint_least64_t mask, uint32_t index)
+{
+ struct vcmd_space_mask_v2 data = { .mask = mask, .index = index };
+ return vserver(VCMD_set_space, CTX_USER2KERNEL(xid), &data);
+}
#include "vserver.h"
#include "virtual.h"
-#if defined(VC_ENABLE_API_V13) && defined(VC_ENABLE_API_V21)
-# define VC_MULTIVERSION_SYSCALL 1
-#endif
+#define VC_MULTIVERSION_SYSCALL 1
#include "vserver-internal.h"
#ifdef VC_ENABLE_API_V13
# include "syscall_setnamespace-v21.hc"
#endif
-#if defined(VC_ENABLE_API_V13) || defined(VC_ENABLE_API_V21)
+#ifdef VC_ENABLE_API_V23
+# include "syscall_setnamespace-v23.hc"
+#endif
+
+#if defined(VC_ENABLE_API_V13) || defined(VC_ENABLE_API_V21) || defined(VC_ENABLE_API_V23)
int
-vc_set_namespace(xid_t xid, uint_least64_t mask)
+vc_set_namespace(xid_t xid, uint_least64_t mask, uint32_t index)
{
- CALL_VC(CALL_VC_SPACES(vc_set_namespace, xid, mask),
- CALL_VC_V13 (vc_set_namespace, xid, mask));
+ CALL_VC(CALL_VC_V23P (vc_set_namespace, xid, mask, index),
+ CALL_VC_SPACES(vc_set_namespace, xid, mask, index),
+ CALL_VC_V13 (vc_set_namespace, xid, mask, index));
}
#endif
char *val, size_t len) VC_ATTR_NONNULL((3));
/* namespace related functions */
- int vc_enter_namespace(xid_t xid, uint_least64_t mask);
- int vc_set_namespace(xid_t xid, uint_least64_t mask);
+ int vc_enter_namespace(xid_t xid, uint_least64_t mask, uint32_t index);
+ int vc_set_namespace(xid_t xid, uint_least64_t mask, uint32_t index);
int vc_cleanup_namespace(void);
uint_least64_t vc_get_space_mask(void);
uint_least64_t vc_get_space_default(void);
{
xid_t xid;
uint_least64_t mask;
+ uint32_t index;
- if (!PyArg_ParseTuple(args, "IK", &xid, &mask))
+ if (!PyArg_ParseTuple(args, "IKI", &xid, &mask, &index))
return NULL;
- if (vc_enter_namespace(xid, mask) == -1)
+ if (vc_enter_namespace(xid, mask, index) == -1)
return PyErr_SetFromErrno(PyExc_OSError);
return NONE();
{
xid_t xid;
uint_least64_t mask;
+ uint32_t index;
- if (!PyArg_ParseTuple(args, "IK", &xid, &mask))
+ if (!PyArg_ParseTuple(args, "IKI", &xid, &mask, &index))
return NULL;
- if (vc_set_namespace(xid, mask) == -1)
+ if (vc_set_namespace(xid, mask, index) == -1)
return PyErr_SetFromErrno(PyExc_OSError);
return NONE();
if (args->do_chroot) {
Echroot(".");
if (args->set_namespace) {
- if (args->do_migrateself) Evc_set_namespace(xid, CLONE_NEWNS|CLONE_FS);
- else if (args->do_migrate) Evc_enter_namespace(xid, CLONE_NEWNS|CLONE_FS);
+ if (args->do_migrateself) Evc_set_namespace(xid, CLONE_NEWNS|CLONE_FS, 0);
+ else if (args->do_migrate) Evc_enter_namespace(xid, CLONE_NEWNS|CLONE_FS, 0);
}
}
{ "new", no_argument, 0, 'n' },
{ "enter", required_argument, 0, 'e' },
{ "set", no_argument, 0, 's' },
+ { "index", required_argument, 0, 'i' },
{ "mask", required_argument, 0, 'm' },
{ "default", no_argument, 0, 'd' },
{ "~default", no_argument, 0, 'd' | 0x10000 },
}
static void
-enterSpaces(xid_t xid, uint_least64_t mask)
+enterSpaces(xid_t xid, uint_least64_t mask, uint32_t index)
{
- if (vc_enter_namespace(xid, mask)==-1) {
+ if (vc_enter_namespace(xid, mask, index)==-1) {
perror(ENSC_WRAPPERS_PREFIX "vc_enter_namespace()");
exit(wrapper_exit_code);
}
}
static void
-setSpaces(xid_t xid, uint_least64_t mask)
+setSpaces(xid_t xid, uint_least64_t mask, uint32_t index)
{
- if (vc_set_namespace(xid, mask)==-1) {
+ if (vc_set_namespace(xid, mask, index)==-1) {
perror(ENSC_WRAPPERS_PREFIX "vc_set_namespace()");
exit(wrapper_exit_code);
}
bool do_enter = false;
bool do_set = false;
uint_least64_t mask = 0;
+ uint32_t index = 0;
xid_t xid = VC_NOCTX;
int sum = 0;
do_enter = true;
xid = Evc_xidopt2xid(optarg,true);
break;
+ case 'i' : {
+ unsigned long index_l;
+ if (!isNumberUnsigned(optarg, &index_l, true)) {
+ WRITE_MSG(2, "Invalid index '");
+ WRITE_STR(2, optarg);
+ WRITE_MSG(2, "'; try '--help' for more information\n");
+ return wrapper_exit_code;
+ }
+ index = (uint32_t)index_l;
+ break;
+ }
case 'm' : {
unsigned long mask_l;
if (!isNumberUnsigned(optarg, &mask_l, true)) {
WRITE_MSG(2, "No command specified; try '--help' for more information\n");
else {
if (do_new) newSpaces(mask);
- else if (do_set) setSpaces(VC_SAMECTX, mask);
- else if (do_enter) enterSpaces(xid, mask);
+ else if (do_set) setSpaces(VC_SAMECTX, mask, index);
+ else if (do_enter) enterSpaces(xid, mask, index);
if (optind<argc)
EexecvpD(argv[optind], argv+optind);