On Wed, Feb 20, 2019 at 09:16:04AM +0000, Steven Davies wrote:
> Provide an option in `btrfs receive` to suppress the informational
> messages when writing files.
Thank, looks ok to me, the 'receive' command already has the verbosity
option so it makes sense to have both.
> Signed-off-by: Steven Davies <btrfs@xxxxxxxxxxx>
> ---
> cmds-receive.c | 67 ++++++++++++++++++++++++++++++--------------------
> 1 file changed, 40 insertions(+), 27 deletions(-)
>
> diff --git a/cmds-receive.c b/cmds-receive.c
> index 3888149a..96411bac 100644
> --- a/cmds-receive.c
> +++ b/cmds-receive.c
> @@ -52,7 +52,11 @@
> #include "send-dump.h"
> #include "help.h"
>
> -static int g_verbose = 0;
> +/*
> + * Default is 1 for historical reasons, changing may break scripts that
> expect
> + * the 'At subvol' message.
> + */
> +static int g_verbose = 1;
>
> struct btrfs_receive
> {
> @@ -194,12 +198,14 @@ static int process_subvol(const char *path, const
> u8 *uuid, u64 ctransid,
> goto out;
> }
>
> - fprintf(stderr, "At subvol %s\n", path);
> + if (g_verbose) {
> + fprintf(stdout, "At subvol %s\n", path);
> + }
This changes stderr to stdout.
>
> memcpy(rctx->cur_subvol.received_uuid, uuid, BTRFS_UUID_SIZE);
> rctx->cur_subvol.stransid = ctransid;
>
> - if (g_verbose) {
> + if (g_verbose >= 2) {
> uuid_unparse((u8*)rctx->cur_subvol.received_uuid,
> uuid_str);
> fprintf(stderr, "receiving subvol %s uuid=%s,
> stransid=%llu\n",
> path, uuid_str,
> @@ -263,12 +269,14 @@ static int process_snapshot(const char *path,
> const u8 *uuid, u64 ctransid,
> goto out;
> }
>
> - fprintf(stdout, "At snapshot %s\n", path);
> + if (g_verbose) {
> + fprintf(stderr, "At snapshot %s\n", path);
And this stdout -> stderr.
That's inconsistent in the original code too, that may need some care to
fix. The stderr is used for all the verbosity levels and it's been like
that since the beginning. I doubt that it has a good reason and that
everybody does 'btrfs receive 2>&1' anyway, but we can never be sure
with that.
So for sake of backward compatibility I'll fix it to keep using the same
output streams and add to devel. Thanks.