btrfs: when mkfs.btrfs, add control to the multiple device which have mounted
diff mbox

Message ID AANLkTi=uYk5A+5QTwLA8bS2KDpe12yAyxTNORfqzCV=X@mail.gmail.com
State New, archived
Headers show

Commit Message

Wang Shaoyan Aug. 5, 2010, 10:04 a.m. UTC
None

Patch
diff mbox

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
  */