From patchwork Thu Jan 31 08:21:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yang X-Patchwork-Id: 2071451 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 51C62DF2E5 for ; Thu, 31 Jan 2013 08:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604Ab3AaIWd (ORCPT ); Thu, 31 Jan 2013 03:22:33 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:46415 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751248Ab3AaIWb (ORCPT ); Thu, 31 Jan 2013 03:22:31 -0500 X-IronPort-AV: E=Sophos;i="4.84,574,1355068800"; d="scan'208";a="6671008" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 31 Jan 2013 16:20:18 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r0V8MSlC017906 for ; Thu, 31 Jan 2013 16:22:28 +0800 Received: from [10.167.225.168] ([10.167.225.168]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013013116212051-194613 ; Thu, 31 Jan 2013 16:21:20 +0800 Message-ID: <510A2984.6010601@cn.fujitsu.com> Date: Thu, 31 Jan 2013 16:21:24 +0800 From: Chen Yang User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: linux-btrfs , miaox@cn.fujitsu.com Subject: [PATCH] Btrfs-prog/send: fix wrong dump_fd check in cmd_send_start() References: <510A2791.1010607@cn.fujitsu.com> In-Reply-To: <510A2791.1010607@cn.fujitsu.com> X-Forwarded-Message-Id: <510A2791.1010607@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/31 16:21:20, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/31 16:21:20, Serialize complete at 2013/01/31 16:21:20 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 --- 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];