diff mbox series

[v2,097/109] virtiofsd: convert more fprintf and perror to use fuse log infra

Message ID 20200121122433.50803-98-dgilbert@redhat.com
State New
Headers show
Series virtiofs daemon [all] | expand

Commit Message

Dr. David Alan Gilbert Jan. 21, 2020, 12:24 p.m. UTC
From: Eryu Guan <eguan@linux.alibaba.com>

Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
 tools/virtiofsd/fuse_signals.c | 7 +++++--
 tools/virtiofsd/helper.c       | 9 ++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

Comments

Philippe Mathieu-Daudé Jan. 22, 2020, 3:44 p.m. UTC | #1
On 1/21/20 1:24 PM, Dr. David Alan Gilbert (git) wrote:
> From: Eryu Guan <eguan@linux.alibaba.com>
> 
> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
> ---
>   tools/virtiofsd/fuse_signals.c | 7 +++++--
>   tools/virtiofsd/helper.c       | 9 ++++++---
>   2 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
> index 10a6f88088..5364cbe984 100644
> --- a/tools/virtiofsd/fuse_signals.c
> +++ b/tools/virtiofsd/fuse_signals.c
> @@ -11,6 +11,7 @@
>   #include "fuse_i.h"
>   #include "fuse_lowlevel.h"
>   
> +#include <errno.h>
>   #include <signal.h>
>   #include <stdio.h>
>   #include <stdlib.h>
> @@ -46,13 +47,15 @@ static int set_one_signal_handler(int sig, void (*handler)(int), int remove)
>       sa.sa_flags = 0;
>   
>       if (sigaction(sig, NULL, &old_sa) == -1) {
> -        perror("fuse: cannot get old signal handler");
> +        fuse_log(FUSE_LOG_ERR, "fuse: cannot get old signal handler: %s\n",
> +                 strerror(errno));
>           return -1;
>       }
>   
>       if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
>           sigaction(sig, &sa, NULL) == -1) {
> -        perror("fuse: cannot set signal handler");
> +        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
> +                 strerror(errno));
>           return -1;
>       }
>       return 0;
> diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
> index 781c47031c..a19959926c 100644
> --- a/tools/virtiofsd/helper.c
> +++ b/tools/virtiofsd/helper.c
> @@ -208,7 +208,8 @@ int fuse_daemonize(int foreground)
>           char completed;
>   
>           if (pipe(waiter)) {
> -            perror("fuse_daemonize: pipe");
> +            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: pipe: %s\n",
> +                     strerror(errno));
>               return -1;
>           }
>   
> @@ -218,7 +219,8 @@ int fuse_daemonize(int foreground)
>            */
>           switch (fork()) {
>           case -1:
> -            perror("fuse_daemonize: fork");
> +            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: fork: %s\n",
> +                     strerror(errno));
>               return -1;
>           case 0:
>               break;
> @@ -228,7 +230,8 @@ int fuse_daemonize(int foreground)
>           }
>   
>           if (setsid() == -1) {
> -            perror("fuse_daemonize: setsid");
> +            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: setsid: %s\n",
> +                     strerror(errno));
>               return -1;
>           }
>   
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
index 10a6f88088..5364cbe984 100644
--- a/tools/virtiofsd/fuse_signals.c
+++ b/tools/virtiofsd/fuse_signals.c
@@ -11,6 +11,7 @@ 
 #include "fuse_i.h"
 #include "fuse_lowlevel.h"
 
+#include <errno.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -46,13 +47,15 @@  static int set_one_signal_handler(int sig, void (*handler)(int), int remove)
     sa.sa_flags = 0;
 
     if (sigaction(sig, NULL, &old_sa) == -1) {
-        perror("fuse: cannot get old signal handler");
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot get old signal handler: %s\n",
+                 strerror(errno));
         return -1;
     }
 
     if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
         sigaction(sig, &sa, NULL) == -1) {
-        perror("fuse: cannot set signal handler");
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
+                 strerror(errno));
         return -1;
     }
     return 0;
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
index 781c47031c..a19959926c 100644
--- a/tools/virtiofsd/helper.c
+++ b/tools/virtiofsd/helper.c
@@ -208,7 +208,8 @@  int fuse_daemonize(int foreground)
         char completed;
 
         if (pipe(waiter)) {
-            perror("fuse_daemonize: pipe");
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: pipe: %s\n",
+                     strerror(errno));
             return -1;
         }
 
@@ -218,7 +219,8 @@  int fuse_daemonize(int foreground)
          */
         switch (fork()) {
         case -1:
-            perror("fuse_daemonize: fork");
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: fork: %s\n",
+                     strerror(errno));
             return -1;
         case 0:
             break;
@@ -228,7 +230,8 @@  int fuse_daemonize(int foreground)
         }
 
         if (setsid() == -1) {
-            perror("fuse_daemonize: setsid");
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: setsid: %s\n",
+                     strerror(errno));
             return -1;
         }