Add the new syscalls from 2.1.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Wed, 15 Nov 2006 20:14:00 +0000 (20:14 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Wed, 15 Nov 2006 20:14:00 +0000 (20:14 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2380 94cd875c-1c1d-0410-91d2-eb244daf1a30

12 files changed:
lib/Makefile-files
lib/syscall_ctxstat-v21.hc [new file with mode: 0644]
lib/syscall_ctxstat.c [new file with mode: 0644]
lib/syscall_getvci-v21.hc [new file with mode: 0644]
lib/syscall_getvci.c [new file with mode: 0644]
lib/syscall_resetminmax-v21.hc [new file with mode: 0644]
lib/syscall_resetminmax.c [new file with mode: 0644]
lib/syscall_rlimitstat-v21.hc [new file with mode: 0644]
lib/syscall_rlimitstat.c [new file with mode: 0644]
lib/syscall_virtstat-v21.hc [new file with mode: 0644]
lib/syscall_virtstat.c [new file with mode: 0644]
lib/vserver.h

index 9574671..736d7f1 100644 (file)
@@ -110,7 +110,17 @@ lib_v13_SRCS =                     lib/syscall_ctxcreate.c \
                                lib/nflags-net.c \
                                lib/nflags_list-net.c
 lib_v21_SRCS =                 lib/syscall_setccaps-v21.hc \
-                               lib/syscall_setsched-v21.hc
+                               lib/syscall_setsched-v21.hc \
+                               lib/syscall_rlimitstat.c \
+                               lib/syscall_rlimitstat-v21.hc \
+                               lib/syscall_resetminmax.c \
+                               lib/syscall_resetminmax-v21.hc \
+                               lib/syscall_getvci.c \
+                               lib/syscall_getvci-v21.hc \
+                               lib/syscall_virtstat.c \
+                               lib/syscall_virtstat-v21.hc \
+                               lib/syscall_ctxstat.c \
+                               lib/syscall_ctxstat-v21.hc
 
 if ENSC_HAVE_C99_COMPILER
 lib_v13_SRCS +=                        lib/syscall_adddlimit-v13.hc \
diff --git a/lib/syscall_ctxstat-v21.hc b/lib/syscall_ctxstat-v21.hc
new file mode 100644 (file)
index 0000000..1bdd6d6
--- /dev/null
@@ -0,0 +1,36 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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
+
+static inline ALWAYSINLINE int
+vc_ctx_stat_v21(xid_t ctx, struct vc_ctx_stat *stat)
+{
+  int ret;
+  struct vcmd_ctx_stat_v0 param;
+
+  ret = vserver(VCMD_ctx_stat, CTX_USER2KERNEL(ctx), &param);
+  if (ret)
+    return ret;
+
+  stat->usecnt = param.usecnt;
+  stat->tasks  = param.tasks;
+  return 0;
+}
diff --git a/lib/syscall_ctxstat.c b/lib/syscall_ctxstat.c
new file mode 100644 (file)
index 0000000..ace29cd
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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"
+#include "vserver-internal.h"
+#include "virtual.h"
+
+#if defined(VC_ENABLE_API_V21)
+#  include "syscall_ctxstat-v21.hc"
+#endif
+
+#if defined(VC_ENABLE_API_V21)
+
+int
+vc_ctx_stat(xid_t ctx, struct vc_ctx_stat *stat)
+{
+  CALL_VC(CALL_VC_V21(vc_ctx_stat, ctx, stat));
+}
+
+#endif
diff --git a/lib/syscall_getvci-v21.hc b/lib/syscall_getvci-v21.hc
new file mode 100644 (file)
index 0000000..ac96358
--- /dev/null
@@ -0,0 +1,27 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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
+
+static inline ALWAYSINLINE int
+vc_get_vci_v21()
+{
+  return vserver(VCMD_get_vci, 0, 0);
+}
diff --git a/lib/syscall_getvci.c b/lib/syscall_getvci.c
new file mode 100644 (file)
index 0000000..94dbc96
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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"
+#include "vserver-internal.h"
+#include "virtual.h"
+
+#if defined(VC_ENABLE_API_V21)
+#  include "syscall_getvci-v21.hc"
+#endif
+
+#if defined(VC_ENABLE_API_V21)
+
+int
+vc_get_vci()
+{
+  CALL_VC(CALL_VC_V21(vc_get_vci));
+}
+
+#endif
diff --git a/lib/syscall_resetminmax-v21.hc b/lib/syscall_resetminmax-v21.hc
new file mode 100644 (file)
index 0000000..d184cd8
--- /dev/null
@@ -0,0 +1,27 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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
+
+static inline ALWAYSINLINE int
+vc_reset_minmax_v21(xid_t ctx)
+{
+  return vserver(VCMD_reset_minmax, CTX_USER2KERNEL(ctx), 0);
+}
diff --git a/lib/syscall_resetminmax.c b/lib/syscall_resetminmax.c
new file mode 100644 (file)
index 0000000..ed9f477
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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"
+#include "vserver-internal.h"
+#include "virtual.h"
+
+#if defined(VC_ENABLE_API_V21)
+#  include "syscall_resetminmax-v21.hc"
+#endif
+
+#if defined(VC_ENABLE_API_V21)
+
+int
+vc_reset_minmax(xid_t ctx)
+{
+  CALL_VC(CALL_VC_V21(vc_reset_minmax, ctx));
+}
+
+#endif
diff --git a/lib/syscall_rlimitstat-v21.hc b/lib/syscall_rlimitstat-v21.hc
new file mode 100644 (file)
index 0000000..cc879c7
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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
+
+static inline ALWAYSINLINE int
+vc_rlimit_stat_v21(xid_t ctx, int resource, struct vc_rlimit_stat *stat)
+{
+  struct vcmd_rlimit_stat_v0   param = { .id = resource };
+  int ret;
+
+  ret = vserver(VCMD_rlimit_stat, CTX_USER2KERNEL(ctx), &param);
+  if (ret)
+    return ret;
+
+  stat->hits   = param.hits;
+  stat->value  = param.value;
+  stat->minimum        = param.minimum;
+  stat->maximum        = param.maximum;
+
+  return 0;
+}
diff --git a/lib/syscall_rlimitstat.c b/lib/syscall_rlimitstat.c
new file mode 100644 (file)
index 0000000..00a38ad
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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"
+#include "vserver-internal.h"
+#include "virtual.h"
+
+#if defined(VC_ENABLE_API_V21)
+#  include "syscall_rlimitstat-v21.hc"
+#endif
+
+#if defined(VC_ENABLE_API_V21)
+
+int
+vc_rlimit_stat(xid_t ctx, int resource, struct vc_rlimit_stat *stat)
+{
+  CALL_VC(CALL_VC_V21(vc_rlimit_stat, ctx, resource, stat));
+}
+
+#endif
diff --git a/lib/syscall_virtstat-v21.hc b/lib/syscall_virtstat-v21.hc
new file mode 100644 (file)
index 0000000..59686e8
--- /dev/null
@@ -0,0 +1,45 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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
+
+static inline ALWAYSINLINE int
+vc_virt_stat_v21(xid_t ctx, struct vc_virt_stat *stat)
+{
+  int ret;
+  struct vcmd_virt_stat_v0 param;
+
+  ret = vserver(VCMD_virt_stat, CTX_USER2KERNEL(ctx), &param);
+  if (ret)
+    return ret;
+
+#define G(ATTR)        stat->ATTR = param.ATTR
+  G(offset);
+  G(uptime);
+  G(nr_threads);
+  G(nr_running);
+  G(nr_uninterruptible);
+  G(nr_onhold);
+  G(nr_forks);
+  G(load[0]);
+  G(load[1]);
+  G(load[2]);
+  return 0;
+}
diff --git a/lib/syscall_virtstat.c b/lib/syscall_virtstat.c
new file mode 100644 (file)
index 0000000..8100a33
--- /dev/null
@@ -0,0 +1,39 @@
+// $Id$    --*- c++ -*--
+
+// Copyright (C) 2006 Daniel Hokka Zakrisson <daniel@hozac.com>
+//  
+// 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"
+#include "vserver-internal.h"
+#include "virtual.h"
+
+#if defined(VC_ENABLE_API_V21)
+#  include "syscall_virtstat-v21.hc"
+#endif
+
+#if defined(VC_ENABLE_API_V21)
+
+int
+vc_virt_stat(xid_t ctx, struct vc_virt_stat *stat)
+{
+  CALL_VC(CALL_VC_V21(vc_virt_stat, ctx, stat));
+}
+
+#endif
index bc5eb2a..41479fb 100644 (file)
@@ -294,6 +294,12 @@ extern "C" {
      * \returns The versionnumber of the kernel API
      */
   int  vc_get_version();
+
+    /** \brief   Returns the kernel configuration bits
+     *  \ingroup syscalls
+     *  \returns The kernel configuration bits
+     */
+  int   vc_get_vci();
   
     /** \brief   Moves current process into a context
      *  \ingroup syscalls
@@ -347,6 +353,42 @@ extern "C" {
      *  \param   xid  The new context
      *  \returns 0 on success, -1 on errors */
   int  vc_ctx_migrate(xid_t xid);
+
+    /** \brief   Statistics about a context */
+  struct vc_ctx_stat {
+      uint_least32_t   usecnt; ///< number of uses
+      uint_least32_t   tasks;  ///< number of tasks
+  };
+
+    /** \brief   Get some statistics about a context.
+     *  \ingroup syscalls
+     *
+     *  \param   xid   The context to get stats about
+     *  \param   stat  Where to store the result
+     *
+     *  \returns 0 on success, -1 on errors. */
+  int   vc_ctx_stat(xid_t xid, struct vc_ctx_stat /*@out@*/ *stat) VC_ATTR_NONNULL((2));
+
+    /** \brief   Contains further statistics about a context. */
+  struct vc_virt_stat {
+      uint_least64_t   offset;
+      uint_least32_t   uptime;
+      uint_least32_t   nr_threads;
+      uint_least32_t   nr_running;
+      uint_least32_t   nr_uninterruptible;
+      uint_least32_t   nr_onhold;
+      uint_least32_t   nr_forks;
+      uint_least32_t   load[3];
+  };
+
+    /** \brief   Get more statistics about a context.
+     *  \ingroup syscalls
+     *
+     *  \param xid   The context to get stats about
+     *  \param stat  Where to store the result
+     *
+     *  \returns 0 on success, -1 on errors. */
+  int   vc_virt_stat(xid_t xid, struct vc_virt_stat /*@out@*/ *stat) VC_ATTR_NONNULL((2));
   
     /* rlimit related functions */
   
@@ -377,6 +419,14 @@ extern "C" {
       uint_least32_t   hard;   ///< masks the resources supporting a hard limit
   };
 
+    /** \brief Statistics for a resource limit. */
+  struct  vc_rlimit_stat {
+      uint_least32_t   hits;    ///< number of hits on the limit
+      uint_least64_t   value;   ///< current value
+      uint_least64_t   minimum; ///< minimum value observed
+      uint_least64_t   maximum; ///< maximum value observed
+  };
+
     /** \brief   Returns the limits of \a resource.
      *  \ingroup syscalls
      *
@@ -399,6 +449,23 @@ extern "C" {
                      struct vc_rlimit const /*@in@*/  *lim) VC_ATTR_NONNULL((3));
   int  vc_get_rlimit_mask(xid_t xid,
                           struct vc_rlimit_mask *lim)       VC_ATTR_NONNULL((2));
+    /** \brief   Returns the current stats of \a resource.
+     *  \ingroup syscalls
+     *
+     *  \param  xid       The id of the context
+     *  \param  resource  The resource which will be queried
+     *  \param  stat      The result which will be filled with the stats
+     *
+     *  \returns 0 on success, and -1 on errors. */
+  int   vc_rlimit_stat(xid_t xid, int resource,
+                      struct vc_rlimit_stat /*@out@*/ *stat) VC_ATTR_NONNULL((3));
+    /** \brief   Resets the minimum and maximum observed values for all resources.
+     *  \ingroup syscalls
+     *
+     *  \param xid  The id of the context
+     *
+     *  \returns 0 on success, and -1 on errors. */
+  int   vc_reset_minmax(xid_t xid);
     /** \brief   Parses a string describing a limit
      *  \ingroup helper
      *