From eade9951858b476520823c406c0617c8281f1311 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 24 Aug 2018 09:56:50 +0100 Subject: [PATCH] zdsfs: Direct --help and --version output to stdout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zdsfs writes output for --help and --version to stderr. This is likely because zdsfs 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 zdsfs generated output, and by redirecting stderr to stdout before calling the FUSE function. Reviewed-by: Hendrik Brueckner Signed-off-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- zdsfs/zdsfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/zdsfs/zdsfs.c b/zdsfs/zdsfs.c index 462fda77..1aac5f6b 100644 --- a/zdsfs/zdsfs.c +++ b/zdsfs/zdsfs.c @@ -774,7 +774,7 @@ static const struct fuse_opt zdsfs_opts[] = { static void usage(const char *progname) { - fprintf(stderr, + fprintf(stdout, "Usage: %s []\n" "\n" "Use the zdsfs command to provide read access to data sets stored on one or\n" @@ -976,14 +976,24 @@ static int zdsfs_process_args(void *UNUSED(data), const char *arg, int key, return 0; case KEY_HELP: 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"); /* call fuse_main to let library print fuse options */ fuse_main(outargs->argc, outargs->argv, &rdf_oper, NULL); exit(0); case KEY_VERSION: - fprintf(stderr, COMP "FUSE file system for z/OS data set access" + fprintf(stdout, COMP "FUSE file system for z/OS data set access" ", program version %s\n", RELEASE_STRING); - fprintf(stderr, "Copyright IBM Corp. 2013, 2017\n"); + fprintf(stdout, "Copyright IBM Corp. 2013, 2017\n"); exit(0); default: fprintf(stderr, "Unknown argument key %x\n", key);