chiark / gitweb /
bus: also parse PID starttime out of kdbus message
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Apr 2013 23:49:52 +0000 (01:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Apr 2013 23:49:52 +0000 (01:49 +0200)
src/libsystemd-bus/bus-kernel.c
src/libsystemd-bus/bus-message.c
src/libsystemd-bus/bus-message.h
src/systemd/sd-bus.h

index 83379d1..3d26f16 100644 (file)
@@ -305,6 +305,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
         }
 
         if (creds) {
+                m->pid_starttime = creds->starttime / NSEC_PER_USEC;
                 m->uid = creds->uid;
                 m->gid = creds->gid;
                 m->pid = creds->pid;
index 092654f..aac49f4 100644 (file)
@@ -692,6 +692,16 @@ int sd_bus_message_get_tid(sd_bus_message *m, pid_t *tid) {
         return 0;
 }
 
+int sd_bus_message_get_pid_starttime(sd_bus_message *m, uint64_t *usec) {
+        if (!m)
+                return -EINVAL;
+        if (m->pid_starttime <= 0)
+                return -ENOENT;
+
+        *usec = m->pid_starttime;
+        return 0;
+}
+
 const char *sd_bus_message_get_label(sd_bus_message *m) {
         if (!m)
                 return NULL;
@@ -2910,7 +2920,8 @@ int bus_message_dump(sd_bus_message *m) {
                 printf("\tuid=%lu\n", (unsigned long) m->uid);
         if (m->gid_valid)
                 printf("\tgid=%lu\n", (unsigned long) m->gid);
-
+        if (m->pid_starttime != 0)
+                printf("\tpid_starttime=%llu\n", (unsigned long long) m->pid_starttime);
 
         r = sd_bus_message_rewind(m, true);
         if (r < 0) {
index d1ab548..079a188 100644 (file)
@@ -67,6 +67,7 @@ struct sd_bus_message {
         gid_t gid;
         pid_t pid;
         pid_t tid;
+        usec_t pid_starttime;
 
         bool sealed:1;
         bool dont_send:1;
index 748d76b..4ab5924 100644 (file)
@@ -125,6 +125,7 @@ int sd_bus_message_get_uid(sd_bus_message *m, uid_t *uid);
 int sd_bus_message_get_gid(sd_bus_message *m, gid_t *gid);
 int sd_bus_message_get_pid(sd_bus_message *m, pid_t *pid);
 int sd_bus_message_get_tid(sd_bus_message *m, pid_t *tid);
+int sd_bus_message_get_pid_starttime(sd_bus_message *m, uint64_t *usec);
 const char *sd_bus_message_get_label(sd_bus_message *m);
 
 int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);