* [PATCH][TRIVIAL] Improve the btrfsctl help @ 2009-12-12 15:39 Goffredo Baroncelli 2009-12-13 8:05 ` sniper 0 siblings, 1 reply; 4+ messages in thread From: Goffredo Baroncelli @ 2009-12-12 15:39 UTC (permalink / raw) To: linux-btrfs [-- Attachment #1: Type: text/plain, Size: 3677 bytes --] Hi all, I found the help of the btrfctl command very poor. I rewrite some help messages and correct (or added when needed) the check of the number of parameter. Please apply. * Improve/correct the check of the arguments number * Revise the command help --- btrfsctl.c | 33 +++++++++++++++++++-------------- 1 files changed, 19 insertions(+), 14 deletions(-) diff --git a/btrfsctl.c b/btrfsctl.c index 66c4e89..0e5ce79 100644 --- a/btrfsctl.c +++ b/btrfsctl.c @@ -45,17 +45,18 @@ 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("usage: btrfsctl [-d file|dir] [-s snap_name subvol]\n"); + printf(" [-S vol_name dir] [-a] [-r size subvol]\n"); + printf(" [-A device] [-c subvol] [-D name subvol]\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-s snap_name subvol: creates a new snapshot of subvol\n"); + printf("\t-S subvol_name dir: creates a new subvolume in dir\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("\t-r [+-]size[gkm] subvol: resize the FS by size amount\n"); + printf("\t-A device: scans the device file for a Btrfs filesystem\n"); + printf("\t-c subvol: forces a single FS sync\n"); + printf("\t-D name dir: delete a snapshot or subvolume of dir\n"); printf("%s\n", BTRFS_BUILD_VERSION); exit(1); } @@ -110,7 +111,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,7 +138,7 @@ 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]; @@ -160,8 +161,8 @@ 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; @@ -178,8 +179,8 @@ 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]; @@ -190,6 +191,10 @@ int main(int ac, char **av) } 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; } } -- gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][TRIVIAL] Improve the btrfsctl help 2009-12-12 15:39 [PATCH][TRIVIAL] Improve the btrfsctl help Goffredo Baroncelli @ 2009-12-13 8:05 ` sniper 2009-12-13 11:38 ` Goffredo Baroncelli 0 siblings, 1 reply; 4+ messages in thread From: sniper @ 2009-12-13 8:05 UTC (permalink / raw) To: Goffredo Baroncelli; +Cc: linux-btrfs 2009/12/12 Goffredo Baroncelli <kreijack@gmail.com>: > Hi all, > > I found the help of the btrfctl command very poor. I rewrite some hel= p > messages and correct (or added when needed) the check of the number o= f > parameter. > > Please apply. > > > * Improve/correct the check of the arguments number > * Revise the command help > --- > =C2=A0btrfsctl.c | =C2=A0 33 +++++++++++++++++++-------------- > =C2=A01 files changed, 19 insertions(+), 14 deletions(-) > > diff --git a/btrfsctl.c b/btrfsctl.c > index 66c4e89..0e5ce79 100644 > --- a/btrfsctl.c > +++ b/btrfsctl.c > @@ -45,17 +45,18 @@ static inline int ioctl(int fd, int define, void = *arg) { > return 0; } > > =C2=A0static void print_usage(void) > =C2=A0{ > - =C2=A0 =C2=A0 =C2=A0 printf("usage: btrfsctl [ -d file|dir] [ -s sn= ap_name subvol|tree ]\n"); > - =C2=A0 =C2=A0 =C2=A0 printf(" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0[-r size] [-A device] [-a] [-c] [-D dir .]\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("usage: btrfsctl [-d file|dir] [-s snap= _name subvol]\n"); > + =C2=A0 =C2=A0 =C2=A0 printf(" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0[-S vol_name dir] [-a] [-r size subvol]\n"); > + =C2=A0 =C2=A0 =C2=A0 printf(" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0[-A device] [-c subvol] [-D name subvol]\n"); > =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("\t-d filename: defragments one fil= e\n"); > =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("\t-d directory: defragments the en= tire Btree\n"); > - =C2=A0 =C2=A0 =C2=A0 printf("\t-s snap_name dir: creates a new snap= shot of dir\n"); > - =C2=A0 =C2=A0 =C2=A0 printf("\t-S subvol_name dir: creates a new su= bvolume\n"); > - =C2=A0 =C2=A0 =C2=A0 printf("\t-r [+-]size[gkm]: resize the FS by s= ize amount\n"); > - =C2=A0 =C2=A0 =C2=A0 printf("\t-A device: scans the device file for= a Btrfs filesystem\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("\t-s snap_name subvol: creates a new s= napshot of subvol\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("\t-S subvol_name dir: creates a new su= bvolume in dir\n"); > =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("\t-a: scans all devices for Btrfs = filesystems\n"); > - =C2=A0 =C2=A0 =C2=A0 printf("\t-c: forces a single FS sync\n"); > - =C2=A0 =C2=A0 =C2=A0 printf("\t-D: delete snapshot\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("\t-r [+-]size[gkm] subvol: resize the = =46S by size amount\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("\t-A device: scans the device file for= a Btrfs filesystem\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("\t-c subvol: forces a single FS sync\n= "); > + =C2=A0 =C2=A0 =C2=A0 printf("\t-D name dir: delete a snapshot or su= bvolume of dir\n"); Hi, should it be "delete a snapshot or subvolume _in_ dir"? I notice that I can only snapshot for a whole device but not a dir, and the snapshot file can be moved to other place after created. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][TRIVIAL] Improve the btrfsctl help 2009-12-13 8:05 ` sniper @ 2009-12-13 11:38 ` Goffredo Baroncelli 2009-12-13 18:50 ` [PATCH] " Goffredo Baroncelli 0 siblings, 1 reply; 4+ messages in thread From: Goffredo Baroncelli @ 2009-12-13 11:38 UTC (permalink / raw) To: linux-btrfs [-- Attachment #1: Type: Text/Plain, Size: 3727 bytes --] On Sunday 13 December 2009, sniper wrote: > 2009/12/12 Goffredo Baroncelli <kreijack@gmail.com>: > > Hi all, [...] > > + printf("\t-D name dir: delete a snapshot or subvolume of dir\n"); > > Hi, should it be "delete a snapshot or subvolume _in_ dir"? > Right, Patch updated BR Goffredo -- gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512 --- btrfsctl.c | 33 +++++++++++++++++++-------------- 1 files changed, 19 insertions(+), 14 deletions(-) diff --git a/btrfsctl.c b/btrfsctl.c index 66c4e89..6f6e8e6 100644 --- a/btrfsctl.c +++ b/btrfsctl.c @@ -45,17 +45,18 @@ 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("usage: btrfsctl [-d file|dir] [-s snap_name subvol]\n"); + printf(" [-S vol_name dir] [-a] [-r size subvol]\n"); + printf(" [-A device] [-c subvol] [-D name subvol]\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-s snap_name subvol: creates a new snapshot of subvol\n"); + printf("\t-S subvol_name dir: creates a new subvolume in dir\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("\t-r [+-]size[gkm] subvol: resize the FS by size amount\n"); + printf("\t-A device: scans the device file for a Btrfs filesystem\n"); + printf("\t-c subvol: forces a single FS sync\n"); + printf("\t-D name dir: delete a snapshot or subvolume in dir\n"); printf("%s\n", BTRFS_BUILD_VERSION); exit(1); } @@ -110,7 +111,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,7 +138,7 @@ 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]; @@ -160,8 +161,8 @@ 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; @@ -178,8 +179,8 @@ 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]; @@ -190,6 +191,10 @@ int main(int ac, char **av) } 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; } } [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Improve the btrfsctl help 2009-12-13 11:38 ` Goffredo Baroncelli @ 2009-12-13 18:50 ` Goffredo Baroncelli 0 siblings, 0 replies; 4+ messages in thread From: Goffredo Baroncelli @ 2009-12-13 18:50 UTC (permalink / raw) To: linux-btrfs [-- Attachment #1: Type: Text/Plain, Size: 7586 bytes --] Hi all, another update: - improved the help - better check of the number of the parameter - added useful info about the '-r' command - update the man page also comments are welcome. BR Goffredo -- 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 create a new snapshot for the filesystem. @@ -18,14 +19,21 @@ is used to control the filesystem and the files and directories stored. It is th \fB\-d\fR \fIfile|directory\fR Defragment a file or a directory. If the argument is a directory, the entire b-tree under the directory is defragged. .TP -\fB\-s\fR \fIsnapshot-name directory\fR -Creates a new \fIsnapshot\fP of the \fIdirectory\fP specified. +\fB\-s\fR \fIsnapshot-name subvolume\fR +Creates a new \fIsnapshot\fP of the \fIsubvolume\fP specified. In the +\fIsnapshot-name\fP may be specify the path where the snapshot will be placed. +\fIsubvolume\fP may be specified with any file or directory of the subvolume. .TP \fB\-S\fR \fIsubvolume-name directory\fR -Creates a new subvolume. +Creates a new \fIsubvolume\fP in the \fIdirectory\fP specified. .TP -\fB\-r\fR \fI[+|-]size\fR -Resizes the filesystem with the \fIsize\fP specified. If the value is preceded with a signed symbol, the filesystem is resized with respect to the current filesystem size. \fIsize\fP can be suffixed by k,m or g to represent kilobytes, megabytes, or gigabytes respectively. +\fB\-r\fR \fI[devid:][+|-]size[kmg] tree\fR +Resizes the filesystem with the \fIsize\fP specified. If the value is preceded +with a signed symbol, the filesystem is resized with respect to the current +filesystem size. \fIsize\fP can be suffixed by k,m or g to represent kilobytes, +megabytes, or gigabytes respectively. For a multi-device filesystem the +\fIdevid\fP parameter specify which device has to be resize (default 1). +\fItree\fP may be any element of the filesystem involved. .TP \fB\-A\fR \fIdevice\fR Scans the \fIdevice\fR for btrfs filesystem. @@ -33,8 +41,12 @@ Scans the \fIdevice\fR for btrfs filesystem. \fB\-a\fR Scans all devices present in the system for btrfs filesystem. .TP -\fB\-c\fR -Forces a filesystem sync. +\fB\-c\fR \fItree\fR +Forces a filesystem sync. \fItree\fP may be any element of the filesystem +involved. +.TP +\fB\-D\fR \fIsubvolume-name directory\fR +Delete a subvolume in the directory specified. .SH AVAILABILITY .B btrfsctl is part of btrfs-progs. Btrfs is currently under heavy development, -- gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-13 18:50 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-12 15:39 [PATCH][TRIVIAL] Improve the btrfsctl help Goffredo Baroncelli 2009-12-13 8:05 ` sniper 2009-12-13 11:38 ` Goffredo Baroncelli 2009-12-13 18:50 ` [PATCH] " Goffredo Baroncelli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox