summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-08-30 21:00:52 +0200
committerLennart Poettering <lennart@poettering.net>2016-10-07 20:14:38 +0200
commitd473176a74891256b95a4a5c89f1c0b9e1440945 (patch)
treef7556daf4e2c6d7767b2cb7df4eb082fdad156f0
parent766c94ad6b6d6101520a02aa2906ca7a446f4863 (diff)
journal: complete slice info in journal metadata
We are already attaching the system slice information to log messages, now add theuser slice info too, as well as the object slice info.
-rw-r--r--src/journal/journald-server.c20
-rw-r--r--src/journal/journald-server.h4
2 files changed, 21 insertions, 3 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index a762558e3d..79a93df26a 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -713,7 +713,7 @@ static void dispatch_message_real(
assert(s);
assert(iovec);
assert(n > 0);
- assert(n + N_IOVEC_META_FIELDS + (object_pid ? N_IOVEC_OBJECT_FIELDS : 0) <= m);
+ assert(n + N_IOVEC_META_FIELDS + (object_pid > 0 ? N_IOVEC_OBJECT_FIELDS : 0) <= m);
if (ucred) {
realuid = ucred->uid;
@@ -814,6 +814,12 @@ static void dispatch_message_real(
IOVEC_SET_STRING(iovec[n++], x);
}
+ if (cg_path_get_user_slice(c, &t) >= 0) {
+ x = strjoina("_SYSTEMD_USER_SLICE=", t);
+ free(t);
+ IOVEC_SET_STRING(iovec[n++], x);
+ }
+
free(c);
} else if (unit_id) {
x = strjoina("_SYSTEMD_UNIT=", unit_id);
@@ -919,6 +925,18 @@ static void dispatch_message_real(
IOVEC_SET_STRING(iovec[n++], x);
}
+ if (cg_path_get_slice(c, &t) >= 0) {
+ x = strjoina("OBJECT_SYSTEMD_SLICE=", t);
+ free(t);
+ IOVEC_SET_STRING(iovec[n++], x);
+ }
+
+ if (cg_path_get_user_slice(c, &t) >= 0) {
+ x = strjoina("OBJECT_SYSTEMD_USER_SLICE=", t);
+ free(t);
+ IOVEC_SET_STRING(iovec[n++], x);
+ }
+
free(c);
}
}
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index d2a32ab422..784d24833d 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -153,10 +153,10 @@ struct Server {
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + strlen("_MACHINE_ID="))
-#define N_IOVEC_META_FIELDS 20
+#define N_IOVEC_META_FIELDS 21
#define N_IOVEC_KERNEL_FIELDS 64
#define N_IOVEC_UDEV_FIELDS 32
-#define N_IOVEC_OBJECT_FIELDS 12
+#define N_IOVEC_OBJECT_FIELDS 14
#define N_IOVEC_PAYLOAD_FIELDS 15
void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len, const char *unit_id, int priority, pid_t object_pid);