Skip to contentSkip to conversation

linux-user: fix socket() strace

PATCH Applied Laurent Vivier 2 participants 3 messages Mar 12, 2020 – Mar 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user: fix socket() strace

print_socket_type() doesn't manage flags and the correct type cannot be displayed

---

Notes:
v2: replace gemu_log() by qemu_log() as it has been removed from qemu

 linux-user/strace.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/strace.c +7 -1
index 4f7130b2ff63..69232f7e27b8 100644
@@ -444,7 +444,7 @@ print_socket_domain(int domain)
 static void
 print_socket_type(int type)
 {
-    switch (type) {
+    switch (type & TARGET_SOCK_TYPE_MASK) {
     case TARGET_SOCK_DGRAM:
         qemu_log("SOCK_DGRAM");
         break;
@@ -464,6 +464,12 @@ print_socket_type(int type)
         qemu_log("SOCK_PACKET");
         break;
     }
+    if (type & TARGET_SOCK_CLOEXEC) {
+        qemu_log("|SOCK_CLOEXEC");
+    }
+    if (type & TARGET_SOCK_NONBLOCK) {
+        qemu_log("|SOCK_NONBLOCK");
+    }
 }
 
 static void
Signature · 1 line
2.24.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 29 lines · Laurent Vivier

print_socket_type() doesn't manage flags and the correct type cannot be displayed

---

Notes:
v2: replace gemu_log() by qemu_log() as it has been removed from qemu

  linux-user/strace.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/strace.c +1 -1
index 4f7130b2ff63..69232f7e27b8 100644
@@ -444,7 +444,7 @@ print_socket_domain(int domain)
  static void
  print_socket_type(int type)
  {
-    switch (type) {
+    switch (type & TARGET_SOCK_TYPE_MASK) {
      case TARGET_SOCK_DGRAM:
          qemu_log("SOCK_DGRAM");
          break;
@@ -464,6 +464,12 @@ print_socket_type(int type)
          qemu_log("SOCK_PACKET");
          break;

linux-user/strace.c print_socket_type(int type) · line 475

Quoted 10 lines
linux-user/strace.c +6 -0
      }
+    if (type & TARGET_SOCK_CLOEXEC) {
+        qemu_log("|SOCK_CLOEXEC");
+    }
+    if (type & TARGET_SOCK_NONBLOCK) {
+        qemu_log("|SOCK_NONBLOCK");
+    }
  }
 
  static void
author Applied
#2 lore raw
In reply to Laurent Vivier

Le 12/03/2020 à 17:55, Laurent Vivier a écrit :

Quoted 29 lines

print_socket_type() doesn't manage flags and the correct type cannot be displayed

---

Notes:
v2: replace gemu_log() by qemu_log() as it has been removed from qemu

 linux-user/strace.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
linux-user/strace.c +1 -1
index 4f7130b2ff63..69232f7e27b8 100644
@@ -444,7 +444,7 @@ print_socket_domain(int domain)
 static void
 print_socket_type(int type)
 {
-    switch (type) {
+    switch (type & TARGET_SOCK_TYPE_MASK) {
     case TARGET_SOCK_DGRAM:
         qemu_log("SOCK_DGRAM");
         break;
@@ -464,6 +464,12 @@ print_socket_type(int type)
         qemu_log("SOCK_PACKET");
         break;

linux-user/strace.c print_socket_type(int type) · line 475

Quoted 10 lines
linux-user/strace.c +6 -0
     }
+    if (type & TARGET_SOCK_CLOEXEC) {
+        qemu_log("|SOCK_CLOEXEC");
+    }
+    if (type & TARGET_SOCK_NONBLOCK) {
+        qemu_log("|SOCK_NONBLOCK");
+    }
 }
 
 static void

Applied to my linux-user branch.

Thanks,
Laurent