]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #1610 from evverx/man-tmpfiles-d
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Oct 2015 17:03:16 +0000 (19:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 19 Oct 2015 17:03:16 +0000 (19:03 +0200)
man: tmpfiles.d: add info about age field

shell-completion/bash/systemd-run
src/basic/util.c
src/basic/util.h
src/core/dbus-execute.c
src/shared/bus-util.c

index 518812e040958860a20c112c108365fbc14cbecc..ea59a42407f6cfed6b69b4859788b4dca0e7a014 100644 (file)
@@ -84,7 +84,7 @@ _systemd_run() {
                          LimitNICE= LimitRTPRIO= LimitRTTIME= PrivateTmp= PrivateDevices=
                          PrivateNetwork= NoNewPrivileges= WorkingDirectory= RootDirectory=
                          TTYPath= SyslogIdentifier= SyslogLevelPrefix= SyslogLevel=
-                         SyslogFacility= TimerSlackNSec='
+                         SyslogFacility= TimerSlackNSec= OOMScoreAdjust='
 
             COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
             return 0
index 8b896a2df35015ef33e6d74042924090ac263a7b..2565b0f5479746773787c1c9da548f6ad2820678 100644 (file)
@@ -29,6 +29,7 @@
 #include <libintl.h>
 #include <limits.h>
 #include <linux/magic.h>
+#include <linux/oom.h>
 #include <linux/sched.h>
 #include <locale.h>
 #include <netinet/ip.h>
@@ -6800,3 +6801,7 @@ bool fdname_is_valid(const char *s) {
 
         return p - s < 256;
 }
+
+bool oom_score_adjust_is_valid(int oa) {
+        return oa >= OOM_SCORE_ADJ_MIN && oa <= OOM_SCORE_ADJ_MAX;
+}
index 2544ad083016df8b1f2b59bc265357323f581d71..6c63bc221f2cc6e9d8de157dd2e018a5776091df 100644 (file)
@@ -941,3 +941,5 @@ void nop_signal_handler(int sig);
 int version(void);
 
 bool fdname_is_valid(const char *s);
+
+bool oom_score_adjust_is_valid(int oa);
index 436229330e54d795e55092fdc0b1ea64efca2b9b..2662b0752568eef2b1a67131922c3f9e5213011c 100644 (file)
@@ -1186,6 +1186,24 @@ int bus_exec_context_set_transient_property(
 
                 return 1;
 
+        } else if (streq(name, "OOMScoreAdjust")) {
+                int oa;
+
+                r = sd_bus_message_read(message, "i", &oa);
+                if (r < 0)
+                        return r;
+
+                if (!oom_score_adjust_is_valid(oa))
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "OOM score adjust value out of range");
+
+                if (mode != UNIT_CHECK) {
+                        c->oom_score_adjust = oa;
+                        c->oom_score_adjust_set = true;
+                        unit_write_drop_in_private_format(u, mode, name, "OOMScoreAdjust=%i\n", oa);
+                }
+
+                return 1;
+
         } else if (rlimit_from_string(name) >= 0) {
                 uint64_t rl;
                 rlim_t x;
index a5d6edbba94a38c502297c8a3f25a79f90f0a4d1..78d6b0eb27657745c63b2245b0055b47cf500fe1 100644 (file)
@@ -1665,6 +1665,21 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                 }
 
                 r = sd_bus_message_append(m, "v", "t", n);
+        } else if (streq(field, "OOMScoreAdjust")) {
+                int oa;
+
+                r = safe_atoi(eq, &oa);
+                if (r < 0) {
+                        log_error("Failed to parse %s value %s", field, eq);
+                        return -EINVAL;
+                }
+
+                if (!oom_score_adjust_is_valid(oa)) {
+                        log_error("OOM score adjust value out of range");
+                        return -EINVAL;
+                }
+
+                r = sd_bus_message_append(m, "v", "i", oa);
         } else {
                 log_error("Unknown assignment %s.", assignment);
                 return -EINVAL;