diff options
author | Gui Hecheng <guihc.fnst@cn.fujitsu.com> | 2014-07-07 09:56:51 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-08-22 15:07:03 +0200 |
commit | f0884b5dc30c134bcb87a43342ca26d0773295ee (patch) | |
tree | 0282d7cb6a2ad324be8380644d0409ca03871e97 | |
parent | acf2652649e7338c89e164dba7c1409946dfb425 (diff) | |
download | btrfs-progs-f0884b5dc30c134bcb87a43342ca26d0773295ee.tar.gz |
btrfs-progs: add mount status check for btrfs-image
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>
-rw-r--r-- | btrfs-image.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/btrfs-image.c b/btrfs-image.c index 985aa26..cb17f16 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -2570,12 +2570,22 @@ int main(int argc, char *argv[]) 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)); |