summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-05 02:29:58 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-05 02:31:09 +0100
commit517d56b1d0f67dcf76710bc1e17b05518b8cabe6 (patch)
tree1d1baa6af8fb323fc0c2eb02a1ae59dbeba2d049
parenta049d1a9723b6608e45bf8f1a64dab5761dee555 (diff)
missing: if RLIMIT_RTTIME is not defined by the libc, then we need a new define for the max number of rlimits, too
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/execute.h3
-rw-r--r--src/core/main.c2
-rw-r--r--src/core/manager.c4
-rw-r--r--src/core/manager.h2
-rw-r--r--src/core/unit.c2
-rw-r--r--src/shared/missing.h3
-rw-r--r--src/shared/util.c3
8 files changed, 13 insertions, 8 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index fec4b3b13a..ca807dc8cb 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1676,7 +1676,7 @@ int exec_spawn(ExecCommand *command,
if (apply_permissions) {
- for (i = 0; i < RLIMIT_NLIMITS; i++) {
+ for (i = 0; i < _RLIMIT_MAX; i++) {
if (!context->rlimit[i])
continue;
diff --git a/src/core/execute.h b/src/core/execute.h
index 2c5d8bbf76..a333657328 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -38,6 +38,7 @@ typedef struct ExecRuntime ExecRuntime;
#include "util.h"
#include "set.h"
#include "fdset.h"
+#include "missing.h"
typedef enum ExecInput {
EXEC_INPUT_NULL,
@@ -93,7 +94,7 @@ struct ExecContext {
char **environment;
char **environment_files;
- struct rlimit *rlimit[RLIMIT_NLIMITS];
+ struct rlimit *rlimit[_RLIMIT_MAX];
char *working_directory, *root_directory;
mode_t umask;
diff --git a/src/core/main.c b/src/core/main.c
index 4ca847c781..25ddafee47 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -105,7 +105,7 @@ static unsigned arg_default_start_limit_burst = DEFAULT_START_LIMIT_BURST;
static usec_t arg_runtime_watchdog = 0;
static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
static char **arg_default_environment = NULL;
-static struct rlimit *arg_default_rlimit[RLIMIT_NLIMITS] = {};
+static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {};
static uint64_t arg_capability_bounding_set_drop = 0;
static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
static Set* arg_syscall_archs = NULL;
diff --git a/src/core/manager.c b/src/core/manager.c
index 822c7ccfee..e4d03681ab 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -810,7 +810,7 @@ void manager_free(Manager *m) {
free(m->switch_root);
free(m->switch_root_init);
- for (i = 0; i < RLIMIT_NLIMITS; i++)
+ for (i = 0; i < _RLIMIT_MAX; i++)
free(m->rlimit[i]);
assert(hashmap_isempty(m->units_requiring_mounts_for));
@@ -2728,7 +2728,7 @@ int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit) {
assert(m);
- for (i = 0; i < RLIMIT_NLIMITS; i++) {
+ for (i = 0; i < _RLIMIT_MAX; i++) {
if (!default_rlimit[i])
continue;
diff --git a/src/core/manager.h b/src/core/manager.h
index 92985caefb..e014abd04f 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -228,7 +228,7 @@ struct Manager {
bool default_memory_accounting;
bool default_blockio_accounting;
- struct rlimit *rlimit[RLIMIT_NLIMITS];
+ struct rlimit *rlimit[_RLIMIT_MAX];
/* non-zero if we are reloading or reexecuting, */
int n_reloading;
diff --git a/src/core/unit.c b/src/core/unit.c
index d0e915909a..2437ee3f66 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2803,7 +2803,7 @@ int unit_exec_context_patch_defaults(Unit *u, ExecContext *c) {
* _after_ the rest of the settings have been initialized */
/* This only copies in the ones that need memory */
- for (i = 0; i < RLIMIT_NLIMITS; i++)
+ for (i = 0; i < _RLIMIT_MAX; i++)
if (u->manager->rlimit[i] && !c->rlimit[i]) {
c->rlimit[i] = newdup(struct rlimit, u->manager->rlimit[i], 1);
if (!c->rlimit[i])
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 06c69dac8e..4e63fb9ac4 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -47,6 +47,9 @@
#define RLIMIT_RTTIME 15
#endif
+/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
+#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
+
#ifndef F_LINUX_SPECIFIC_BASE
#define F_LINUX_SPECIFIC_BASE 1024
#endif
diff --git a/src/shared/util.c b/src/shared/util.c
index 10daff3036..8c7cfbd6df 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -83,6 +83,7 @@
#include "gunicode.h"
#include "virt.h"
#include "def.h"
+#include "missing.h"
int saved_argc = 0;
char **saved_argv = NULL;
@@ -4713,7 +4714,7 @@ static const char* const sched_policy_table[] = {
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int, INT_MAX);
-static const char* const rlimit_table[] = {
+static const char* const rlimit_table[_RLIMIT_MAX] = {
[RLIMIT_CPU] = "LimitCPU",
[RLIMIT_FSIZE] = "LimitFSIZE",
[RLIMIT_DATA] = "LimitDATA",