From mboxrd@z Thu Jan 1 00:00:00 1970 From: Goffredo Baroncelli Subject: [RFC] btrfs: a new tool to manage a btrfs filesystem Date: Fri, 19 Feb 2010 21:12:10 +0100 Message-ID: <201002192112.17752.kreijack@libero.it> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart22224074.T7vGTAjSpL"; protocol="application/pgp-signature"; micalg=pgp-sha1 To: linux-btrfs@vger.kernel.org Return-path: List-ID: --nextPart22224074.T7vGTAjSpL Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi all, on the basis of the suggestion received, I update my btrfs tool. The main changes are: =2D removed the short form of the command (like '-C') =2D deployed the "multi level" command (i.e.: btrfs snapshot create) =2D split the source in three files. This because the new parses are quite = big=20 (about 295 lines; for example btrfsctl.c are only 239 lines). The "multi level" command parser is quite flexible. They accept the full- length command (btrfs subvolume create) and a contract form (btrfs subvol c= r).=20 The commands may be arbitrary shortly (even 1 chars) but they have to be un- ambiguous. For example =2D btrfs s s -> OK (matches 'btrfs subvolume snapshot' only) =2D btrfs dev s -> FAIL (matches both 'btrfs dev show' and=20 '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 command. I am proposing the following structure: =20 btrfs where are:=20 =2D subvolume (valid action: create, delete, snapshot, list [not implemente= d]) =2D filesystem (valid action: defrag, sync, resize [not implemented]) =2D device (valid action: add, delete, scan, show, balance) You can find the source at=20 http://cassiopea.homelinux.net/git/btrfs-command.git (commit 3deec45d18879d60b4032dc1f8895d7b7e1211ec, remember to switch to the= =20 "remotes/origin/multi-level-command" branch (I hate git!!!) BR G.Baroncelli =2D--- $ git diff remotes/origin/orig | diffstat Makefile | 6 btrfs.c | 73 ++++++ btrfs_cmds.c | 587 +++++++++++++++++++++++++++++++++++++++++++[..= =2E] btrfs_cmds.h | 30 ++ btrfs_cmds_parse.c | 296 +++++++++++++++++++++++++ man/Makefile | 5 man/btrfs.8.in | 148 ++++++++++++ 13 files changed, 1291 insertions(+), 2 deletions(-) =2D--- $ ./btrfs Usage: btrfs subvolume snapshot [/] Create a writeble snapshot of the subvolume with the name in the directory. btrfs subvolume delete Delete the subvolume . btrfs subvolume create [/] Create a subvolume in (or the current directory if not passed). btrfs filesystem defrag | [|...] Defragment a file or a directory. btrfs device scan [ [..] Scan all device for or the passed device for a btrfs filesystem. btrfs filesystem sync Force a fs sync on the filesystem btrfs filesystem resize [+/-][gkm]|max Resize the file system. If 'max' is passed, the filesystem will occupe all available space on the device. btrfs device show [|