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