From patchwork Sun Dec 13 18:50:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goffredo Baroncelli X-Patchwork-Id: 67037 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBDIoY6S026555 for ; Sun, 13 Dec 2009 18:50:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbZLMSuO (ORCPT ); Sun, 13 Dec 2009 13:50:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753182AbZLMSuN (ORCPT ); Sun, 13 Dec 2009 13:50:13 -0500 Received: from fg-out-1718.google.com ([72.14.220.157]:61329 "HELO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752950AbZLMSuL (ORCPT ); Sun, 13 Dec 2009 13:50:11 -0500 Received: by fg-out-1718.google.com with SMTP id 19so1143534fgg.1 for ; Sun, 13 Dec 2009 10:50:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=QCLoHrI8qDrxCBclNF6PpXYBOW0X99MAwh6wbymU3yQ=; b=PH1NQ3BLnGoYXMkLyuuCwGpQfT8HpOmO6WG5McGA9D9vBZzGXEMoWw/yuwWoVlkz02 edYPOzyeTQ2odCUuqRBupgqohcAJLJK8LvKeb6hAkzED1fJ/s/xP0o1Lab7bZnJtqKs+ pualNX6/mRtq9c3FspjGryxMcsiY8tCEjtQek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:references:in-reply-to:mime-version :content-type:content-transfer-encoding:message-id; b=myDtyMQUQBOUAouBRI9y4s/QciaL6tqCM3uhC6aNWSPDjPW0SSo8kYmB7UiDwjqxvs VzL7IiSb+wLCnio8m8BuvTRDKQI1BF8wuwtKImZJG13L5Upl1EzAekKSyTU9GYq+7dBe iZfVVWuZaefKBLniZZap0QuXokMX1UrBnXMmk= Received: by 10.86.198.22 with SMTP id v22mr4742515fgf.40.1260730209446; Sun, 13 Dec 2009 10:50:09 -0800 (PST) Received: from venice.localnet (host149-218-dynamic.11-87-r.retail.telecomitalia.it [87.11.218.149]) by mx.google.com with ESMTPS id e11sm8372677fga.29.2009.12.13.10.50.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 13 Dec 2009 10:50:07 -0800 (PST) From: Goffredo Baroncelli To: linux-btrfs@vger.kernel.org Subject: [PATCH] Improve the btrfsctl help Date: Sun, 13 Dec 2009 19:50:03 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.31-17-generic; KDE/4.3.2; x86_64; ; ) References: <200912121639.41192.kreijack@libero.it> <9bd6b5360912130005m2bf7993ar7df5244945504534@mail.gmail.com> <200912131239.06192.kreijack@libero.it> In-Reply-To: <200912131239.06192.kreijack@libero.it> MIME-Version: 1.0 Message-Id: <200912131950.09622.kreijack@libero.it> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/btrfsctl.c b/btrfsctl.c index 66c4e89..dd0de48 100644 --- a/btrfsctl.c +++ b/btrfsctl.c @@ -45,17 +45,21 @@ static inline int ioctl(int fd, int define, void *arg) { return 0; } static void print_usage(void) { - printf("usage: btrfsctl [ -d file|dir] [ -s snap_name subvol|tree ]\n"); - printf(" [-r size] [-A device] [-a] [-c] [-D dir .]\n"); - printf("\t-d filename: defragments one file\n"); - printf("\t-d directory: defragments the entire Btree\n"); - printf("\t-s snap_name dir: creates a new snapshot of dir\n"); - printf("\t-S subvol_name dir: creates a new subvolume\n"); - printf("\t-r [+-]size[gkm]: resize the FS by size amount\n"); - printf("\t-A device: scans the device file for a Btrfs filesystem\n"); - printf("\t-a: scans all devices for Btrfs filesystems\n"); - printf("\t-c: forces a single FS sync\n"); - printf("\t-D: delete snapshot\n"); + printf("usage: btrfsctl [-d file|directory] [-s snap_name subvol]\n"); + printf(" [-S vol_name directory] [-a] [-r size tree]\n"); + printf(" [-A device] [-c tree] [-D name directory]\n"); + printf("\t-d filename: defragments one file.\n"); + printf("\t-d directory: defragments the entire Btree.\n"); + printf("\t-s snap_name subvol: creates a new snapshot of subvol.\n"); + printf("\t-S subvol_name directory: creates a new subvolume in directory.\n"); + printf("\t-a: scans all devices for Btrfs filesystems.\n"); + printf("\t-r [revid:][+-]size[kmg] tree\n"); + printf("\t resize the FS by size amount (pass 'max'\n"); + printf("\t to resize up to device size).'revid' is\n"); + printf("\t the device-id to resize: default is 1.\n"); + printf("\t-A device: scans the device file for a Btrfs filesystem.\n"); + printf("\t-c tree: forces a single FS sync.\n"); + printf("\t-D name directory: delete a snapshot or subvolume in directory.\n"); printf("%s\n", BTRFS_BUILD_VERSION); exit(1); } @@ -110,7 +114,7 @@ int main(int ac, char **av) for (i = 1; i < ac; i++) { if (strcmp(av[i], "-s") == 0) { if (i + 1 >= ac - 1) { - fprintf(stderr, "-s requires an arg"); + fprintf(stderr, "-s requires two args\n"); print_usage(); } fullpath = av[i + 1]; @@ -137,14 +141,14 @@ int main(int ac, char **av) command = BTRFS_IOC_SNAP_CREATE; } else if (strcmp(av[i], "-S") == 0) { if (i + 1 >= ac - 1) { - fprintf(stderr, "-S requires an arg"); + fprintf(stderr, "-S requires two args\n"); print_usage(); } name = av[i + 1]; len = strlen(name); if (len == 0 || len >= BTRFS_VOL_NAME_MAX) { fprintf(stderr, - "snapshot name zero length or too long\n"); + "volume name zero length or too long\n"); exit(1); } if (strchr(name, '/')) { @@ -160,15 +164,16 @@ int main(int ac, char **av) } command = BTRFS_IOC_DEFRAG; } else if (strcmp(av[i], "-D") == 0) { - if (i >= ac - 1) { - fprintf(stderr, "-D requires an arg\n"); + if (i + 1 >= ac - 1) { + fprintf(stderr, "-D requires two args\n"); print_usage(); } command = BTRFS_IOC_SNAP_DESTROY; name = av[i + 1]; len = strlen(name); if (len == 0 || len >= BTRFS_VOL_NAME_MAX) { - fprintf(stderr, "-D size too long\n"); + fprintf(stderr, + "volume name zero length or too long\n"); exit(1); } } else if (strcmp(av[i], "-A") == 0) { @@ -178,18 +183,23 @@ int main(int ac, char **av) } command = BTRFS_IOC_SCAN_DEV; } else if (strcmp(av[i], "-r") == 0) { - if (i >= ac - 1) { - fprintf(stderr, "-r requires an arg\n"); + if (i+1 >= ac - 1) { + fprintf(stderr, "-r requires two args\n"); print_usage(); } name = av[i + 1]; len = strlen(name); if (len == 0 || len >= BTRFS_VOL_NAME_MAX) { - fprintf(stderr, "-r size too long\n"); + fprintf(stderr, + "-r argument zero length or too long\n"); exit(1); } command = BTRFS_IOC_RESIZE; } else if (strcmp(av[i], "-c") == 0) { + if (i >= ac - 1) { + fprintf(stderr, "-c requires an arg\n"); + print_usage(); + } command = BTRFS_IOC_SYNC; } } diff --git a/man/btrfsctl.8.in b/man/btrfsctl.8.in index c2d4488..b645429 100644 --- a/man/btrfsctl.8.in +++ b/man/btrfsctl.8.in @@ -4,12 +4,13 @@ btrfsctl \- control a btrfs filesystem .SH SYNOPSIS .B btrfsctl [ \fB\-d\fP\fI file|directory \fP ] -[ \fB\-s\fP\fI snapshot-name directory\fP ] +[ \fB\-s\fP\fI snapshot-name subvolume\fP ] [ \fB \-S\fP\fI subvolume-name directory\fP ] -[ \fB \-r\fP\fI [+-]size\fP ] +[ \fB \-r\fP\fI [devid:][+-]size[kmg]\fP tree] [ \fB \-A\fP\fI device\fP ] [ \fB \-a\fP ] -[ \fB \-c\fP ] +[ \fB \-c\fP tree] +[ \fB \-D\fP\fI subvolume-name directory\fP ] .SH DESCRIPTION .B btrfsctl is used to control the filesystem and the files and directories stored. It is the tool to