From: Andi Drebes <lists-receive@programmierforen.de>
To: linux-btrfs@vger.kernel.org
Cc: Chris Mason <chris.mason@oracle.com>, "Yan, Zheng" <yanzheng@21cn.com>
Subject: [PATCH 2/2] btrfs-progs: prevent btrfsck to run on mounted filesystems
Date: Sat, 21 Nov 2009 15:39:15 +0100 [thread overview]
Message-ID: <200911211539.15224.lists-receive@programmierforen.de> (raw)
In-Reply-To: <200911211533.25878.lists-receive@programmierforen.de>
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>
---
diff --git a/btrfsck.c b/btrfsck.c
index 73f1836..6f2a0d0 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -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)
prev parent reply other threads:[~2009-11-21 14:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-21 14:33 [PATCH 0/2] btrfs-progs: mounted filesystems checks Andi Drebes
2009-11-21 14:38 ` [PATCH 1/2] btrfs-progs: multidevice support for check_mounted Andi Drebes
2009-11-21 20:21 ` Karel Zak
2009-11-22 13:33 ` Andi Drebes
2009-11-23 9:01 ` Karel Zak
2009-11-21 14:39 ` Andi Drebes [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200911211539.15224.lists-receive@programmierforen.de \
--to=lists-receive@programmierforen.de \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=yanzheng@21cn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox