* [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start()
[not found] <510A2791.1010607@cn.fujitsu.com>
@ 2013-01-31 8:21 ` Chen Yang
2013-01-31 16:52 ` David Sterba
0 siblings, 1 reply; 4+ messages in thread
From: Chen Yang @ 2013-01-31 8:21 UTC (permalink / raw)
To: linux-btrfs, miaox
In cmd_send_start(), there is a check to make sure dump_fd is not a tty
before parsing command options. So if we use the option "-f file",
it doesn't work for the dump_fd has not been created. So fix it.
Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
---
cmds-send.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmds-send.c b/cmds-send.c
index 2b9a610..aafa800 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -429,11 +429,6 @@ int cmd_send_start(int argc, char **argv)
memset(&send, 0, sizeof(send));
send.dump_fd = fileno(stdout);
- if (isatty(send.dump_fd)) {
- fprintf(stderr, "ERROR: not dumping send stream into a terminal, redirect it into a file\n");
- return 1;
- }
-
while ((c = getopt(argc, argv, "vf:i:p:")) != -1) {
switch (c) {
case 'v':
@@ -497,6 +492,13 @@ int cmd_send_start(int argc, char **argv)
}
}
+ if (isatty(send.dump_fd)) {
+ fprintf(stderr,
+ "ERROR: not dumping send stream into a terminal, "
+ "redirect it into a file\n");
+ return 1;
+ }
+
/* use first send subvol to determine mount_root */
subvol = argv[optind];
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start()
2013-01-31 8:21 ` [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start() Chen Yang
@ 2013-01-31 16:52 ` David Sterba
2013-02-01 2:58 ` Chen Yang
0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2013-01-31 16:52 UTC (permalink / raw)
To: Chen Yang; +Cc: linux-btrfs, miaox
On Thu, Jan 31, 2013 at 04:21:24PM +0800, Chen Yang wrote:
> In cmd_send_start(), there is a check to make sure dump_fd is not a tty
> before parsing command options. So if we use the option "-f file",
> it doesn't work for the dump_fd has not been created. So fix it.
Good catch, thanks. I see that there's no special handling of the '-'
filename that usually means stdout. We may want to add this as a common
command line usage pattern.
david
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start()
2013-01-31 16:52 ` David Sterba
@ 2013-02-01 2:58 ` Chen Yang
2013-02-01 12:31 ` David Sterba
0 siblings, 1 reply; 4+ messages in thread
From: Chen Yang @ 2013-02-01 2:58 UTC (permalink / raw)
To: dsterba; +Cc: linux-btrfs, miaox
> On Thu, Jan 31, 2013 at 04:21:24PM +0800, Chen Yang wrote:
>> In cmd_send_start(), there is a check to make sure dump_fd is not a tty
>> before parsing command options. So if we use the option "-f file",
>> it doesn't work for the dump_fd has not been created. So fix it.
>
> Good catch, thanks. I see that there's no special handling of the '-'
> filename that usually means stdout. We may want to add this as a common
> command line usage pattern.
>
> david
>
We can touch a file name "-", so I think special handling of the '-' is unnecessary.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start()
2013-02-01 2:58 ` Chen Yang
@ 2013-02-01 12:31 ` David Sterba
0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2013-02-01 12:31 UTC (permalink / raw)
To: Chen Yang; +Cc: dsterba, linux-btrfs, miaox
On Fri, Feb 01, 2013 at 10:58:33AM +0800, Chen Yang wrote:
> > Good catch, thanks. I see that there's no special handling of the '-'
> > filename that usually means stdout. We may want to add this as a common
> > command line usage pattern.
> >
> We can touch a file name "-", so I think special handling of the '-' is unnecessary.
I want to avoid creating a file named '-'. It would work the same way as
'cat -' etc.
david
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-01 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <510A2791.1010607@cn.fujitsu.com>
2013-01-31 8:21 ` [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start() Chen Yang
2013-01-31 16:52 ` David Sterba
2013-02-01 2:58 ` Chen Yang
2013-02-01 12:31 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).