When btrfs-image run on a mounted filesystem,
the undergoing fs operations may change what you have imaged a while ago.
In this case, give a warning to remind the user that he may not
get a consistent image he wants.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
[tweaked the message]
Signed-off-by: David Sterba <dsterba@suse.cz>
num_threads = 1;
}
- if (create)
+ if (create) {
+ ret = check_mounted(source);
+ if (ret < 0) {
+ fprintf(stderr, "Could not check mount status: %s\n",
+ strerror(-ret));
+ exit(1);
+ } else if (ret)
+ fprintf(stderr,
+ "WARNING: The device is mounted. Make sure the filesystem is quiescent.\n");
+
ret = create_metadump(source, out, num_threads,
compress_level, sanitize, walk_trees);
- else
+ } else {
ret = restore_metadump(source, out, old_restore, 1,
multi_devices);
+ }
if (ret) {
printk("%s failed (%s)\n", (create) ? "create" : "restore",
strerror(errno));