--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//
+// 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_sched_v13(xid_t xid, struct vc_set_sched const *data)
+{
+ struct vcmd_set_sched_v1 k_data;
+
+ k_data.fill_rate = data->fill_rate;
+ k_data.period = data->period;
+ k_data.fill_level = data->fill_level;
+ k_data.bucket_size = data->bucket_size;
+
+ return vserver(VCMD_set_sched, CTX_USER2KERNEL(xid), &k_data);
+}
--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//
+// 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 "linuxvirtual.h"
+
+#include "vserver-internal.h"
+
+#ifdef VC_ENABLE_API_V13
+# include "syscall_setsched-v13.hc"
+#endif
+
+int
+vc_set_sched(xid_t xid, struct vc_set_sched const *data)
+{
+ CALL_VC(CALL_VC_V13(vc_set_sched,xid,data));
+}
--- /dev/null
+// $Id$ --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//
+// 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 "util.h"
+#include "vserver.h"
+
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <libgen.h>
+
+#define ENSC_WRAPPERS_PREFIX "vschedule: "
+#define ENSC_WRAPPERS_VSERVER 1
+#define ENSC_WRAPPERS_UNISTD 1
+#include <wrappers.h>
+
+#define CMD_HELP 0x1000
+#define CMD_VERSION 0x1001
+#define CMD_XID 0x4000
+#define CMD_FRATE 0x4001
+#define CMD_PERIOD 0x4002
+#define CMD_FLEVEL 0x4003
+#define CMD_BSIZE 0x4004
+
+int wrapper_exit_code = 255;
+
+struct option const
+CMDLINE_OPTIONS[] = {
+ { "help", no_argument, 0, CMD_HELP },
+ { "version", no_argument, 0, CMD_VERSION },
+ { "ctx", required_argument, 0, CMD_XID },
+ { "fill-rate", required_argument, 0, CMD_FRATE },
+ { "period", required_argument, 0, CMD_PERIOD },
+ { "fill-level", required_argument, 0, CMD_FLEVEL },
+ { "bucket-size", required_argument, 0, CMD_BSIZE },
+ {0,0,0,0}
+};
+
+static void
+showHelp(int fd, char const *cmd, int res)
+{
+ VSERVER_DECLARE_CMD(cmd);
+
+ WRITE_MSG(fd, "Usage:\n ");
+ WRITE_STR(fd, cmd);
+ WRITE_MSG(fd,
+ " [--ctx <xid>] [--fill-rate <rate>] [--period <period>] [--fill-level <level>] [--bucket-size <size>] [--] [<command> <args>*]\n"
+ "\n"
+ "Please report bugs to " PACKAGE_BUGREPORT "\n");
+
+ exit(res);
+}
+
+static void
+showVersion()
+{
+ WRITE_MSG(1,
+ "vschedule " VERSION " -- modifies scheduling parameters\n"
+ "This program is part of " PACKAGE_STRING "\n\n"
+ "Copyright (C) 2003,2004 Enrico Scholz\n"
+ VERSION_COPYRIGHT_DISCLAIMER);
+ exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ xid_t xid = VC_NOCTX;
+ struct vc_set_sched sched = { 0,0,0,0 };
+
+ while (1) {
+ int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
+ if (c==-1) break;
+
+ switch (c) {
+ case CMD_HELP : showHelp(1, argv[0], 0);
+ case CMD_VERSION : showVersion();
+ case CMD_XID : xid = atoi(optarg); break;
+ case CMD_FRATE : sched.fill_rate = atoi(optarg); break;
+ case CMD_PERIOD : sched.period = atoi(optarg); break;
+ case CMD_FLEVEL : sched.fill_level = atoi(optarg); break;
+ case CMD_BSIZE : sched.bucket_size = atoi(optarg); break;
+ default :
+ WRITE_MSG(2, "Try '");
+ WRITE_STR(2, argv[0]);
+ WRITE_MSG(2, " --help\" for more information.\n");
+ return EXIT_FAILURE;
+ break;
+ }
+ }
+
+ if (xid==VC_NOCTX && optind==argc) {
+ WRITE_MSG(2, "Neither '--xid' nor a program was specified; try '--help' for more information\n");
+ exit(255);
+ }
+
+ if (xid==VC_NOCTX)
+ xid = Evc_get_task_xid(0);
+
+ if (vc_set_sched(xid, &sched)==-1) {
+ perror("vc_set_sched()");
+ exit(255);
+ }
+
+ EexecvpD(argv[optind],argv+optind);
+}