From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Fedyk Subject: Re: [RFC] btrfs: a new tool to manage a btrfs filesystem Date: Fri, 19 Feb 2010 13:16:24 -0800 Message-ID: <93cdabd21002191316r7f65a031veb943045dca82c14@mail.gmail.com> References: <201002192112.17752.kreijack@libero.it> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: linux-btrfs@vger.kernel.org To: Goffredo Baroncelli Return-path: In-Reply-To: <201002192112.17752.kreijack@libero.it> List-ID: On Fri, Feb 19, 2010 at 12:12 PM, Goffredo Baroncelli wrote: > Hi all, > > on the basis of the suggestion received, I update my btrfs tool. > > The main changes are: > - removed the short form of the command (like '-C') > - deployed the "multi level" command (i.e.: btrfs snapshot create) > - split the source in three files. This because the new parses are qu= ite big > (about =C2=A0295 lines; for example btrfsctl.c are only 239 lines). > > The "multi level" command parser is quite flexible. They accept the f= ull- > length command (btrfs subvolume create) and a contract form (btrfs su= bvol cr). > The commands may be arbitrary shortly (even 1 chars) but they have to= be un- > ambiguous. For example > - btrfs s s =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -> OK (matches = 'btrfs subvolume snapshot' only) > - btrfs dev s =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -> FAIL (matches bot= h 'btrfs dev show' and > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'btrfs dev scan') > > The parser highlights which part of the command are ambiguous. > > This is a RFC because there is no agreement about the name of the com= mand. > I am proposing the following structure: > > =C2=A0 btrfs > > where are: > - subvolume (valid action: create, delete, snapshot, list [not implem= ented]) > - filesystem (valid action: defrag, sync, resize [not implemented]) > - device (valid action: add, delete, scan, show, balance) > > You can find the source at > > =C2=A0 =C2=A0 =C2=A0 =C2=A0http://cassiopea.homelinux.net/git/btrfs-c= ommand.git > > (commit 3deec45d18879d60b4032dc1f8895d7b7e1211ec, remember to switch = to the > "remotes/origin/multi-level-command" branch (I hate git!!!) > > > BR > G.Baroncelli > ---- > > $ git diff remotes/origin/orig | diffstat > =C2=A0Makefile =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2= =A06 > =C2=A0btrfs.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0= 73 ++++++ > =C2=A0btrfs_cmds.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0587 ++++++++++= +++++++++++++++++++++++++++++++++[...] > =C2=A0btrfs_cmds.h =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 30 ++ > =C2=A0btrfs_cmds_parse.c =C2=A0 | =C2=A0296 +++++++++++++++++++++++++ > =C2=A0man/Makefile =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A05 > =C2=A0man/btrfs.8.in =C2=A0 =C2=A0 =C2=A0 | =C2=A0148 ++++++++++++ > =C2=A013 files changed, 1291 insertions(+), 2 deletions(-) > > ---- > $ ./btrfs > Usage: > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs subvolume snapshot [/] > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Create a write= ble snapshot of the subvolume with > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0the name in the directory. > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs subvolume delete > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Delete the sub= volume . > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs subvolume create [/] > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Create a subvo= lume in (or the current directory if > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0not passed). > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs filesystem defrag | [|...] > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Defragment a f= ile or a directory. > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs device scan [ [..] > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Scan all devic= e for or the passed device for a btrfs > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0filesystem. > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs filesystem sync > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Force a fs syn= c on the filesystem > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs filesystem resize [+/-][gkm= ]|max > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Resize the fil= e system. If 'max' is passed, the filesystem > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0will occupe al= l available space on the device. > =C2=A0 =C2=A0 =C2=A0 =C2=A0btrfs device show [|