peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0104-virtiofsd-convert-more-fprintf-and-perror-to-use-fus.patch

1d442b
From: Eryu Guan <eguan@linux.alibaba.com>
1d442b
Date: Mon, 27 Jan 2020 19:02:13 +0000
1d442b
Subject: [PATCH] virtiofsd: convert more fprintf and perror to use fuse log
1d442b
 infra
1d442b
MIME-Version: 1.0
1d442b
Content-Type: text/plain; charset=UTF-8
1d442b
Content-Transfer-Encoding: 8bit
1d442b
1d442b
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
1d442b
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
1d442b
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
1d442b
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit fc1aed0bf96259d0b46b1cfea7497b7762c4ee3d)
1d442b
---
1d442b
 tools/virtiofsd/fuse_signals.c | 7 +++++--
1d442b
 tools/virtiofsd/helper.c       | 9 ++++++---
1d442b
 2 files changed, 11 insertions(+), 5 deletions(-)
1d442b
1d442b
diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
1d442b
index dc7c8ac025..f18625b6e2 100644
1d442b
--- a/tools/virtiofsd/fuse_signals.c
1d442b
+++ b/tools/virtiofsd/fuse_signals.c
1d442b
@@ -12,6 +12,7 @@
1d442b
 #include "fuse_i.h"
1d442b
 #include "fuse_lowlevel.h"
1d442b
 
1d442b
+#include <errno.h>
1d442b
 #include <signal.h>
1d442b
 #include <stdio.h>
1d442b
 #include <stdlib.h>
1d442b
@@ -47,13 +48,15 @@ static int set_one_signal_handler(int sig, void (*handler)(int), int remove)
1d442b
     sa.sa_flags = 0;
1d442b
 
1d442b
     if (sigaction(sig, NULL, &old_sa) == -1) {
1d442b
-        perror("fuse: cannot get old signal handler");
1d442b
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot get old signal handler: %s\n",
1d442b
+                 strerror(errno));
1d442b
         return -1;
1d442b
     }
1d442b
 
1d442b
     if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
1d442b
         sigaction(sig, &sa, NULL) == -1) {
1d442b
-        perror("fuse: cannot set signal handler");
1d442b
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
1d442b
+                 strerror(errno));
1d442b
         return -1;
1d442b
     }
1d442b
     return 0;
1d442b
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
1d442b
index 33749bfcb7..f98d8f2eb2 100644
1d442b
--- a/tools/virtiofsd/helper.c
1d442b
+++ b/tools/virtiofsd/helper.c
1d442b
@@ -208,7 +208,8 @@ int fuse_daemonize(int foreground)
1d442b
         char completed;
1d442b
 
1d442b
         if (pipe(waiter)) {
1d442b
-            perror("fuse_daemonize: pipe");
1d442b
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: pipe: %s\n",
1d442b
+                     strerror(errno));
1d442b
             return -1;
1d442b
         }
1d442b
 
1d442b
@@ -218,7 +219,8 @@ int fuse_daemonize(int foreground)
1d442b
          */
1d442b
         switch (fork()) {
1d442b
         case -1:
1d442b
-            perror("fuse_daemonize: fork");
1d442b
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: fork: %s\n",
1d442b
+                     strerror(errno));
1d442b
             return -1;
1d442b
         case 0:
1d442b
             break;
1d442b
@@ -228,7 +230,8 @@ int fuse_daemonize(int foreground)
1d442b
         }
1d442b
 
1d442b
         if (setsid() == -1) {
1d442b
-            perror("fuse_daemonize: setsid");
1d442b
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: setsid: %s\n",
1d442b
+                     strerror(errno));
1d442b
             return -1;
1d442b
         }
1d442b