From f4c4151b7eadb9ede5056cc2f0f62ea41d0e1cde Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Wed, 21 Jan 2004 18:47:18 +0000 Subject: [PATCH] initial checkin git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@666 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/lib/fscompat_getiattr-v13.hc | 28 +++++++++++++++ util-vserver/lib/fscompat_setiattr-v13.hc | 29 ++++++++++++++++ util-vserver/lib/syscall_gettaskxid-oldproc.hc | 47 +++++++++++++++++++++++++ util-vserver/lib/syscall_gettaskxid-v13.hc | 29 ++++++++++++++++ util-vserver/lib/syscall_gettaskxid.c | 44 +++++++++++++++++++++++ util-vserver/lib/syscall_getvxinfo-oldproc.hc | 29 ++++++++++++++++ util-vserver/lib/syscall_getvxinfo-v13.hc | 34 ++++++++++++++++++ util-vserver/lib/syscall_getvxinfo.c | 48 ++++++++++++++++++++++++++ 8 files changed, 288 insertions(+) create mode 100644 util-vserver/lib/fscompat_getiattr-v13.hc create mode 100644 util-vserver/lib/fscompat_setiattr-v13.hc create mode 100644 util-vserver/lib/syscall_gettaskxid-oldproc.hc create mode 100644 util-vserver/lib/syscall_gettaskxid-v13.hc create mode 100644 util-vserver/lib/syscall_gettaskxid.c create mode 100644 util-vserver/lib/syscall_getvxinfo-oldproc.hc create mode 100644 util-vserver/lib/syscall_getvxinfo-v13.hc create mode 100644 util-vserver/lib/syscall_getvxinfo.c diff --git a/util-vserver/lib/fscompat_getiattr-v13.hc b/util-vserver/lib/fscompat_getiattr-v13.hc new file mode 100644 index 0000000..613303a --- /dev/null +++ b/util-vserver/lib/fscompat_getiattr-v13.hc @@ -0,0 +1,28 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +inline static ALWAYSINLINE int +vc_get_iattr_compat_v13(char const UNUSED *filename, dev_t dev, ino_t ino, + xid_t *xid, uint32_t *flags, uint32_t *mask) +{ + return vc_get_iattr(dev, ino, xid, flags, mask); +} diff --git a/util-vserver/lib/fscompat_setiattr-v13.hc b/util-vserver/lib/fscompat_setiattr-v13.hc new file mode 100644 index 0000000..93fed93 --- /dev/null +++ b/util-vserver/lib/fscompat_setiattr-v13.hc @@ -0,0 +1,29 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +inline static ALWAYSINLINE int +vc_set_iattr_compat_v13(char const UNUSED *filename, + dev_t dev, ino_t ino, xid_t xid, + uint32_t flags, uint32_t mask) +{ + return vc_set_iattr(dev, ino, xid, flags, mask); +} diff --git a/util-vserver/lib/syscall_gettaskxid-oldproc.hc b/util-vserver/lib/syscall_gettaskxid-oldproc.hc new file mode 100644 index 0000000..442a892 --- /dev/null +++ b/util-vserver/lib/syscall_gettaskxid-oldproc.hc @@ -0,0 +1,47 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +#include "utils-legacy.h" + +static xid_t +getctx_legacy_internal(pid_t pid) +{ + size_t bufsize = utilvserver_getProcEntryBufsize(); + char buf[bufsize]; + char *pos = 0; + + pos = utilvserver_getProcEntry(pid, "\ns_context: ", buf, bufsize); + + if (pos!=0) return atoi(pos); + else return VC_NOCTX; +} + +static inline ALWAYSINLINE xid_t +vc_get_task_xid_X(pid_t pid) +{ + xid_t res; + do { + res = getctx_legacy_internal(pid); + } while (res==VC_NOCTX && errno==EAGAIN); + + return res; +} diff --git a/util-vserver/lib/syscall_gettaskxid-v13.hc b/util-vserver/lib/syscall_gettaskxid-v13.hc new file mode 100644 index 0000000..2741d71 --- /dev/null +++ b/util-vserver/lib/syscall_gettaskxid-v13.hc @@ -0,0 +1,29 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +static inline ALWAYSINLINE xid_t +vc_get_task_xid_v13(pid_t pid) +{ + xid_t res; + if (vserver(VC_CMD(VINFO, 1,0), pid, &res)==-1) return -1; + return CTX_KERNEL2USER(res); +} diff --git a/util-vserver/lib/syscall_gettaskxid.c b/util-vserver/lib/syscall_gettaskxid.c new file mode 100644 index 0000000..e7b152c --- /dev/null +++ b/util-vserver/lib/syscall_gettaskxid.c @@ -0,0 +1,44 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +#include "vserver.h" +#include "linuxvirtual.h" + +#if defined(VC_ENABLE_API_OLDPROC) && defined(VC_ENABLE_API_V13) +# define VC_MULTIVERSION_SYSCALL 1 +#endif +#include "vserver-internal.h" + +#ifdef VC_ENABLE_API_V13 +# include "syscall_gettaskxid-v13.hc" +#endif + +#ifdef VC_ENABLE_API_OLDPROC +# include "syscall_gettaskxid-oldproc.hc" +#endif + +xid_t +vc_get_task_xid(pid_t pid) +{ + CALL_VC(CALL_VC_V13 (vc_get_task_xid, pid), + CALL_VC_OLDPROC(vc_get_task_xid, pid)); +} diff --git a/util-vserver/lib/syscall_getvxinfo-oldproc.hc b/util-vserver/lib/syscall_getvxinfo-oldproc.hc new file mode 100644 index 0000000..13717ed --- /dev/null +++ b/util-vserver/lib/syscall_getvxinfo-oldproc.hc @@ -0,0 +1,29 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +static inline ALWAYSINLINE int +vc_get_vx_info_X(xid_t UNUSED xid, struct vc_vx_info UNUSED *info) +{ + // TODO: ??? + errno = EINVAL; + return -1; +} diff --git a/util-vserver/lib/syscall_getvxinfo-v13.hc b/util-vserver/lib/syscall_getvxinfo-v13.hc new file mode 100644 index 0000000..4813eb8 --- /dev/null +++ b/util-vserver/lib/syscall_getvxinfo-v13.hc @@ -0,0 +1,34 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +static inline ALWAYSINLINE int +vc_get_vx_info_v13(xid_t xid, struct vc_vx_info *info) +{ + struct vcmd_vx_info_v0 res; + int rc = vserver(VC_CMD(VINFO, 5,0), xid, &res); + if (rc==-1) return -1; + + info->xid = CTX_KERNEL2USER(res.xid); + info->initpid = res.initpid; + + return rc; +} diff --git a/util-vserver/lib/syscall_getvxinfo.c b/util-vserver/lib/syscall_getvxinfo.c new file mode 100644 index 0000000..e41da16 --- /dev/null +++ b/util-vserver/lib/syscall_getvxinfo.c @@ -0,0 +1,48 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2004 Enrico Scholz +// +// 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 +#endif + +#include "vserver.h" +#include "linuxvirtual.h" + +#if defined(VC_ENABLE_API_OLDPROC) && defined(VC_ENABLE_API_V13) +# define VC_MULTIVERSION_SYSCALL 1 +#endif +#include "vserver-internal.h" + +#ifdef VC_ENABLE_API_V13 +# include "syscall_getvxinfo-v13.hc" +#endif + +#ifdef VC_ENABLE_API_OLDPROC +# include "syscall_getvxinfo-oldproc.hc" +#endif + +int +vc_get_vx_info(xid_t xid, struct vc_vx_info *info) +{ + if (info==0) { + errno = EINVAL; + return -1; + } + CALL_VC(CALL_VC_V13 (vc_get_vx_info, xid, info), + CALL_VC_OLDPROC(vc_get_vx_info, xid, info)); +} -- 1.8.1.5