.utimes = process_utimes,
};
-static int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd,
- u64 max_errors)
+static int do_receive(struct btrfs_receive *r, const char *tomnt,
+ char *realmnt, int r_fd, u64 max_errors)
{
int ret;
char *dest_dir_full_path;
goto out;
}
- ret = find_mount_root(dest_dir_full_path, &r->root_path);
- if (ret < 0) {
- fprintf(stderr,
- "ERROR: failed to determine mount point for %s: %s\n",
- dest_dir_full_path, strerror(-ret));
- ret = -EINVAL;
- goto out;
- }
- if (ret > 0) {
- fprintf(stderr,
+ if (realmnt) {
+ r->root_path = realmnt;
+ } else {
+ ret = find_mount_root(dest_dir_full_path, &r->root_path);
+ if (ret < 0) {
+ fprintf(stderr,
+ "ERROR: failed to determine mount point for %s: %s\n",
+ dest_dir_full_path, strerror(-ret));
+ ret = -EINVAL;
+ goto out;
+ }
+ if (ret > 0) {
+ fprintf(stderr,
"ERROR: %s doesn't belong to btrfs mount point\n",
dest_dir_full_path);
- ret = -EINVAL;
- goto out;
+ ret = -EINVAL;
+ goto out;
+ }
}
r->mnt_fd = open(r->root_path, O_RDONLY | O_NOATIME);
if (r->mnt_fd < 0) {
{
char *tomnt = NULL;
char *fromfile = NULL;
+ char *realmnt = NULL;
struct btrfs_receive r;
int receive_fd = fileno(stdin);
u64 max_errors = 1;
{ NULL, 0, NULL, 0 }
};
- c = getopt_long(argc, argv, "Cevf:", long_opts, NULL);
+ c = getopt_long(argc, argv, "Cevf:m:", long_opts, NULL);
if (c < 0)
break;
case 'E':
max_errors = arg_strtou64(optarg);
break;
+ case 'm':
+ realmnt = strdup(optarg);
+ if (!realmnt) {
+ fprintf(stderr, "ERROR: couldn't allocate realmnt.\n");
+ return 1;
+ }
+ break;
case '?':
default:
fprintf(stderr, "ERROR: receive args invalid.\n");
}
}
- ret = do_receive(&r, tomnt, receive_fd, max_errors);
+ ret = do_receive(&r, tomnt, realmnt, receive_fd, max_errors);
return !!ret;
}
"--max-errors <N> Terminate as soon as N errors happened while",
" processing commands from the send stream.",
" Default value is 1. A value of 0 means no limit.",
+ "-m <mountpoint> The root mount point of the destination fs.",
+ " If you do not have /proc use this to tell us where ",
+ " this file system is mounted.",
NULL
};