From f2f572fa7005b8f7adfff258bfb174076381a391 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 24 Aug 2018 09:43:25 +0100 Subject: [PATCH] hmcdrvfs: Direct --help and --version output to stdout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hmcdrvfs writes output for --help and --version to stderr. This is likely because hmcdrvfs calls into a FUSE function for additional usage output that also writes to stderr (prior to FUSE 3.0.0). To be consistent with other s390-tools and GNU coding guide lines, fix this by using stdout for hmcdrvfs generated output, and by redirecting stderr to stdout before calling the FUSE function. Signed-off-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- hmcdrvfs/hmcdrvfs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hmcdrvfs/hmcdrvfs.c b/hmcdrvfs/hmcdrvfs.c index 3cf10056..fb540662 100644 --- a/hmcdrvfs/hmcdrvfs.c +++ b/hmcdrvfs/hmcdrvfs.c @@ -1338,7 +1338,7 @@ static int hmcdrv_fuse_main(struct fuse_args *args) */ static void hmcdrv_fuse_usage(const char *progname) { - fprintf(stderr, + fprintf(stdout, "Usage: %s MOUNTPOINT [OPTIONS]\n\n" "Use the %s command to read files from a HMC drive DVD.\n" "\n" @@ -1450,7 +1450,7 @@ static int hmcdrv_fuse_optproc(void *data, const char *arg, return 1; case HMCDRV_FUSE_OPTKEY_VERSION: - fprintf(stderr, HMCDRV_FUSE_LOGHEAD + fprintf(stdout, HMCDRV_FUSE_LOGHEAD "HMC drive DVD file system, version %s\n" "Copyright IBM Corp. 2015, 2017\n", HMCDRV_FUSE_RELEASE); @@ -1458,6 +1458,16 @@ static int hmcdrv_fuse_optproc(void *data, const char *arg, case HMCDRV_FUSE_OPTKEY_HELP: hmcdrv_fuse_usage(outargs->argv[0]); + + /* + * Usage output needs to go to stdout to be consistent with + * coding guidelines. FUSE versions before 3.0.0 print help + * output to stderr. Redirect stderr to stdout here to enforce + * consistent behavior. + */ + fflush(stderr); + dup2(STDOUT_FILENO, STDERR_FILENO); + fuse_opt_add_arg(outargs, "-ho"); hmcdrv_fuse_main(outargs); exit(EXIT_SUCCESS);