All of lore.kernel.org
 help / color / mirror / Atom feed
From: M G Berberich <btrfs@oss.m-berberich.de>
To: linux-btrfs@vger.kernel.org
Subject: [PATHCH] add option to supress "At subvol …" message in btrfs send
Date: Sat, 7 May 2016 18:29:58 +0200	[thread overview]
Message-ID: <20160507162958.GA2241@invalid> (raw)

Hello,

btrfs send puts a “At subvol …” on stderr, which is very annoying in
scripts, esp. cron-jobs. Piping stderr to /dev/null does suppress this
message, but also error-messages which one would probably want to
see. I added an option to not change the behavior of btrfs send
and possibly break existing scripts, but moving this message to
verbose would be O.K. for me too.


diff -Naur btrfs-progs-4.4.1/cmds-send.c btrfs-progs-4.4.1-neu/cmds-send.c
--- btrfs-progs-4.4.1/cmds-send.c	2016-02-26 18:22:09.000000000 +0100
+++ btrfs-progs-4.4.1-neu/cmds-send.c	2016-05-07 18:10:13.935853568 +0200
@@ -45,6 +45,7 @@
 #include "send-utils.h"
 
 static int g_verbose = 0;
+static int g_quiet = 0;
 
 struct btrfs_send {
 	int send_fd;
@@ -442,7 +443,7 @@
 		static const struct option long_options[] = {
 			{ "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA }
 		};
-		int c = getopt_long(argc, argv, "vec:f:i:p:", long_options, NULL);
+		int c = getopt_long(argc, argv, "vec:f:i:p:q", long_options, NULL);
 
 		if (c < 0)
 			break;
@@ -534,6 +535,9 @@
 			error("option -i was removed, use -c instead");
 			ret = 1;
 			goto out;
+		case 'q':
+			g_quiet = 1;
+			break;
 		case GETOPT_VAL_SEND_NO_DATA:
 			send_flags |= BTRFS_SEND_FLAG_NO_FILE_DATA;
 			break;
@@ -642,7 +646,8 @@
 		free(subvol);
 		subvol = argv[i];
 
-		fprintf(stderr, "At subvol %s\n", subvol);
+		if (!g_quiet)
+			fprintf(stderr, "At subvol %s\n", subvol);
 
 		subvol = realpath(subvol, NULL);
 		if (!subvol) {
@@ -737,5 +742,6 @@
 	"                 does not contain any file data and thus cannot be used",
 	"                 to transfer changes. This mode is faster and useful to",
 	"                 show the differences in metadata.",
+	"-q               suppress 'At subvol' message on stderr",
 	NULL
 };
diff -Naur btrfs-progs-4.4.1/Documentation/btrfs-send.asciidoc btrfs-progs-4.4.1-neu/Documentation/btrfs-send.asciidoc
--- btrfs-progs-4.4.1/Documentation/btrfs-send.asciidoc	2016-02-26 18:22:09.000000000 +0100
+++ btrfs-progs-4.4.1-neu/Documentation/btrfs-send.asciidoc	2016-05-07 18:14:24.615712654 +0200
@@ -45,6 +45,8 @@
 Send in NO_FILE_DATA mode. The output stream does not contain any file
 data and thus cannot be used to transfer changes. This mode is faster and
 useful to show the differences in metadata.
+-q::
+Suppress "At subvol" message on stderr.
 
 EXIT STATUS
 -----------


	MfG
	bmg

-- 
„Des is völlig wurscht, was heut beschlos- | M G Berberich
 sen wird: I bin sowieso dagegn!“          | mail@m-berberich.de
(SPD-Stadtrat Kurt Schindler; Regensburg)  | 

             reply	other threads:[~2016-05-07 17:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-07 16:29 M G Berberich [this message]
2016-05-12 11:41 ` [PATHCH] add option to supress "At subvol …" message in btrfs send David Sterba
2016-05-12 19:49   ` [PATCH] btrfs-progs: added quiet-option for scripts btrfs
2016-05-13  9:24     ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160507162958.GA2241@invalid \
    --to=btrfs@oss.m-berberich.de \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.