From patchwork Thu Aug 5 10:04:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shaoyan X-Patchwork-Id: 117262 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o75A4uhh023669 for ; Thu, 5 Aug 2010 10:04:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759546Ab0HEKEx (ORCPT ); Thu, 5 Aug 2010 06:04:53 -0400 Received: from mail-qy0-f174.google.com ([209.85.216.174]:44466 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755601Ab0HEKEw (ORCPT ); Thu, 5 Aug 2010 06:04:52 -0400 Received: by qyk7 with SMTP id 7so2043925qyk.19 for ; Thu, 05 Aug 2010 03:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=4w4vwAan/k+YofzzhYTP4GsicvmihDe4YFC0X2fFng8=; b=OY5vc367I17fX7wBlmRBzenDbz511yO2LAWaZRCS2Cn5fQmtyrQl2DQXjkgWrufpIp pSoWiMS54xm1LEYgccVBbguZ2RefCmLGt3PEvnhCpouZM9B/j49eWFQBl4cPSFSsEkKB SPPsKNgjVmWajrpKRoFAYd/LKxcPGWpMveYfQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=xUWGtWdreIY8cmtlZbDysNQhaFIPJDQQFw/yvYVD8Wv4sFvXBMn0vVpEuD2ILjLxQN zjtrFWsZZhpShulKg/hbub8lxexMV+v8s1WcxZ2aT7mAq4NAewcl+tKk6xq34ZrYSufa khBFpafEoTH2FlfW7iN007FiNySOlbKwpiKC8= MIME-Version: 1.0 Received: by 10.229.141.206 with SMTP id n14mr3229932qcu.171.1281002691589; Thu, 05 Aug 2010 03:04:51 -0700 (PDT) Received: by 10.229.203.161 with HTTP; Thu, 5 Aug 2010 03:04:51 -0700 (PDT) Date: Thu, 5 Aug 2010 18:04:51 +0800 Message-ID: Subject: [PATCH] btrfs: when mkfs.btrfs, add control to the multiple device which have mounted From: Wang Shaoyan To: linux-btrfs@vger.kernel.org Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 05 Aug 2010 10:04:56 +0000 (UTC) diff --git a/mkfs.c b/mkfs.c index 2e99b95..ceb65cb 100644 --- a/mkfs.c +++ b/mkfs.c @@ -431,6 +431,10 @@ int main(int ac, char **av) fprintf(stderr, "%s is mounted\n", file); exit(1); } + if (ret == 2) { + fprintf(stderr, "%s is apparently in use by the system\n", file); + exit(1); + } ac--; fd = open(file, O_RDWR); if (fd < 0) { @@ -489,6 +493,10 @@ int main(int ac, char **av) fprintf(stderr, "%s is mounted\n", file); exit(1); } + if (ret == 2) { + fprintf(stderr, "%s is apparently in use by the system\n", file); + exit(1); + } fd = open(file, O_RDWR); if (fd < 0) { fprintf(stderr, "unable to open %s\n", file); diff --git a/utils.c b/utils.c index 2f4c6e1..e400745 100644 --- a/utils.c +++ b/utils.c @@ -587,7 +587,7 @@ error: } /* - * returns 1 if the device was mounted, < 0 on error or 0 if everything + * returns 2 if the device is busy, returns 1 if the device was mounted, < 0 on error or 0 if everything * is safe to continue. TODO, this should also scan multi-device filesystems */