Update Android Logger stdout tag setting 34/256834/1
authorMichal Bloch <m.bloch@samsung.com>
Tue, 13 Apr 2021 14:23:30 +0000 (16:23 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Tue, 13 Apr 2021 17:15:41 +0000 (19:15 +0200)
Kernel-side development changed the expected data format; conform.

Change-Id: I107b55b195cb9247fcccec7e7d48e646eeb09af8
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
include/dlog_ioctl.h
src/log-redirect-stdout/internal.c

index 7ba5e79..1e42787 100644 (file)
@@ -2,6 +2,7 @@
 #define _DLOG_IOCTL_H_
 
 #include <sys/ioctl.h>
+#include <stdint.h>
 
 // These are taken from the kernel: ./drivers/staging/android/logger.h
 #define __LOGGERIO     0xAE
 #define LOGGER_SET_TAG                 _IO(__LOGGERIO, 7) /* set flow mode tag */
 #define LOGGER_SET_PRIO                _IO(__LOGGERIO, 8) /* set flow mode prio */
 
+/**
+ * struct logger_set_tag
+ * @len:       Length of a NULL-terminated tag including '\0'
+ * @msg:       Pointer to a user buffer containing the tag
+ */
+struct logger_set_tag {
+       uint64_t len;
+       uint64_t ptr;
+};
+
 #endif
index b41a413..86b33cb 100644 (file)
@@ -27,6 +27,8 @@
 #include <logconfig.h>
 #include <logpipe.h>
 
+#include <stdint.h>
+
 static int setup_single_pipe(log_id_t buffer, const char *tag, log_priority prio, struct log_config *config, int *fd)
 {
        /* We don't really have a way to get the PID correctly in
@@ -64,16 +66,10 @@ static int setup_single_pipe(log_id_t buffer, const char *tag, log_priority prio
 
 static int apply_android_logger_ioctl(int fd, const char *tag, log_priority prio)
 {
-       struct {
-               int len;
-               char tag[128]; // soft limit on length based on dlogutil output format
-       } tag_info;
-
-       strncpy(tag_info.tag, tag, sizeof tag_info.tag);
-       tag_info.tag[sizeof tag_info.tag - 1] = '\0';
-       tag_info.len = strlen(tag_info.tag) + 1;
-
-       int r = ioctl(fd, LOGGER_SET_TAG, &tag_info);
+       int r = ioctl(fd, LOGGER_SET_TAG, & (struct logger_set_tag) {
+               .len = strlen(tag) + 1,
+               .ptr = (uintptr_t) tag
+       });
        if (r < 0)
                return -errno;