From: Goffredo Baroncelli <kreijack@gmail.com>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: Chris Mason <chris.mason@fusionio.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
Goffredo Baroncelli <kreijack@inwind.it>
Subject: Re: [PATCH 1/2] Update btrfs filesystem df command
Date: Wed, 03 Oct 2012 18:34:38 +0200 [thread overview]
Message-ID: <506C691E.6020506@gmail.com> (raw)
In-Reply-To: <20121003150219.GB1978@zambezi.lan>
On 10/03/2012 05:02 PM, Ilya Dryomov wrote:
> On Wed, Oct 03, 2012 at 01:43:15PM +0200, Goffredo Baroncelli wrote:
>> The command btrfs filesystem df is used to query the
>> status of the chunks, how many space on the disk(s) are used by
>> the chunks, how many space are available in the chunks, and an
>> estimation of the free space of the filesystem.
>> ---
>> cmds-filesystem.c | 264 +++++++++++++++++++++++++++++++++++++++++++----------
>> 1 file changed, 215 insertions(+), 49 deletions(-)
>>
>> diff --git a/cmds-filesystem.c b/cmds-filesystem.c
>> index b1457de..6c3ebdc 100644
>> --- a/cmds-filesystem.c
>> +++ b/cmds-filesystem.c
>
> (snipped)
>
>> +static int cmd_disk_free(int argc, char **argv)
>> +{
>> +
>> + int flags=DF_SHOW_SUMMARY|DF_SHOW_DETAIL|DF_HUMAN_UNIT;
>> + int i, more_than_one=0;
>> +
>> + if (check_argc_min(argc, 2))
>> + usage(cmd_disk_free_usage);
>> +
>> + for(i=1; i< argc ; i++){
>> + if(!strcmp(argv[i],"-d"))
>> + flags&= ~DF_SHOW_DETAIL;
>> + else if(!strcmp(argv[i],"-s"))
>> + flags&= ~DF_SHOW_SUMMARY;
>> + else if(!strcmp(argv[i],"-k"))
>> + flags&= ~DF_HUMAN_UNIT;
>> + else{
>> + int r;
>> + if(more_than_one)
>> + printf("\n");
>> + r = _cmd_disk_free(argv[i], flags);
>> + if( r ) return r;
>> + more_than_one=1;
>> + }
>
> Is there any reason getopt(), or better yet, getopt_long() won't work?
In the beginning there were also the switches +d, +s, +k, then I dropped
them. So I leaved this style. The code is simple enough to not justify a
change.
>
>> +
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +
>> +
>> static int uuid_search(struct btrfs_fs_devices *fs_devices, char *search)
>> {
>> char uuidbuf[37];
>> @@ -529,7 +695,7 @@ static int cmd_label(int argc, char **argv)
>>
>> const struct cmd_group filesystem_cmd_group = {
>> filesystem_cmd_group_usage, NULL, {
>> - { "df", cmd_df, cmd_df_usage, NULL, 0 },
>> + { "df", cmd_disk_free, cmd_disk_free_usage, NULL, 0 },
>
> If this command is going to replace df, you should change the function
> name back to cmd_df.
I was never convinced to use 'df'. At the beginning when I wrote the
first parser of btrfs, was suggested (not by me) to use "long" command
and allow the parser to match a contracted command until there was any
ambiguity. I suggested to use disk-free, but everybody were confortable
with df.. so I leaved it as "official name". But I prefer for the
internal code a more verbose name.
>
> Thanks,
Thanks you for your review.
>
> Ilya
>
next prev parent reply other threads:[~2012-10-03 16:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-03 11:43 [PATCH][BTRFS-PROGS][V1] btrfs filesystem df Goffredo Baroncelli
2012-10-03 11:43 ` [PATCH 1/2] Update btrfs filesystem df command Goffredo Baroncelli
2012-10-03 15:02 ` Ilya Dryomov
2012-10-03 16:34 ` Goffredo Baroncelli [this message]
2012-10-03 17:20 ` Ilya Dryomov
2012-10-03 17:38 ` Goffredo Baroncelli
2012-10-03 17:09 ` Goffredo Baroncelli
2012-10-03 11:43 ` [PATCH 2/2] Update help page Goffredo Baroncelli
2012-10-03 11:56 ` [PATCH][BTRFS-PROGS][V1] btrfs filesystem df Hugo Mills
2012-10-03 16:17 ` Goffredo Baroncelli
2012-10-03 16:34 ` Hugo Mills
2012-10-09 9:43 ` Bart Noordervliet
2012-10-09 11:38 ` Goffredo Baroncelli
2012-10-09 12:51 ` Bart Noordervliet
2012-10-09 18:22 ` Goffredo Baroncelli
2012-10-12 9:42 ` Martin Steigerwald
2012-10-03 15:01 ` Ilya Dryomov
2012-10-03 16:46 ` Goffredo Baroncelli
2012-10-03 17:46 ` Ilya Dryomov
2012-10-03 20:01 ` Goffredo Baroncelli
2012-10-03 20:24 ` Ilya Dryomov
2012-10-12 10:01 ` Martin Steigerwald
2012-10-12 9:55 ` Martin Steigerwald
-- strict thread matches above, loose matches on Subject: below --
2012-10-03 17:22 [PATCH][BTRFS-PROGS][V2] " Goffredo Baroncelli
2012-10-03 17:22 ` [PATCH 1/2] Update btrfs filesystem df command Goffredo Baroncelli
2012-10-03 20:34 ` Ilya Dryomov
2012-10-03 20:38 ` Hugo Mills
2012-10-03 20:43 ` Ilya Dryomov
2012-10-03 20:53 ` Goffredo Baroncelli
2012-10-04 17:27 [PATCH][BTRFS-PROGS][V3] btrfs filesystem df Goffredo Baroncelli
2012-10-04 17:27 ` [PATCH 1/2] Update btrfs filesystem df command Goffredo Baroncelli
2012-10-13 17:47 [PATCH][BTRFS-PROGS][V4] btrfs filesystem df Goffredo Baroncelli
2012-10-13 17:47 ` [PATCH 1/2] Update btrfs filesystem df command Goffredo Baroncelli
2012-10-13 19:14 [PATCH][BTRFS-PROGS][V6] btrfs filesystem df Goffredo Baroncelli
2012-10-13 19:14 ` [PATCH 1/2] Update btrfs filesystem df command Goffredo Baroncelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=506C691E.6020506@gmail.com \
--to=kreijack@gmail.com \
--cc=chris.mason@fusionio.com \
--cc=idryomov@gmail.com \
--cc=kreijack@inwind.it \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.