From patchwork Wed Sep 4 15:22:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 2853762 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5A2F59F4D4 for ; Wed, 4 Sep 2013 15:23:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36ED0204CE for ; Wed, 4 Sep 2013 15:23:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 168E4204CF for ; Wed, 4 Sep 2013 15:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935007Ab3IDPXo (ORCPT ); Wed, 4 Sep 2013 11:23:44 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:55852 "EHLO mail-pb0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934783Ab3IDPXm (ORCPT ); Wed, 4 Sep 2013 11:23:42 -0400 Received: by mail-pb0-f44.google.com with SMTP id xa7so445559pbc.31 for ; Wed, 04 Sep 2013 08:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yAT4sj4mcorotvs+PB/1LZQ6acEgPmo4H9N6+YU/ORc=; b=BtlypbAsmvw0CeYKJzXzLBtQ05j+GAxPRmeIqiDj0NzY0VuTC/BgClcxCWEisWY9Wx rR0byXzA0OHCZKvs1mDHFkosQoyFClGg8YOuUJ5lLfvIU6QanANGIA48ZRF05GCp5Q6F 94qw1bbHLaRHTYh8DZIk6BGT31j+VJVOylUBBtWJjD7OG3sEnWFm7y6/0EarkPrD5A6w VyYOBBNi+n2ZgYkscGAlFbTv0qKtfAoG5/T8u7X+fqWwX18d6frxIZ+O5Hg4GA3s9Zv3 hnqn20aCJki3keJWtNvpD9KbIj6pkBNy595pA6TmvQ67zIkq3aIIkONkj+MiZi0eIx3j mqSQ== X-Received: by 10.68.52.200 with SMTP id v8mr3944167pbo.48.1378308222042; Wed, 04 Sep 2013 08:23:42 -0700 (PDT) Received: from localhost.localdomain.localdomain ([223.65.191.73]) by mx.google.com with ESMTPSA id uw6sm29467271pbc.8.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Sep 2013 08:23:41 -0700 (PDT) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, sandeen@redhat.com Subject: [PATCH 19/20] Btrfs-progs: fix magic return value in cmds-replace.c Date: Wed, 4 Sep 2013 23:22:36 +0800 Message-Id: <1378308157-4621-20-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1378308157-4621-1-git-send-email-wangshilong1991@gmail.com> References: <1378308157-4621-1-git-send-email-wangshilong1991@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Shilong There are 3 kinds of return values in replace cancel: 0: cancel successfully. 1: usage or syntal errors 2: cancel a not started or finished replacing operations. Signed-off-by: Wang Shilong --- cmds-replace.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmds-replace.c b/cmds-replace.c index 1df719b..d9b0940 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -324,7 +324,7 @@ leave_with_error: close(fdsrcdev); if (fddstdev != -1) close(fddstdev); - return -1; + return 1; } static const char *const cmd_status_replace_usage[] = { @@ -367,12 +367,12 @@ static int cmd_status_replace(int argc, char **argv) if (fd < 0) { fprintf(stderr, "ERROR: can't access \"%s\": %s\n", path, strerror(e)); - return -1; + return 1; } ret = print_replace_status(fd, path, once); close_file_or_dir(fd, dirstream); - return ret; + return !!ret; } static int print_replace_status(int fd, const char *path, int once) @@ -530,7 +530,7 @@ static int cmd_cancel_replace(int argc, char **argv) if (fd < 0) { fprintf(stderr, "ERROR: can't access \"%s\": %s\n", path, strerror(errno)); - return -1; + return 1; } args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL; @@ -541,9 +541,13 @@ static int cmd_cancel_replace(int argc, char **argv) fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_CANCEL) failed on \"%s\": %s, %s\n", path, strerror(e), replace_dev_result2string(args.result)); - return ret; + return 1; + } + if (args.result == BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED) { + printf("INFO: ioctl(DEV_REPLACE_CANCEL)\"%s\": %s\n", + path, replace_dev_result2string(args.result)); + return 2; } - return 0; }