From patchwork Mon Mar 4 22:40:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2214681 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 E106DDF2F2 for ; Mon, 4 Mar 2013 21:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932623Ab3CDVkf (ORCPT ); Mon, 4 Mar 2013 16:40:35 -0500 Received: from nat-pool-rdu.redhat.com ([66.187.233.202]:24081 "EHLO bp-05.lab.msp.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932576Ab3CDVkd (ORCPT ); Mon, 4 Mar 2013 16:40:33 -0500 Received: by bp-05.lab.msp.redhat.com (Postfix, from userid 0) id 4E35F1E0AB7; Mon, 4 Mar 2013 16:40:08 -0600 (CST) From: Eric Sandeen To: linux-btrfs@vger.kernel.org Cc: Eric Sandeen Subject: [PATCH 13/14] btrfs-progs: better option/error handling for btrfs-vol Date: Mon, 4 Mar 2013 16:40:03 -0600 Message-Id: <1362436804-16766-14-git-send-email-sandeen@redhat.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1362436804-16766-1-git-send-email-sandeen@redhat.com> References: <1362436804-16766-1-git-send-email-sandeen@redhat.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Today wrong cmdlines give odd results: # ./btrfs-vol /dev/sdb1 Unable to open device (null) # ./btrfs-vol -a /dev/sdb1 usage: btrfs-vol [options] mount_point ... Make it a bit more informative: # ./btrfs-vol /dev/sdb1 No command specified usage: btrfs-vol [options] mount_point ... # ./btrfs-vol -a /dev/sdb1 No mountpoint specified usage: btrfs-vol [options] mount_point ... (even though it's deprecated ...) Signed-off-by: Eric Sandeen --- btrfs-vol.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/btrfs-vol.c b/btrfs-vol.c index 3cc1c32..e37b41a 100644 --- a/btrfs-vol.c +++ b/btrfs-vol.c @@ -106,8 +106,13 @@ int main(int ac, char **av) } } ac = ac - optind; - if (ac == 0) + if (ac == 0 || !cmd) { + if (!ac) + fprintf(stderr, "No mountpoint specified\n"); + else + fprintf(stderr, "No command specified\n"); print_usage(); + } mnt = av[optind]; if (device && strcmp(device, "missing") == 0 &&