Commit graph

16 commits

Author SHA1 Message Date
Alex Lyakas 6712828275 btrfs-progs: Fix the receive code pathing
The receive code was not distinguishing properly between the mount root
and the directory to create the received subvolume in.
Also make sure the find_mount_root reports an error if it cannot find
a match at all.

Reported-by: Robert Buhren <robert@robertbuhren.de>
Reported-by: Rory Campbell-Lange <rory@campbell-lange.net>
Reported-by: Stefan Priebe - Profihost AG <s.priebe@profihost.ag>
Signed-off-by: Alex Lyakas <alex.btrfs@zadarastorage.com>
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:25 +02:00
Stefan Behrens 913372adbd Btrfs-progs: allow to receive to relative directories
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:25 +02:00
Stefan Behrens b4efe05b69 Btrfs-progs: Fix that BTRFS_FSID_SIZE is used instead of BTRFS_UUID_SIZE
Both are 16 but it's wrong anyway to use FSID_SIZE for UUIDs.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:24 +02:00
Stefan Behrens 46de1a6ec3 Btrfs-progs: btrfs-receive optionally honors the end-cmd
A new option is added to btrfs-receive to change the behavior when
an <end cmd> is received in the Btrfs send stream.

The traditional behavior (which still is the default) is to continue
to read the stream until an EOF condition is encountered. If an
<end cmd> is received, afterwards either an EOF or a new
<stream header> is expected.

The new behavior (if the -e option is set on the command line) is
to terminate after an <end cmd> is read without the need for an EOF.
This allows the stream (e.g. a single TCP stream) to carry additional
data or even multiple Btrfs send streams.

Old btrfs-send tools used to encode multiple snapshots like this
(with 2 snapshots in this example):
<stream header> + <sequence of commands> + <end cmd> +
<stream header> + <sequence of commands> + <end cmd> + EOF

If the new -e option is set, the expected format is like this:
<stream header> + <sequence of commands> +
                  <sequence of commands> + <end cmd>

The btrfs-send tool is changed in a seperate commit to always use
the new format, i.e. to send an <end cmd> only at the end.

Note that the currently existing receivers treat <end cmd> only as
an indication that a new <stream header> is following. This means,
you can just skip the sequence <end cmd> <stream header> without
loosing compatibility. As long as an EOF is following, the currently
existing receivers handle the new format (if the two new flags are
used) exactly as the old one.

The goal of changing the semantic of <end cmd> is to be able to use
a single stream (one TCP connection) to multiplex a request/response
handshake plus Btrfs send streams, all in the same stream. In this
case you cannot evaluate an EOF condition as an end of the Btrfs send
stream. You need something else, and the <end cmd> is just perfect
for this purpose.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:24 +02:00
Stefan Behrens fea32e3983 Btrfs-progs: small parent_subvol cleanup for cmds-receive.c
parent_subvol is local to process_snapshot() and not needed outside.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:24 +02:00
Stefan Behrens adf67ff761 Btrfs-progs: Set the root-id for received subvols in btrfs receive
When an entry was added to the subvol search tree, the root_id was
always 0 (not set at all) and therefore only the first one was
added, all the others had been ignored. This commit sets the root_id
before the entry is added.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:23 +02:00
Stefan Behrens c3153d2fc8 Btrfs-progs: btrfs-receive: different levels (amount) of debug output
There used to be 2 levels of verbose output, now there are 3:
- None at all (no -v option given).
- Some information about received snapshots / subvolumes (-v option).
- Each received command is printed (-vv option).

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:23 +02:00
Stefan Behrens 04629af38a Btrfs-progs: free memory and close file descriptor in btrfs receive
Nothing really important since this is not part of the library and
at the end exit() is called.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:23 +02:00
Stefan Behrens 969d0cbb51 Btrfs-progs: cleanup subvol_uuid_search memory in btrfs send/receive
Call the cleanup function that was introduced with the other commit.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-04-23 18:56:22 +02:00
Eric Sandeen 899ba61fa6 btrfs-progs: fix overflows of ioctl name args
3 places where we copy pathnames into ioctl arguments
were not limited to the destination name size, and
could overflow.  Use the new strncpy_null() macro
to make this safe.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-02-05 16:09:41 -08:00
Zach Brown d86394da23 btrfs-progs: remove unused info_fd
finish_subvol() initializes and tests info_fd but it is never used.

Signed-off-by: Zach Brown <zab@redhat.com>
2013-02-05 16:09:38 -08:00
Chen Yang efbb344a59 Btrfs-progs: Complete the help information of btrfs send/receive
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>
2013-02-01 16:55:03 +01:00
Ulrik c9597c7f17 Btrfs-progs: correct btrfs receive usage string
Fix the usage string to specify the correct '-f' option for input file,
not '-i'.

Signed-off-by: Ulrik Sverdrup <ulrik.sverdrup@gmail.com>
Signed-off-by: Gene Czarcinski <gene@czarc.net>
2013-01-21 18:28:00 +01:00
Alex Lyakas e1a97972ac btrfs-progs: Receive: preserve ownership for symlinks, by using 'lchown'
Signed-off-by: Alex Lyakas <alex.btrfs@zadarastorage.com>
2013-01-17 18:27:54 +01:00
Wade Cline 0d5cfddc2c Btrfs-progs: Fix compiler warnings on PPC64
The kernel uses unsigned long long for u64, but PPC64 uses unsigned
long by default. This results in compilation warnings such as:

print-tree.c:333: warning: format '%llu' expects type 'long long
unsigned int', but argument 4 has type 'u64'

To fix this, the macro __KERNEL__ needs to be defined before including
the file <asm/types.h>. This can be done by defining the macro in
"kerncompat.h" and making it the first included file in the relevant
header files; this fixes the compiler warnings on PPC64.

Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Wade Cline <clinew@linux.vnet.ibm.com>
2013-01-17 18:12:57 +01:00
Alexander Block f1c24cd80d Btrfs-progs: add btrfs send/receive commands
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>
2012-07-26 14:51:27 -04:00