diff mbox series

[095/104] virtiofsd: convert more fprintf and perror to use fuse log infra

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

Commit Message

Dr. David Alan Gilbert Dec. 12, 2019, 4:38 p.m. UTC
From: Eryu Guan <eguan@linux.alibaba.com>

Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
---
 tools/virtiofsd/fuse_signals.c | 6 +++++-
 tools/virtiofsd/helper.c       | 9 ++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

Comments

Daniel P. Berrangé Jan. 7, 2020, 12:16 p.m. UTC | #1
On Thu, Dec 12, 2019 at 04:38:55PM +0000, Dr. David Alan Gilbert (git) wrote:
> From: Eryu Guan <eguan@linux.alibaba.com>
> 
> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
> ---
>  tools/virtiofsd/fuse_signals.c | 6 +++++-
>  tools/virtiofsd/helper.c       | 9 ++++++---
>  2 files changed, 11 insertions(+), 4 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
Misono Tomohiro Jan. 16, 2020, 12:29 p.m. UTC | #2
> From: Eryu Guan <eguan@linux.alibaba.com>
> 
> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
> ---
>  tools/virtiofsd/fuse_signals.c | 6 +++++-
>  tools/virtiofsd/helper.c       | 9 ++++++---
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
> index 10a6f88088..edabf24e0d 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,12 +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) {
> +        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
> +                 strerror(errno));

I notice one perror is remaining:
>          perror("fuse: cannot set signal handler");

other than that,
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>

>          return -1;
>      }
> diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
> index 7b28507a38..bcb8c05063 100644
> --- a/tools/virtiofsd/helper.c
> +++ b/tools/virtiofsd/helper.c
> @@ -200,7 +200,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;
>          }
>  
> @@ -210,7 +211,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;
> @@ -220,7 +222,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;
>          }
>  
> -- 
> 2.23.0
Dr. David Alan Gilbert Jan. 16, 2020, 4:32 p.m. UTC | #3
* Misono Tomohiro (misono.tomohiro@jp.fujitsu.com) wrote:
> > From: Eryu Guan <eguan@linux.alibaba.com>
> > 
> > Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
> > ---
> >  tools/virtiofsd/fuse_signals.c | 6 +++++-
> >  tools/virtiofsd/helper.c       | 9 ++++++---
> >  2 files changed, 11 insertions(+), 4 deletions(-)
> > 
> > diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
> > index 10a6f88088..edabf24e0d 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,12 +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) {
> > +        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
> > +                 strerror(errno));
> 
> I notice one perror is remaining:
> >          perror("fuse: cannot set signal handler");

Oops,  Removed.

> other than that,
> Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>

Thanks.

> 
> >          return -1;
> >      }
> > diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
> > index 7b28507a38..bcb8c05063 100644
> > --- a/tools/virtiofsd/helper.c
> > +++ b/tools/virtiofsd/helper.c
> > @@ -200,7 +200,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;
> >          }
> >  
> > @@ -210,7 +211,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;
> > @@ -220,7 +222,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;
> >          }
> >  
> > -- 
> > 2.23.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
index 10a6f88088..edabf24e0d 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,12 +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) {
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
+                 strerror(errno));
         perror("fuse: cannot set signal handler");
         return -1;
     }
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
index 7b28507a38..bcb8c05063 100644
--- a/tools/virtiofsd/helper.c
+++ b/tools/virtiofsd/helper.c
@@ -200,7 +200,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;
         }
 
@@ -210,7 +211,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;
@@ -220,7 +222,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;
         }