// $Id$ --*- c -*--
// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+// 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
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
+#include <stddef.h>
#define ENSC_WRAPPERS_PREFIX "vsched: "
#define ENSC_WRAPPERS_VSERVER 1
};
#define FOPT(NAME,MASK,FIELD) { #NAME, MASK, offsetof(struct vc_set_sched, FIELD) }
static struct sched_opt FILE_OPTIONS[] = {
- FOPT(fill-rate, VC_VXSM_FILL_RATE, fill_rate),
- FOPT(interval, VC_VXSM_INTERVAL, interval),
- FOPT(tokens, VC_VXSM_TOKENS, tokens),
- FOPT(tokens-min, VC_VXSM_TOKENS_MIN, tokens_min),
- FOPT(tokens-max, VC_VXSM_TOKENS_MAX, tokens_max),
- FOPT(prio-bias, VC_VXSM_PRIO_BIAS, priority_bias),
- FOPT(priority-bias, VC_VXSM_PRIO_BIAS, priority_bias),
+ FOPT(fill-rate, VC_VXSM_FILL_RATE, fill_rate),
+ FOPT(interval, VC_VXSM_INTERVAL, interval),
+ FOPT(tokens, VC_VXSM_TOKENS, tokens),
+ FOPT(tokens-min, VC_VXSM_TOKENS_MIN, tokens_min),
+ FOPT(tokens-max, VC_VXSM_TOKENS_MAX, tokens_max),
+ FOPT(prio-bias, VC_VXSM_PRIO_BIAS, priority_bias),
+ FOPT(priority-bias, VC_VXSM_PRIO_BIAS, priority_bias),
FOPT(fill-rate2, VC_VXSM_FILL_RATE2|VC_VXSM_IDLE_TIME, fill_rate2),
FOPT(interval2, VC_VXSM_INTERVAL2|VC_VXSM_IDLE_TIME, interval2),
FOPT(cpu-id, VC_VXSM_CPU_ID, cpu_id),
WRITE_MSG(fd, "Usage:\n ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
- " [--xid <xid>] [--fill-rate <rate>] [--interval <interval>] [--tokens <tokens>] [--tokens-min <tokens>] [--tokens-max <tokens>] [--prio-bias <bias>] [--] [<command> <args>*]\n"
+ " [--xid <xid>] <sched options>* [--dir <dir>] [--] [<command> <args>*]\n"
"\n"
- "Please report bugs to " PACKAGE_BUGREPORT "\n");
+ "Options:\n"
+ " --fill-rate <rate>\n"
+ " --interval <interval>\n"
+ " --tokens <tokens>\n"
+ " --tokens-min <tokens>\n"
+ " --tokens-max <tokens>\n"
+ " --prio-bias <bias>\n"
+ " --fill-rate2 <rate>\n"
+ " --interval2 <interval>\n"
+ " --cpu-id <CPU id>\n"
+ " --bucket-id <bucket id>\n"
+ " --idle-time ... set the idle time flag; this is required for\n"
+ " all updates to the scheduler to keep it enabled\n"
+ " --force ... force update of all per-CPU schedulers now\n"
+ " --dir <dir> ... read settings from <dir>\n"
+ " --missingok ... do not fail when <dir> does not exist\n"
+ "\nPlease report bugs to " PACKAGE_BUGREPORT "\n");
exit(res);
}
"vsched " VERSION " -- modifies scheduling parameters\n"
"This program is part of " PACKAGE_STRING "\n\n"
"Copyright (C) 2003,2004 Enrico Scholz\n"
+ "Copyright (C) 2006 Daniel Hokka Zakrisson\n"
VERSION_COPYRIGHT_DISCLAIMER);
exit(0);
}
static void do_dir_entry(struct vc_set_sched *sched, const char *name)
{
- int fd;
- char buf[128];
- signed long val;
struct sched_opt *opt;
- ssize_t len;
- char *newline;
for (opt = FILE_OPTIONS; opt->name != 0; opt++) {
if (strcmp(name, opt->name) == 0)
break;
}
+ if (opt->name == 0)
+ return;
+
+ if (opt->offset != offsetof(struct vc_set_sched, set_mask)) {
+ int fd;
+ char buf[128], *newline;
+ signed long val;
+ ssize_t len;
+
+ fd = Eopen(name, O_RDONLY, 0);
+ len = Eread(fd, buf, sizeof(buf)-1);
+ Eclose(fd);
+ buf[len] = '\0';
+ if ((newline=strchr(buf, '\n')) != NULL)
+ *newline = '\0';
+
+ if (!isNumber(buf, &val, true)) {
+ WRITE_MSG(2, ENSC_WRAPPERS_PREFIX);
+ WRITE_STR(2, name);
+ WRITE_MSG(2, ": is not an integer\n");
+ exit(1);
+ }
- fd = Eopen(name, O_RDONLY, 0);
- len = Eread(fd, buf, sizeof(buf)-1);
- Eclose(fd);
- buf[len] = '\0';
- if ((newline=strchr(buf, '\n')) != NULL)
- *newline = '\0';
-
- if (!isNumber(buf, &val, true)) {
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX);
- WRITE_STR(2, name);
- WRITE_MSG(2, ": is not a number\n");
- exit(1);
- }
-
- if (opt->offset != offsetof(struct vc_set_sched, set_mask))
*(int_least32_t *)(((char *)sched)+opt->offset) = (int_least32_t) val;
+ }
sched->set_mask |= opt->mask;
}
#define SETVAL(ATTR,MASK) \
if (!isNumber(optarg, &tmp, false)) { \
- WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "non-numeric value specified for '--" #ATTR "'\n"); \
+ WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "non-integer value specified for '--" #ATTR "'\n"); \
exit(wrapper_exit_code); \
} \
else { \
do_dir(xid, &sched, dir, missing_ok, 0);
}
else {
- if (sched.set_mask!=0 && vc_set_sched(xid, &sched)==-1) {
+ if (sched.set_mask!=0 && sched.set_mask!=VC_VXSM_FORCE &&
+ vc_set_sched(xid, &sched)==-1) {
perror("vc_set_sched()");
exit(255);
}