|
|
22c213 |
From 9f726593bc3acbc247876dcc4d79fbf046958003 Mon Sep 17 00:00:00 2001
|
|
|
22c213 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
22c213 |
Date: Mon, 27 Jan 2020 19:00:49 +0100
|
|
|
22c213 |
Subject: [PATCH 018/116] virtiofsd: Fix fuse_daemonize ignored return values
|
|
|
22c213 |
MIME-Version: 1.0
|
|
|
22c213 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c213 |
Content-Transfer-Encoding: 8bit
|
|
|
22c213 |
|
|
|
22c213 |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
22c213 |
Message-id: <20200127190227.40942-15-dgilbert@redhat.com>
|
|
|
22c213 |
Patchwork-id: 93469
|
|
|
22c213 |
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 014/112] virtiofsd: Fix fuse_daemonize ignored return values
|
|
|
22c213 |
Bugzilla: 1694164
|
|
|
22c213 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
22c213 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
22c213 |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
22c213 |
|
|
|
22c213 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
22c213 |
|
|
|
22c213 |
QEMU's compiler enables warnings/errors for ignored values
|
|
|
22c213 |
and the (void) trick used in the fuse code isn't enough.
|
|
|
22c213 |
Turn all the return values into a return value on the function.
|
|
|
22c213 |
|
|
|
22c213 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
22c213 |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
22c213 |
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
22c213 |
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
22c213 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
22c213 |
(cherry picked from commit 30d8e49760712d65697ea517c53671bd1d214fc7)
|
|
|
22c213 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
22c213 |
---
|
|
|
22c213 |
tools/virtiofsd/helper.c | 33 ++++++++++++++++++++++-----------
|
|
|
22c213 |
1 file changed, 22 insertions(+), 11 deletions(-)
|
|
|
22c213 |
|
|
|
22c213 |
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
|
|
|
22c213 |
index 5e6f205..d9227d7 100644
|
|
|
22c213 |
--- a/tools/virtiofsd/helper.c
|
|
|
22c213 |
+++ b/tools/virtiofsd/helper.c
|
|
|
22c213 |
@@ -10,12 +10,10 @@
|
|
|
22c213 |
* See the file COPYING.LIB.
|
|
|
22c213 |
*/
|
|
|
22c213 |
|
|
|
22c213 |
-#include "config.h"
|
|
|
22c213 |
#include "fuse_i.h"
|
|
|
22c213 |
#include "fuse_lowlevel.h"
|
|
|
22c213 |
#include "fuse_misc.h"
|
|
|
22c213 |
#include "fuse_opt.h"
|
|
|
22c213 |
-#include "mount_util.h"
|
|
|
22c213 |
|
|
|
22c213 |
#include <errno.h>
|
|
|
22c213 |
#include <limits.h>
|
|
|
22c213 |
@@ -171,6 +169,7 @@ int fuse_parse_cmdline(struct fuse_args *args, struct fuse_cmdline_opts *opts)
|
|
|
22c213 |
|
|
|
22c213 |
int fuse_daemonize(int foreground)
|
|
|
22c213 |
{
|
|
|
22c213 |
+ int ret = 0, rett;
|
|
|
22c213 |
if (!foreground) {
|
|
|
22c213 |
int nullfd;
|
|
|
22c213 |
int waiter[2];
|
|
|
22c213 |
@@ -192,8 +191,8 @@ int fuse_daemonize(int foreground)
|
|
|
22c213 |
case 0:
|
|
|
22c213 |
break;
|
|
|
22c213 |
default:
|
|
|
22c213 |
- (void)read(waiter[0], &completed, sizeof(completed));
|
|
|
22c213 |
- _exit(0);
|
|
|
22c213 |
+ _exit(read(waiter[0], &completed,
|
|
|
22c213 |
+ sizeof(completed) != sizeof(completed)));
|
|
|
22c213 |
}
|
|
|
22c213 |
|
|
|
22c213 |
if (setsid() == -1) {
|
|
|
22c213 |
@@ -201,13 +200,22 @@ int fuse_daemonize(int foreground)
|
|
|
22c213 |
return -1;
|
|
|
22c213 |
}
|
|
|
22c213 |
|
|
|
22c213 |
- (void)chdir("/");
|
|
|
22c213 |
+ ret = chdir("/");
|
|
|
22c213 |
|
|
|
22c213 |
nullfd = open("/dev/null", O_RDWR, 0);
|
|
|
22c213 |
if (nullfd != -1) {
|
|
|
22c213 |
- (void)dup2(nullfd, 0);
|
|
|
22c213 |
- (void)dup2(nullfd, 1);
|
|
|
22c213 |
- (void)dup2(nullfd, 2);
|
|
|
22c213 |
+ rett = dup2(nullfd, 0);
|
|
|
22c213 |
+ if (!ret) {
|
|
|
22c213 |
+ ret = rett;
|
|
|
22c213 |
+ }
|
|
|
22c213 |
+ rett = dup2(nullfd, 1);
|
|
|
22c213 |
+ if (!ret) {
|
|
|
22c213 |
+ ret = rett;
|
|
|
22c213 |
+ }
|
|
|
22c213 |
+ rett = dup2(nullfd, 2);
|
|
|
22c213 |
+ if (!ret) {
|
|
|
22c213 |
+ ret = rett;
|
|
|
22c213 |
+ }
|
|
|
22c213 |
if (nullfd > 2) {
|
|
|
22c213 |
close(nullfd);
|
|
|
22c213 |
}
|
|
|
22c213 |
@@ -215,13 +223,16 @@ int fuse_daemonize(int foreground)
|
|
|
22c213 |
|
|
|
22c213 |
/* Propagate completion of daemon initialization */
|
|
|
22c213 |
completed = 1;
|
|
|
22c213 |
- (void)write(waiter[1], &completed, sizeof(completed));
|
|
|
22c213 |
+ rett = write(waiter[1], &completed, sizeof(completed));
|
|
|
22c213 |
+ if (!ret) {
|
|
|
22c213 |
+ ret = rett;
|
|
|
22c213 |
+ }
|
|
|
22c213 |
close(waiter[0]);
|
|
|
22c213 |
close(waiter[1]);
|
|
|
22c213 |
} else {
|
|
|
22c213 |
- (void)chdir("/");
|
|
|
22c213 |
+ ret = chdir("/");
|
|
|
22c213 |
}
|
|
|
22c213 |
- return 0;
|
|
|
22c213 |
+ return ret;
|
|
|
22c213 |
}
|
|
|
22c213 |
|
|
|
22c213 |
void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
|
|
|
22c213 |
--
|
|
|
22c213 |
1.8.3.1
|
|
|
22c213 |
|