Preparatory work to support more global options. The current parser
abuses the subcommand table to understand help and version when
specified as options (--). These are now special case when processing
the global options.
Signed-off-by: David Sterba <dsterba@suse.com>
We use pointer of argc and argv in handle_options() because they
are necessary in very old code which are not exist now.
This patch move to use argc and argv directly in handle_options(),
alone with following update:
1: rename handle_options() to check_options()
to fit its function.
2: cleanup for condition in handle_options() to make line short.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Adding a btrfs_close_all_devices() after command callback in btrfs.c
can force-close all opened device before program exit, to avoid memory leak
in all btrfs sub-command.
Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Running 'btrfs' without arguments will print complete help that spans
a lot of lines and is really helpful. Print only subcommand group
names with short descriptions, similar to what 'git' does.
Signed-off-by: David Sterba <dsterba@suse.cz>
- use standard PACKAGE_{NAME,VERSION,STRING,URL,...} autoconf macros
rather than homemade BTRFS_BUILD_VERSION
- don't #include version.h, now the file is necessary for library API only
Note that "btrfs version" returns "btrfs-progs <version>" instead of
the original confusing "btrfs <version>".
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
glibc 2.10+ (5+ years old) enables all the desired features:
_XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a
single _GNU_SOURCE define in the makefile alone. For portability to
other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also
defined.
This also resolves Debian bug report filed by Michael Tautschnig -
"Inconsistent use of _XOPEN_SOURCE results in conflicting
declarations". Whilst I was not able to reproduce the results, the
reported fact is that _XOPEN_SOURCE set to 500 in one set of files
(e.g. cmds-filesystem.c) generates/defines different struct stat from
other files (cmds-replace.c).
This patch thus cleans up all feature defines, and sets them at a
consistent level.
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
To let the independent tools(e.g. btrfs-image, btrfs-convert, etc.)
share the convenience of check_argc_* functions, just move it into
utils.c.
Also add a new function "set_argv0" to set the correct tool name:
*btrfs-image*: too few arguments
The original btrfs* tools work as before.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
[moved argv0 and check_argc to utils.*]
Signed-off-by: David Sterba <dsterba@suse.cz>
Just cleanup: remove useless return type, while loop and dead code.
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
"btrfs filesystem property" is a generic interface to set/get
properties on filesystem objects (inodes/subvolumes/filesystems
/devs).
This patch adds the generic framework for properties and also
implements two properties. The first is the read-only property
for subvolumes and the second is the label property for devices.
Signed-off-by: Alexander Block <ablock84@googlemail.com>
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Add an empty 1st level command namespace that will collect specialized
recovery tools like chunk-recover, zero-log, select-super and similar.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
These were mostly in option structs but there were a few gross string
pointer arguments given as 0.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Mark many functions as static, and remove any resulting dead code.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Update the usage strings of some cmds to keep the them consistent with
the source.
Also some minor changes are done to fit the man page syntax.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Add chunk-recover program to check or rebuild chunk tree when the system
chunk array or chunk tree is broken.
Due to the importance of the system chunk array and chunk tree, if one of
them is broken, the whole btrfs will be broken even other data are OK.
But we have some hint(fsid, checksum...) to salvage the old metadata.
So this function will first scan the whole file system and collect the
needed data(chunk/block group/dev extent), and check for the references
between them. If the references are OK, the chunk tree can be rebuilt and
luckily the file system will be mountable.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Add 'btrfs restore' command which previously existed as a separate
utility btrfs-restore.
Signed-off-by: Ian Kumlien <pomac@demius.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
This patch adds a busybox-style name detection for the name "btrfsck" to
btrfs utility. The idea is to maintain backwards compatibility by
linking btrfsck to btrfs and have btrfs invoke the check sub-command
when called through the btrfsck link. This has been suggested on the
mailing list and approved by Dave and Chris.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This patch includes the functionality of btrfs, it's
found as "btrfs check".
Signed-off-by: Ian Kumlien <pomac@demius.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
When typing command "btrfs send --help" or "btrfs receive --help",
the help information of the commands is incomplete, which only
shows a short usage.
This patch helps to display the complete infomation of the commands.
Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
This is the user mode part of the device replace patch series.
The command group "btrfs replace" is added with three commands:
- btrfs replace start srcdev|srcdevid targetdev [-Bfr] mount_point
- btrfs replace status mount_point [-1]
- btrfs replace cancel mount_point
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
This patch fixed the following warning:
cmds-send.c:464:6: warning: ‘ret' may be used uninitialized in this function [-Wuninitialized]
crc32c.c:121:1: warning: control reaches end of non-void function [-Wreturn-type]
send-utils.c:69:11: warning: ‘comp' may be used uninitialized in this function [-Wuninitialized]
send-utils.c:126:6: warning: ‘comp' may be used uninitialized in this function [-Wuninitialized]
send-utils.c:99:22: warning: ‘entry' may be used uninitialized in this function [-Wuninitialized]
btrfs.c:261:2: warning: implicit declaration of function ‘crc32c_optimization_init' [-Wimplicit-function-declaration]
btrfs.c:105:2: warning: ‘cmd' may be used uninitialized in this function [-Wuninitialized]
restore.c:435:12: warning: ignoring return value of ‘ftruncate', declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Add user space commands for btrfs send/receive.
Signed-off-by: Alexander Block <ablock84@googlemail.com>
Reviewed-by: David Sterba <dave@jikos.cz>
Reviewed-by: Arne Jansen <sensille@gmx.net>
Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Reviewed-by: Alex Lyakas <alex.bolshoy.btrfs@gmail.com>
Add balance command group under both 'btrfs' and 'btrfs filesystem'.
Preserve the old 'btrfs filesystem balance <path>' behaviour.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
The new infrastructure offloads checking number of arguments passed to a
command to individual command handlers. Fix them up accordingly.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This completely replaces the existing subcommand infrastructure, which
is not flexible enough to accomodate our needs. Instead of a global
command table we now have per-level tables and command group handlers,
which allows command-group-specific handling of options and subcommands.
The new parser exports a clear interface and gets out of the way - all
control over how matching is done is passed to commands and command
group handlers.
One side effect of this is that command implementors have to check the
number of arguments themselves - patch to fix up all existing commands
follows.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
two new commands that make use of the new path resolving functions
implemented for scrub, doing the resolving in-kernel. the result for both
commands is a list of files belonging to that inode / logical address.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
During the commands:
- btrfs filesystem show
- btrfs device scan
the devices "scanned" are extracted from /proc/partitions. This
should avoid to scan devices not suitable for a btrfs filesystem like cdrom
and floppy or to scan not existant devices.
The old behavior (scan all the block devices under /dev) may be
forced passing the "--all-devices" switch.
Add subcommand to get the default subvolume of btrfs filesystem
V2->V3:
* add man page
* based on http://git.darksatanic.net/repo/btrfs-progs-unstable.git
integration-20110705
Reviewed-by: Andreas Philipp <philipp.andreas@gmail.com>
Reviewed-by: Goffredo Baroncelli <kreijack@libero.it>
Reported-by: Yang, Yi <yi.y.yang@intel.com>
Signed-off-by: Zhong, Xin <xin.zhong@intel.com>
- scrub commands added
- open_file_or_dir no longer static (needed by scrub.c)
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
There was some discussion on "where" subvolumes live in. Why do we not
simply print the parent ID for each subvolume in btrfs subvolume list?
This patch adds this functionality when called with parameter "-p".
Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
This simple patch makes "btrfs filesystem label" command actually work.
On tmp branch, commit d1dc6a9, "btrfs filesystem label" functionality
was introduced. However the commit lacks one component that lets
"btrfs" accept "filesystem label" command.
Test case:
/dev/loop0
WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using
fs created label old on /dev/loop0
nodesize 4096 leafsize 4096 sectorsize 4096 size 1.00GB
Btrfs Btrfs v0.19
old
new
FATAL: the filesystem has to be unmounted
new
Not sure if you need if you need a signoff for something as trivial as
this, but here it is just in case.
Signed-off-by: Fajar A. Nugraha <list@fajar.net>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Now 'btrfs subvolume snapshot' takes not two but only at least two
parameters. Additionally, the help message is updated accordingly.
Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
extend the
btrfs <cmd> --help
command to print detailed help message if available but fallback to
basic help message if detailed is unavailable
add detailed help message for 'filesystem defragment' command
little tweaks in comments
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
explain how to use
btrfs <cmd> --help
command in help message
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Hi all,
this patch adds the command "btrfs filesystem label" to change (or show) the
label of a filesystem.
This patch is a subset of the one written previously by Morey Roof. I
included the user space part only. So it is possible only to change/show a
label of a *single device* and *unounted* filesystem.
The reason of excluding the kernel space part, is to simplify the patch in
order to speed the check and then the merging of the patch itself. In fact I
have to point out that in the past there was almost three attempts to propose
this patch, without success neither complaints.
Chris, let me know how you want to proceed. I know that you are very busy,
and you prefer to work to stabilize btrfs instead adding new feature. But I
think that changing a label is a *essential* feature for a filesystem
managing tool. Think about a mount by LABEL.
To show a label
$ btrfs filesystem label <device>
To set a label
$ btrfs filesystem label <device> <newlabel>
Please guys, give a look to the source.
Comments are welcome.
You can pull the source from the branch "label" of the repository
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
Regards
G.Baroncelli
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Hi all,
enclose you can find a patch which improves the help of the btrfs commands,
updates the INSTALL file and the btrfs (command) man page.
Regarding the help of the btrfs command:
- moved the "subvolume set-default" command in the "subvolume" commands group
- removed a wrong new line
- small tweak on the basis of Andreas suggestion
Regarding the btrfs command man page:
- renaming the command "device balance" in "filesystem balance" (thanks to
Andreas Phillipp to highlight that)
- adding the entry "subvolume find-new"
- document the switches of the command "filesystem defrag"
- document the <devid> facility of the command "filesystem resize"
- small tweak on the basis of Andreas suggestion
Regarding the INSTALL file, which was very old, I removed the reference of the
old btrfsctl utility and changed the examples using the btrfs command.
I removed the old (and now wrong) statement about the inability to delete a
subvolume/snapshot
Chris, you can pull the patch from the branch "help_cleanup" of the following
repository.
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
(or you can browse the changes at
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git/?p=btrfs-
progs-unstable-all.git;a=summary)
The patch is very simple: only updates the man page, the INSTALL file and
moves/updates some lines in the help of btrfs command. Comments are welcome.
Regards
G.Baroncelli
INSTALL | 29 ++++++++++++++++++++---------
btrfs.c | 24 ++++++++++++------------
man/btrfs.8.in | 45 +++++++++++++++++++++++++--------------------
3 files changed, 57 insertions(+), 41 deletions(-)
all the block devices.
.TP
@@ -138,21 +143,21 @@ can expand the partition before enlarging the filesystem
and shrink the
partition after reducing the size of the filesystem.
.TP
-\fBfilesystem show\fR [<uuid>|<label>]\fR
-Show the btrfs filesystem with some additional info. If no UUID or label is
-passed, \fBbtrfs\fR show info of all the btrfs filesystem.
+\fBfilesystem show\fR [<device>|<uuid>|<label>]\fR
+Show the btrfs filesystem with some additional info. If no argument is
+passed, \fBbtrfs\fR shows info of all the btrfs filesystems.
.TP
-\fBdevice balance\fR \fI<path>\fR
+\fBfilesystem balance\fR \fI<path>\fR
Balance the chunks of the filesystem identified by \fI<path>\fR
across the devices.
.TP
-\fBdevice add\fR\fI <dev> [<dev>..] <path>\fR
+\fBdevice add\fR\fI <device> [<device>...] <path>\fR
Add device(s) to the filesystem identified by \fI<path>\fR.
.TP
-\fBdevice delete\fR\fI <dev> [<dev>..] <path>\fR
+\fBdevice delete\fR\fI <device> [<device>...] <path>\fR
Remove device(s) from a filesystem identified by \fI<path>\fR.
.PP
Signed-off-by: Chris Mason <chris.mason@oracle.com>
[Btrfs-Progs][V2] Update for lzo support
- Add incompat flag, otherwise btrfs-progs will report error
when operating on btrfs filesystems mounted with lzo option.
- Update man page.
- Allow to turn on lzo compression for defrag operation:
# btrfs filesystem defragment -c[zlib, lzo] <file>
Note: "-c zlib" will fail, because that's how getopt() works
for optional arguments.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
When we compile btrfs-progs in RHEL5(with default gcc 4.1.2 and glibc-2.5-18),
we can get following error:
cc1: warnings being treated as errors
btrfs-list.c: In function 'ino_resolve':
btrfs-list.c:511: warning: implicit declaration of function 'strndup'
btrfs-list.c:511: warning: incompatible implicit declaration of built-in function 'strndup'
make: *** [btrfs-list.o] Error 1
...
cc1: warnings being treated as errors
btrfs.c: In function 'split_command':
btrfs.c:168: warning: implicit declaration of function 'strndup'
btrfs.c:168: warning: incompatible implicit declaration of built-in function 'strndup'
make: *** [btrfs-list.o] Error 1
We can add _GNU_SOURCE definition according man strndup.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
btrfs-subvol find-new <subvol> <id> will search through a given subvol
and print out all the files with extents newer than a given id.
Care must be taken to make sure any pending delalloc is on disk before
running this because that won't show up in the output.
This goes along with the new space info ioctl. This will spit out the space
info all nice and pretty with the type, it's flags (DUP, RAID) and how much
space is in that group and how much is in use.
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>