From patchwork Sat Nov 21 14:39:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Drebes X-Patchwork-Id: 61932 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nALEdOBj009224 for ; Sat, 21 Nov 2009 14:39:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754729AbZKUOjR (ORCPT ); Sat, 21 Nov 2009 09:39:17 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754578AbZKUOjR (ORCPT ); Sat, 21 Nov 2009 09:39:17 -0500 Received: from wp178.webpack.hosteurope.de ([80.237.132.185]:60902 "EHLO wp178.webpack.hosteurope.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754550AbZKUOjR (ORCPT ); Sat, 21 Nov 2009 09:39:17 -0500 Received: from 9.149.67-86.rev.gaoland.net ([86.67.149.9] helo=[192.168.1.66]); authenticated by wp178.webpack.hosteurope.de running ExIM with esmtpsa (TLSv1:RC4-SHA:128) id 1NBr7T-0006hW-0f; Sat, 21 Nov 2009 15:39:23 +0100 From: Andi Drebes To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/2] btrfs-progs: prevent btrfsck to run on mounted filesystems Date: Sat, 21 Nov 2009 15:39:15 +0100 User-Agent: KMail/1.9.9 Cc: Chris Mason , "Yan, Zheng" References: <200911211533.25878.lists-receive@programmierforen.de> In-Reply-To: <200911211533.25878.lists-receive@programmierforen.de> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200911211539.15224.lists-receive@programmierforen.de> X-bounce-key: webpack.hosteurope.de; lists-receive@programmierforen.de; 1258814363; 37f2d4b4; Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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)