diff options
author | Andi Drebes <lists-receive@programmierforen.de> | 2010-09-09 10:58:43 +0800 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-09-23 20:26:49 -0400 |
commit | 659d37c68d0676dcb9a9990bdbe61b98f11b0246 (patch) | |
tree | bf6792f098cb12f44d5a85a9aec67e1819820d0c | |
parent | 09559bfe7bcd43965bf8d3090f6f761fd785d093 (diff) |
prevent btrfsck to run on mounted filesystems
As recently discussed on the list, btrfsck should only be run on
unmounted filesystems. This patch adds a short check for the mount
status at the beginning of btrfsck. If the FS is mounted, the
program aborts showing an error message.
Signed-off-by: Andi Drebes <lists-receive@programmierforen.de>
-rw-r--r-- | btrfsck.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -28,6 +28,7 @@ #include "transaction.h" #include "list.h" #include "version.h" +#include "utils.h" static u64 bytes_used = 0; static u64 total_csum_bytes = 0; @@ -2821,6 +2822,15 @@ int main(int ac, char **av) radix_tree_init(); cache_tree_init(&root_cache); + + if((ret = check_mounted(av[1])) < 0) { + fprintf(stderr, "Could not check mount status: %s\n", strerror(ret)); + return ret; + } else if(ret) { + fprintf(stderr, "%s is currently mounted. Aborting.\n", av[1]); + return -EBUSY; + } + root = open_ctree(av[1], 0, 0); if (root == NULL) |