From 18254b66cf6ff7c9eff605ac7de9b4947d39a96f Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Sat, 16 Jul 2011 11:35:39 +0200 Subject: [PATCH 08/35] Add info for the commands. Add info for every btrfs sub-commands in the sources. --- btrfs_cmds.c | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scrub.c | 79 +++++++++++++++++++ 2 files changed, 316 insertions(+), 0 deletions(-) diff --git a/btrfs_cmds.c b/btrfs_cmds.c index 9252ffa..1bfc669 100644 --- a/btrfs_cmds.c +++ b/btrfs_cmds.c @@ -28,6 +28,7 @@ #include #include #include +#include #undef ULONG_MAX @@ -155,6 +156,42 @@ static int parse_compress_type(char *s) }; } + +/**** man: btrfs filesystem defragment + * + * \Bbtrfs\b \Bfilesystem defragment\b -c[zlib|lzo] [-l \Ilen\i] [-s \Istart\i] [-t \Isize\i] -[vf] <\Ifile\i>|<\Idir\i> [<\Ifile\i>|<\Idir\i>...] + * + * Defragment a file or a directory. + * + * Defragment file data and/or directory metadata. To defragment all files in a + * directory you have to specify each one on its own or use your shell + * wildcards. + * + * The start position and the number of bytes to deframention can be specified + * by \Istart\i and \Ilen\i. Any extent bigger than \Ithresh\i will be + * considered already defragged. Use 0 to take the kernel default, and use 1 + * to say eveery single extent must be rewritten. You can also turn on + * compression in defragment operations. + * + * \B-v\b be verbose + * + * \B-c\b compress file contents while defragmenting + * + * \B-f\b flush filesystem after defragmenting + * + * \B-s start\b defragment only from byte \Istart\i onward + * + * \B-l len\b defragment only up to \Ilen\i bytes + * + * \B-t size\b defragment only files at least \Isize\i bytes big + * + * NOTE: defragmenting with kernels up to 2.6.37 will unlink COW-ed copies of + * data, don't use it if you use snapshots, have de-duplicated your data or + * made copies with + * + * \Bcp --reflink\b. + ****/ + int do_defrag(int ac, char **av) { int fd; @@ -267,6 +304,16 @@ int do_defrag(int ac, char **av) return errors + 20; } + +/**** man: btrfs subvolume find-new + * + * \Bbtrfs\b \Bsubvolume find-new\b\I \i + * + * List the recently modified files in a filesystem. + * + * List the recently modified files in a subvolume, after \I\i ID. + ****/ + int do_find_newer(int argc, char **argv) { int fd; @@ -298,6 +345,25 @@ int do_find_newer(int argc, char **argv) return 0; } + +/**** man: btrfs subvolume list + * + * \Bbtrfs\b \Bsubvolume list\b\I [-p] \i + * + * List the snapshot/subvolume of a filesystem. + * + * List the subvolumes present in the filesystem \I\i. For every + * subvolume the following information is shown by default. + * ID top level path + * where path is the relative path of the subvolume to the \Itop level\i + * subvolume. + * The subvolume's ID may be used by the \Bsubvolume set-default\b command, or + * at mount time via the \Isubvol=\i option. + * If \I-p\i is given, then \Iparent \i is added to the output between ID + * and top level. The parent's ID may be used at mount time via the + * \Isubvolrootid=\i option. + ****/ + int do_subvol_list(int argc, char **argv) { int fd; @@ -345,6 +411,20 @@ int do_subvol_list(int argc, char **argv) return 0; } + +/**** man: btrfs subvolume snapshot + * + * \Bbtrfs\b \Bsubvolume snapshot\b\I [-r] [/]\i + * + * Create a writable/readonly snapshot of the subvolume with + * the name in the directory. + * + * Create a writable/readonly snapshot of the subvolume \I\i with the + * name \I\i in the \I\i directory. If \I\i is not a + * subvolume, \Bbtrfs\b returns an error. If \I-r\i is given, the snapshot + * will be readonly. + ****/ + int do_clone(int argc, char **argv) { char *subvol, *dst; @@ -463,6 +543,17 @@ int do_clone(int argc, char **argv) } + +/**** man: btrfs subvolume delete + * + * \Bbtrfs\b \Bsubvolume delete\b\I \i + * + * Delete the subvolume . + * + * Delete the subvolume \I\i. If \I\i is not a + * subvolume, \Bbtrfs\b returns an error. + ****/ + int do_delete_subvolume(int argc, char **argv) { int res, fd, len, e; @@ -525,6 +616,18 @@ int do_delete_subvolume(int argc, char **argv) } + +/**** man: btrfs subvolume create + * + * \Bbtrfs\b \Bsubvolume create\b\I [/]\i + * + * Create a subvolume in (or the current directory if + * not passed). + * + * Create a subvolume in \I\i (or in the current directory if + * \I\i is omitted). + ****/ + int do_create_subvol(int argc, char **argv) { int res, fddst, len, e; @@ -581,6 +684,16 @@ int do_create_subvol(int argc, char **argv) } + +/**** man: btrfs filesystem sync + * + * \Bbtrfs\b \Bfilesystem sync\b\I \i + * + * Force a sync on the filesystem . + * + * Force a sync for the filesystem identified by \I\i. + ****/ + int do_fssync(int argc, char **argv) { int fd, res, e; @@ -605,6 +718,21 @@ int do_fssync(int argc, char **argv) return 0; } + +/**** man: btrfs device scan + * + * \Bbtrfs\b \Bdevice scan\b \I[--all-devices| [...]\i + * + * Scan all device for or the passed device for a btrfs + * filesystem. + * + * If one or more devices are passed, these are scanned for a btrfs filesystem. + * If no devices are passed, \Bbtrfs\b scans all the block devices listed + * in the /proc/partitions file. + * Finally, if \B--all-devices\b is passed, all the devices under /dev are + * scanned. + ****/ + int do_scan(int argc, char **argv) { int i, fd, e; @@ -672,6 +800,32 @@ int do_scan(int argc, char **argv) } + +/**** man: btrfs filesystem resize + * + * \Bbtrfs\b \Bfilesystem resize\b\I [+/\-][gkm]|max \i + * + * Resize the file system. If 'max' is passed, the filesystem + * will occupe all available space on the device. + * + * Resize a filesystem identified by \I\i. + * The \I\i parameter specifies the new size of the filesystem. + * If the prefix \I+\i or \I\-\i is present the size is increased or decreased + * by the quantity \I\i. + * If no units are specified, the unit of the \I\i parameter defaults to + * bytes. Optionally, the size parameter may be suffixed by one of the following + * the units designators: 'K', 'M', or 'G', kilobytes, megabytes, or gigabytes, + * respectively. + * + * If 'max' is passed, the filesystem will occupy all available space on the + * volume(s). + * + * The \Bresize\b command \Bdoes not\b manipulate the size of underlying + * partition. If you wish to enlarge/reduce a filesystem, you must make sure + * you can expand the partition before enlarging the filesystem and shrink the + * partition after reducing the size of the filesystem. + ****/ + int do_resize(int argc, char **argv) { @@ -762,6 +916,20 @@ static void print_one_uuid(struct btrfs_fs_devices *fs_devices) printf("\n"); } + +/**** man: btrfs filesystem show + * + * \Bbtrfs\b \Bfilesystem show\b [--all-devices||