struct subvol_info *cur_subvol;
struct subvol_uuid_search sus;
+
+ int honor_end_cmd;
};
static int finish_subvol(struct btrfs_receive *r)
goto out;
while (!end) {
- ret = btrfs_read_and_process_send_stream(r_fd, &send_ops, r);
+ ret = btrfs_read_and_process_send_stream(r_fd, &send_ops, r,
+ r->honor_end_cmd);
if (ret < 0)
goto out;
if (ret)
r.mnt_fd = -1;
r.write_fd = -1;
- while ((c = getopt(argc, argv, "vf:")) != -1) {
+ while ((c = getopt(argc, argv, "evf:")) != -1) {
switch (c) {
case 'v':
g_verbose++;
case 'f':
fromfile = optarg;
break;
+ case 'e':
+ r.honor_end_cmd = 1;
+ break;
case '?':
default:
fprintf(stderr, "ERROR: receive args invalid.\n");
};
const char * const cmd_receive_usage[] = {
- "btrfs receive [-v] [-f <infile>] <mount>",
+ "btrfs receive [-ve] [-f <infile>] <mount>",
"Receive subvolumes from stdin.",
"Receives one or more subvolumes that were previously ",
"sent with btrfs send. The received subvolumes are stored",
"-f <infile> By default, btrfs receive uses stdin",
" to receive the subvolumes. Use this",
" option to specify a file to use instead.",
+ "-e Terminate after receiving an <end cmd>",
+ " in the data stream. Without this option,",
+ " the receiver terminates only if an error",
+ " is recognized or on EOF.",
NULL
};
}
int btrfs_read_and_process_send_stream(int fd,
- struct btrfs_send_ops *ops, void *user)
+ struct btrfs_send_ops *ops, void *user,
+ int honor_end_cmd)
{
int ret;
struct btrfs_send_stream s;
if (ret < 0)
goto out;
if (ret) {
- ret = 0;
+ if (!honor_end_cmd)
+ ret = 0;
goto out;
}
}