Skip to contentSkip to conversation

btrfs-progs: Check mount status of multidevice filesystems

PATCH In review Andi Drebes 2 participants 3 messages Nov 14, 2009 – Nov 17, 2009 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: Check mount status of multidevice filesystems

Some programs like btrfsck should not be run on a mounted filesystem. This patch adds a check in btrfs_open_devices() for the mount status of every device belonging to the filesystem. The function check_mount() gets improved support for loopback devices. It now detects if the program is run on the file that is being used by the loopback device.

---

btrfs-map-logical.c +1 -1
index a109c6a..1e0ef9f 100644
@@ -169,7 +169,7 @@ int main(int ac, char **av)
 	radix_tree_init();
 	cache_tree_init(&root_cache);
 
-	root = open_ctree(dev, 0, 0);
+	root = open_ctree(dev, 0, 0, 0);
 	if (!root) {
 		fprintf(stderr, "Open ctree failed\n");
 		exit(1);
btrfsck.c +1 -1
index 73f1836..1434791 100644
@@ -2821,7 +2821,7 @@ int main(int ac, char **av)
 
 	radix_tree_init();
 	cache_tree_init(&root_cache);
-	root = open_ctree(av[1], 0, 0);
+	root = open_ctree(av[1], 0, 0, 1);
 
 	if (root == NULL)
 		return 1;
debug-tree.c +1 -1
index 1d47519..a8e85f4 100644
@@ -137,7 +137,7 @@ int main(int ac, char **av)
 	if (ac != 1)
 		print_usage();
 
-	root = open_ctree(av[optind], 0, 0);
+	root = open_ctree(av[optind], 0, 0, 0);
 	if (!root) {
 		fprintf(stderr, "unable to open %s\n", av[optind]);
 		exit(1);
disk-io.c +6 -6
index addebe1..f8e623b 100644
@@ -570,7 +570,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
 	return root;
 }
 
-struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes)
+struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes, int check_mount)
 {
 	int fp;
 	struct btrfs_root *root;
@@ -584,14 +584,14 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes)
 		fprintf (stderr, "Could not open %s\n", filename);
 		return NULL;
 	}
-	root = open_ctree_fd(fp, filename, sb_bytenr, writes);
+	root = open_ctree_fd(fp, filename, sb_bytenr, writes, check_mount);
 	close(fp);
 
 	return root;
 }
 
 struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
-				 int writes)
+				 int writes, int check_mount)
 {
 	u32 sectorsize;
 	u32 nodesize;
@@ -657,9 +657,9 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
 		     fs_info, BTRFS_ROOT_TREE_OBJECTID);
 
 	if (writes)
-		ret = btrfs_open_devices(fs_devices, O_RDWR);
+		ret = btrfs_open_devices(fs_devices, O_RDWR, check_mount);
 	else
-		ret = btrfs_open_devices(fs_devices, O_RDONLY);
+		ret = btrfs_open_devices(fs_devices, O_RDONLY, check_mount);
 	BUG_ON(ret);
 
 	fs_info->super_bytenr = sb_bytenr;
@@ -725,7 +725,7 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
 		 BTRFS_UUID_SIZE);
 
 	if (!(btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_METADUMP)) {
-		ret = btrfs_read_chunk_tree(chunk_root);
+		ret = btrfs_read_chunk_tree(chunk_root, check_mount);
 		BUG_ON(ret);
 	}
 
disk-io.h +2 -2
index 49e5692..1d6519e 100644
@@ -43,9 +43,9 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
 						   u64 bytenr, u32 blocksize);
 int clean_tree_block(struct btrfs_trans_handle *trans,
 		     struct btrfs_root *root, struct extent_buffer *buf);
-struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes);
+struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes, int check_mount);
 struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
-				 int writes);
+				 int writes, int check_mount);
 int close_ctree(struct btrfs_root *root);
 int write_ctree_super(struct btrfs_trans_handle *trans,
 		      struct btrfs_root *root);
kerncompat.h +4 -0
index e4c8ce0..46236cd 100644
@@ -42,7 +42,11 @@
 #define GFP_NOFS 0
 #define __read_mostly
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#ifndef ULONG_MAX
 #define ULONG_MAX       (~0UL)
+#endif
+
 #define BUG() abort()
 #ifdef __CHECKER__
 #define __force    __attribute__((force))
mkfs.c +1 -1
index 2e99b95..f226661 100644
@@ -456,7 +456,7 @@ int main(int ac, char **av)
 		fprintf(stderr, "error during mkfs %d\n", ret);
 		exit(1);
 	}
-	root = open_ctree(file, 0, O_RDWR);
+	root = open_ctree(file, 0, O_RDWR, 1);
 	root->fs_info->alloc_start = alloc_start;
 
 	ret = make_root_dir(root);
utils.c +86 -24

144 lines not on this page · raw message

utils.h +6 -0
index 7ff542b..695686b 100644
@@ -19,6 +19,12 @@
 #ifndef __UTILS__
 #define __UTILS__
 
+#define LOOP_MAJOR 7
+
+#ifndef major
+#define major(dev)	((dev) >> 8)
+#endif
+
 #define BTRFS_MKFS_SYSTEM_GROUP_SIZE (4 * 1024 * 1024)
 
 int make_btrfs(int fd, const char *device, const char *label,
volumes.c +24 -9
index 7671855..467f552 100644
@@ -29,6 +29,7 @@
 #include "transaction.h"
 #include "print-tree.h"
 #include "volumes.h"
+#include "utils.h"
 
 struct stripe {
 	struct btrfs_device *dev;
@@ -164,7 +165,7 @@ again:
 	return 0;
 }
 
-int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
+int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags, int check_mount)
 {
 	int fd;
 	struct list_head *head = &fs_devices->devices;
@@ -175,6 +176,19 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
 	list_for_each(cur, head) {
 		device = list_entry(cur, struct btrfs_device, dev_list);
 
+		if(check_mount) {
+			ret = check_mounted(device->name);
+			if (ret < 0) {
+				fprintf(stderr, "error checking %s mount status\n", device->name);
+				goto fail;
+			}
+			if (ret == 1) {
+				fprintf(stderr, "Error: %s is currently mounted.\n", device->name);
+				ret = -EBUSY;
+				goto fail;
+			}
+		}
+
 		fd = open(device->name, flags);
 		if (fd < 0) {
 			ret = -errno;
@@ -1240,7 +1254,7 @@ static int fill_device_from_item(struct extent_buffer *leaf,
 	return 0;
 }
 
-static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
+static int open_seed_devices(struct btrfs_root *root, u8 *fsid, int check_mount)
 {
 	struct btrfs_fs_devices *fs_devices;
 	int ret;
@@ -1260,7 +1274,7 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
 		goto out;
 	}
 
-	ret = btrfs_open_devices(fs_devices, O_RDONLY);
+	ret = btrfs_open_devices(fs_devices, O_RDONLY, check_mount);
 	if (ret)
 		goto out;
 
@@ -1272,7 +1286,8 @@ out:
 
 static int read_one_dev(struct btrfs_root *root,
 			struct extent_buffer *leaf,
-			struct btrfs_dev_item *dev_item)
+			struct btrfs_dev_item *dev_item,
+			int check_mount)
 {
 	struct btrfs_device *device;
 	u64 devid;
@@ -1289,7 +1304,7 @@ static int read_one_dev(struct btrfs_root *root,
 			   BTRFS_UUID_SIZE);
 
 	if (memcmp(fs_uuid, root->fs_info->fsid, BTRFS_UUID_SIZE)) {
-		ret = open_seed_devices(root, fs_uuid);
+		ret = open_seed_devices(root, fs_uuid, check_mount);
 		if (ret)
 			return ret;
 	}
@@ -1311,13 +1326,13 @@ static int read_one_dev(struct btrfs_root *root,
 	return ret;
 }
 
-int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf)
+int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf, int check_mount)
 {
 	struct btrfs_dev_item *dev_item;
 
 	dev_item = (struct btrfs_dev_item *)offsetof(struct btrfs_super_block,
 						     dev_item);
-	return read_one_dev(root, buf, dev_item);
+	return read_one_dev(root, buf, dev_item, check_mount);
 }
 
 int btrfs_read_sys_array(struct btrfs_root *root)
@@ -1378,7 +1393,7 @@ int btrfs_read_sys_array(struct btrfs_root *root)
 	return 0;
 }
 
-int btrfs_read_chunk_tree(struct btrfs_root *root)
+int btrfs_read_chunk_tree(struct btrfs_root *root, int check_mount)
 {
 	struct btrfs_path *path;
 	struct extent_buffer *leaf;
@@ -1421,7 +1436,7 @@ again:
 				struct btrfs_dev_item *dev_item;
 				dev_item = btrfs_item_ptr(leaf, slot,
 						  struct btrfs_dev_item);
-				ret = read_one_dev(root, leaf, dev_item);
+				ret = read_one_dev(root, leaf, dev_item, check_mount);
 				BUG_ON(ret);
 			}
 		} else if (found_key.type == BTRFS_CHUNK_ITEM_KEY) {
volumes.h +3 -3
index bb78751..baf12ff 100644
@@ -103,16 +103,16 @@ int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
 		     u64 chunk_start, u64 physical, u64 devid,
 		     u64 **logical, int *naddrs, int *stripe_len);
 int btrfs_read_sys_array(struct btrfs_root *root);
-int btrfs_read_chunk_tree(struct btrfs_root *root);
+int btrfs_read_chunk_tree(struct btrfs_root *root, int check_mount);
 int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
 		      struct btrfs_root *extent_root, u64 *start,
 		      u64 *num_bytes, u64 type);
-int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf);
+int btrfs_read_super_device(struct btrfs_root *root, struct extent_buffer *buf, int check_mount);
 int btrfs_add_device(struct btrfs_trans_handle *trans,
 		     struct btrfs_root *root,
 		     struct btrfs_device *device);
 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
-		       int flags);
+		       int flags, int check_mount);
 int btrfs_close_devices(struct btrfs_fs_devices *fs_devices);
 int btrfs_add_device(struct btrfs_trans_handle *trans,
 		     struct btrfs_root *root,
#1 lore raw
Quoted 3 lines · Andi Drebes

Some programs like btrfsck should not be run on a mounted filesystem. This patch adds a check in btrfs_open_devices() for the mount status of every device belonging to the filesystem. The function check_mount=

()

Quoted 3 lines

gets improved support for loopback devices. It now detects if the program is run on the file that is being used by the loopback device.

Hi Andi,

Thank you for sending the patch.

Would you please add mounted check for multiple devices FS to check_mounted instead of btrfs_open_devices. It's easy to get the list of devices, see code at very beginning of open_ctree_fd().

Yan, Zheng

Quoted 12 lines

---besides

btrfs-map-logical.c +1 -1
index a109c6a..1e0ef9f 100644
@@ -169,7 +169,7 @@ int main(int ac, char **av)
 =A0 =A0 =A0 =A0radix_tree_init();
 =A0 =A0 =A0 =A0cache_tree_init(&root_cache);
 
- =A0 =A0 =A0 root =3D open_ctree(dev, 0, 0);
+ =A0 =A0 =A0 root =3D open_ctree(dev, 0, 0, 0);
 =A0 =A0 =A0 =A0if (!root) {
Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fprintf(stderr, "Open ctree failed\n")=

;

Quoted 25 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit(1);

btrfsck.c +1 -1
index 73f1836..1434791 100644
@@ -2821,7 +2821,7 @@ int main(int ac, char **av)
 
 =A0 =A0 =A0 =A0radix_tree_init();
 =A0 =A0 =A0 =A0cache_tree_init(&root_cache);
- =A0 =A0 =A0 root =3D open_ctree(av[1], 0, 0);
+ =A0 =A0 =A0 root =3D open_ctree(av[1], 0, 0, 1);
 
 =A0 =A0 =A0 =A0if (root =3D=3D NULL)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return 1;
debug-tree.c +1 -1
index 1d47519..a8e85f4 100644
@@ -137,7 +137,7 @@ int main(int ac, char **av)
 =A0 =A0 =A0 =A0if (ac !=3D 1)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0print_usage();
 
- =A0 =A0 =A0 root =3D open_ctree(av[optind], 0, 0);
+ =A0 =A0 =A0 root =3D open_ctree(av[optind], 0, 0, 0);
 =A0 =A0 =A0 =A0if (!root) {
Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fprintf(stderr, "unable to open %s\n",=

av[optind]);

disk-io.c struct btrfs_root *btrfs_read_fs_root(struct btrf=

Quoted 6 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit(1);

disk-io.c +0 -0
index addebe1..f8e623b 100644
@@ -570,7 +570,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrf=

s_fs_info *fs_info,

disk-io.c struct btrfs_root *btrfs_read_fs_root(struct btrf= · line 573

Quoted 4 lines
disk-io.c +0 -1
 =A0 =A0 =A0 =A0return root;
 =A0}
 
-struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, i=

nt writes)

disk-io.c struct btrfs_root *btrfs_read_fs_root(struct btrf= · line 573

Quoted 1 line
disk-io.c +1 -0
+struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, i=

nt writes, int check_mount)

disk-io.c struct btrfs_root *open_ctree(const char *filen=

Quoted 4 lines
disk-io.c +0 -0
 =A0{
 =A0 =A0 =A0 =A0int fp;
 =A0 =A0 =A0 =A0struct btrfs_root *root;
@@ -584,14 +584,14 @@ struct btrfs_root *open_ctree(const char *filen=

ame, u64 sb_bytenr, int writes)

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fprintf (stderr, "Could not open %s\n"=

, filename);

Quoted 3 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return NULL;
=A0 =A0 =A0 =A0}
- =A0 =A0 =A0 root =3D open_ctree_fd(fp, filename, sb_bytenr, writes)=

;

Quoted 1 line

+ =A0 =A0 =A0 root =3D open_ctree_fd(fp, filename, sb_bytenr, writes,=

check_mount);

Quoted 6 lines

=A0 =A0 =A0 =A0close(fp);

=A0 =A0 =A0 =A0return root;
=A0}

=A0struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_=

bytenr,

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int =

writes)

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int =

writes, int check_mount)

disk-io.c struct btrfs_root *open_ctree_fd(int fp, const ch=

Quoted 4 lines

=A0{
=A0 =A0 =A0 =A0u32 sectorsize;
=A0 =A0 =A0 =A0u32 nodesize;

disk-io.c +0 -0
@@ -657,9 +657,9 @@ struct btrfs_root *open_ctree_fd(int fp, const ch=

ar *path, u64 sb_bytenr,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fs_info, BTRFS_ROOT_TREE_OBJE=

CTID);

Quoted 3 lines

=A0 =A0 =A0 =A0if (writes)
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D btrfs_open_devices(fs_devices, =

O_RDWR);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D btrfs_open_devices(fs_devices, =

O_RDWR, check_mount);

Quoted 2 lines

=A0 =A0 =A0 =A0else
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D btrfs_open_devices(fs_devices, =

O_RDONLY);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D btrfs_open_devices(fs_devices, =

O_RDONLY, check_mount);

disk-io.c struct btrfs_root *open_ctree_fd(int fp, const ch=

Quoted 4 lines

=A0 =A0 =A0 =A0BUG_ON(ret);

=A0 =A0 =A0 =A0fs_info->super_bytenr =3D sb_bytenr;

disk-io.c +0 -0
@@ -725,7 +725,7 @@ struct btrfs_root *open_ctree_fd(int fp, const ch=

ar *path, u64 sb_bytenr,

Quoted 3 lines
disk-io.c +0 -0
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 BTRFS_UUID_SIZE);
 

=A0 =A0 =A0 =A0if (!(btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG=

_METADUMP)) {

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D btrfs_read_chunk_tree(chunk_roo=

t);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D btrfs_read_chunk_tree(chunk_roo=

t, check_mount);

disk-io.h struct extent_buffer *btrfs_find_create_tree_block(=

Quoted 8 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BUG_ON(ret);
=A0 =A0 =A0 =A0}

disk-io.h +0 -0
index 49e5692..1d6519e 100644
@@ -43,9 +43,9 @@ struct extent_buffer *btrfs_find_create_tree_block(=

struct btrfs_root *root,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 =A0 =A0 =A0 =A0 =A0 u64 bytenr, u32 blocksize);

Quoted 2 lines

=A0int clean_tree_block(struct btrfs_trans_handle *trans, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct btrfs_root *root, stru=

ct extent_buffer *buf);

Quoted 1 line

-struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, i=

nt writes);

Quoted 1 line

+struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, i=

nt writes, int check_mount);

Quoted 1 line

=A0struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_=

bytenr,

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int =

writes);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int =

writes, int check_mount);

Quoted 24 lines

=A0int close_ctree(struct btrfs_root *root);
=A0int write_ctree_super(struct btrfs_trans_handle *trans, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct btrfs_root *root);

kerncompat.h +0 -0
index e4c8ce0..46236cd 100644
@@ -42,7 +42,11 @@

=A0#define GFP_NOFS 0
=A0#define __read_mostly
=A0#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

kerncompat.h +2 -0
+
+#ifndef ULONG_MAX

=A0#define ULONG_MAX =A0 =A0 =A0 (~0UL)

kerncompat.h +2 -0
+#endif
+

=A0#define BUG() abort()
=A0#ifdef __CHECKER__
=A0#define __force =A0 =A0__attribute__((force))

mkfs.c +0 -0
index 2e99b95..f226661 100644
@@ -456,7 +456,7 @@ int main(int ac, char **av)
Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fprintf(stderr, "error during mkfs %d\=

n", ret);

Quoted 22 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit(1);
=A0 =A0 =A0 =A0}
- =A0 =A0 =A0 root =3D open_ctree(file, 0, O_RDWR);
+ =A0 =A0 =A0 root =3D open_ctree(file, 0, O_RDWR, 1); =A0 =A0 =A0 =A0root->fs_info->alloc_start =3D alloc_start;

=A0 =A0 =A0 =A0ret =3D make_root_dir(root);

utils.c +0 -0
index 2f4c6e1..60c3f24 100644
@@ -31,6 +31,8 @@

=A0#include <fcntl.h>
=A0#include <unistd.h>
=A0#include <mntent.h>

utils.c +2 -0
+#include <linux/loop.h>
+#include <limits.h>

=A0#include "kerncompat.h"
=A0#include "radix-tree.h"
=A0#include "ctree.h"

utils.c +0 -0
@@ -586,46 +588,105 @@ error:
 =A0 =A0 =A0 =A0return ret;

utils.c error: · line 598

Quoted 10 lines
utils.c +8 -0
 =A0}
 
+int is_loop_device (const char *device) {
+ =A0 =A0 =A0 struct stat statbuf;
+
+ =A0 =A0 =A0 if(stat(device, &statbuf) < 0)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -errno;
+
+ =A0 =A0 =A0 return (S_ISBLK(statbuf.st_mode) &&
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 major(statbuf.st_rdev) =3D=3D LOOP_MAJO=

R);

Quoted 42 lines
utils.c +42 -0
+}
+
+int is_same_blk_file(const char* a, const char* b)
+{
+ =A0 =A0 =A0 struct stat st_buf_a, st_buf_b;
+ =A0 =A0 =A0 char real_a[PATH_MAX];
+ =A0 =A0 =A0 char real_b[PATH_MAX];
+
+ =A0 =A0 =A0 if(!realpath(a, real_a) ||
+ =A0 =A0 =A0 =A0 =A0!realpath(b, real_b))
+ =A0 =A0 =A0 {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -errno;
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 /* Identical path? */
+ =A0 =A0 =A0 if(strcmp(real_a, real_b) =3D=3D 0)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1;
+
+ =A0 =A0 =A0 if(stat(a, &st_buf_a) < 0 ||
+ =A0 =A0 =A0 =A0 =A0stat(b, &st_buf_b) < 0)
+ =A0 =A0 =A0 {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -errno;
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 /* Same blockdevice? */
+ =A0 =A0 =A0 if(S_ISBLK(st_buf_a.st_mode) &&
+ =A0 =A0 =A0 =A0 =A0S_ISBLK(st_buf_b.st_mode) &&
+ =A0 =A0 =A0 =A0 =A0st_buf_a.st_rdev =3D=3D st_buf_b.st_rdev)
+ =A0 =A0 =A0 {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1;
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 /* Hardlink? */
+ =A0 =A0 =A0 if (st_buf_a.st_dev =3D=3D st_buf_b.st_dev &&
+ =A0 =A0 =A0 =A0 =A0 st_buf_a.st_ino =3D=3D st_buf_b.st_ino)
+ =A0 =A0 =A0 {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1;
+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 return 0;
+}
+
Quoted 2 lines

=A0/*
=A0* returns 1 if the device was mounted, < 0 on error or 0 if everyt=

hing

Quoted 1 line

- * is safe to continue. =A0TODO, this should also scan multi-device =

filesystems

Quoted 12 lines

+ * is safe to continue.
=A0*/
=A0int check_mounted(char *file)
=A0{
=A0 =A0 =A0 =A0struct mntent *mnt;
- =A0 =A0 =A0 struct stat st_buf;
- =A0 =A0 =A0 dev_t file_dev =3D 0;
- =A0 =A0 =A0 dev_t file_rdev =3D 0;
- =A0 =A0 =A0 ino_t file_ino =3D 0;
=A0 =A0 =A0 =A0FILE *f;
=A0 =A0 =A0 =A0int ret =3D 0;

Quoted 1 line

- =A0 =A0 =A0 if ((f =3D setmntent ("/proc/mounts", "r")) =3D=3D NULL=

)

Quoted 6 lines

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -errno;
+ =A0 =A0 =A0 int loop_fd;
+ =A0 =A0 =A0 struct loop_info loopinfo;

- =A0 =A0 =A0 if (stat(file, &st_buf) < 0) {
+ =A0 =A0 =A0 if ((f =3D setmntent ("/proc/mounts", "r")) =3D=3D NULL=

)

Quoted 4 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -errno;
- =A0 =A0 =A0 } else {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (S_ISBLK(st_buf.st_mode)) {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 file_rdev =3D st_buf.st=

_rdev;

Quoted 2 lines

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 file_dev =3D st_buf.st_=

dev;

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 file_ino =3D st_buf.st_=

ino;

Quoted 5 lines

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
- =A0 =A0 =A0 }

=A0 =A0 =A0 =A0while ((mnt =3D getmntent (f)) !=3D NULL) {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (strcmp(file, mnt->mnt_fsname) =3D=3D=

0)

Quoted 3 lines

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Only check btrfs filesystems */
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(strcmp(mnt->mnt_type, "btrfs") !=3D =

0)

Quoted 3 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue;

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (stat(mnt->mnt_fsname, &st_buf) =3D=3D=

0) {

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (S_ISBLK(st_buf.st_m=

ode)) {

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (fil=

e_rdev && (file_rdev =3D=3D st_buf.st_rdev))

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 break;

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else if (file_dev && =

((file_dev =3D=3D st_buf.st_dev) &&

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 =A0 =A0 =A0 =A0 (file_ino =3D=3D st_buf.st_ino))) {

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D is_loop_device(mnt->mnt_fsname)=

;

utils.c

Quoted 6 lines
utils.c +6 -0
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(ret < 0)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out_err;
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(ret) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Current entry is a l=

oop device */

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((loop_fd =3D open(m=

nt->mnt_fsname, O_RDONLY)) < 0) {

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D=

-errno;

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto ou=

t_err;

Quoted 3 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Get loop device info=

and check */

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ioctl(loop_fd, LOOP=

_GET_STATUS, &loopinfo) =3D=3D 0) {

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D=

is_same_blk_file(file, loopinfo.lo_name);

Quoted 2 lines

+
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(ret =

< 0)

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 goto out_err;

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 else if=

(ret)

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0break;

Quoted 2 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D=

-errno;

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto ou=

t_err;

Quoted 3 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* normal block device =

*/

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(is_same_blk_file(fil=

e, mnt->mnt_fsname) > 0)

Quoted 42 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0}

utils.c +1 -0
@@ -634,6 +695,7 @@ int check_mounted(char *file)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D 1;
 =A0 =A0 =A0 =A0}
 
+out_err:
 =A0 =A0 =A0 =A0endmntent (f);
 =A0 =A0 =A0 =A0return ret;
 =A0}
utils.h +0 -0
index 7ff542b..695686b 100644
@@ -19,6 +19,12 @@

=A0#ifndef __UTILS__
=A0#define __UTILS__

utils.h +6 -0
+#define LOOP_MAJOR 7
+
+#ifndef major
+#define major(dev) =A0 =A0 ((dev) >> 8)
+#endif
+

=A0#define BTRFS_MKFS_SYSTEM_GROUP_SIZE (4 * 1024 * 1024)

=A0int make_btrfs(int fd, const char *device, const char *label,

volumes.c +0 -0
index 7671855..467f552 100644
@@ -29,6 +29,7 @@

=A0#include "transaction.h"
=A0#include "print-tree.h"
=A0#include "volumes.h"
+#include "utils.h"

=A0struct stripe {
=A0 =A0 =A0 =A0struct btrfs_device *dev;

volumes.c again: · line 167

Quoted 4 lines
volumes.c +0 -1
@@ -164,7 +165,7 @@ again:
 =A0 =A0 =A0 =A0return 0;
 =A0}
 
-int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flag=

s)

volumes.c again: · line 168

Quoted 1 line
volumes.c +1 -0
+int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flag=

s, int check_mount)

volumes.c int btrfs_open_devices(struct btrfs_fs_devices *=

Quoted 4 lines
volumes.c +0 -0
 =A0{
 =A0 =A0 =A0 =A0int fd;
 =A0 =A0 =A0 =A0struct list_head *head =3D &fs_devices->devices;
@@ -175,6 +176,19 @@ int btrfs_open_devices(struct btrfs_fs_devices *=

fs_devices, int flags)

Quoted 2 lines
volumes.c +0 -0
 =A0 =A0 =A0 =A0list_for_each(cur, head) {

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0device =3D list_entry(cur, struct btrf=

s_device, dev_list);

Quoted 3 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(check_mount) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D check_mounted(d=

evice->name);

Quoted 2 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ret < 0) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf=

(stderr, "error checking %s mount status\n", device->name);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto fa=

il;

Quoted 3 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ret =3D=3D 1) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fprintf=

(stderr, "Error: %s is currently mounted.\n", device->name);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D=

-EBUSY;

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto fa=

il;

volumes.c static int fill_device_from_item(struct extent_=

Quoted 7 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
+
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0fd =3D open(device->name, flags); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (fd < 0) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D -errno;

volumes.c +0 -0
@@ -1240,7 +1254,7 @@ static int fill_device_from_item(struct extent_=

buffer *leaf,

volumes.c static int fill_device_from_item(struct extent_= · line 1257

Quoted 5 lines
volumes.c +1 -1
 =A0 =A0 =A0 =A0return 0;
 =A0}
 
-static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
+static int open_seed_devices(struct btrfs_root *root, u8 *fsid, int =

check_mount)

volumes.c static int open_seed_devices(struct btrfs_root =

Quoted 4 lines
volumes.c +0 -0
 =A0{
 =A0 =A0 =A0 =A0struct btrfs_fs_devices *fs_devices;
 =A0 =A0 =A0 =A0int ret;
@@ -1260,7 +1274,7 @@ static int open_seed_devices(struct btrfs_root =

*root, u8 *fsid)

volumes.c static int open_seed_devices(struct btrfs_root = · line 1277

Quoted 5 lines
volumes.c +1 -1
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out;
 =A0 =A0 =A0 =A0}
 
- =A0 =A0 =A0 ret =3D btrfs_open_devices(fs_devices, O_RDONLY);
+ =A0 =A0 =A0 ret =3D btrfs_open_devices(fs_devices, O_RDONLY, check_=

mount);

Quoted 7 lines
volumes.c +0 -0
 =A0 =A0 =A0 =A0if (ret)
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out;
 
@@ -1272,7 +1286,8 @@ out:
 
 =A0static int read_one_dev(struct btrfs_root *root,

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct extent_buffer *=

leaf,

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct btrfs_dev_item *=

dev_item)

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct btrfs_dev_item *=

dev_item,

volumes.c static int read_one_dev(struct btrfs_root *root=

Quoted 5 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int check_mount) =A0{
=A0 =A0 =A0 =A0struct btrfs_device *device;
=A0 =A0 =A0 =A0u64 devid;

volumes.c +0 -0
@@ -1289,7 +1304,7 @@ static int read_one_dev(struct btrfs_root *root=

,

Quoted 3 lines
volumes.c +0 -0
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 BTRFS_UUID_SIZE);
 

=A0 =A0 =A0 =A0if (memcmp(fs_uuid, root->fs_info->fsid, BTRFS_UUID_SI=

ZE)) {

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D open_seed_devices(root, fs_uuid=

);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D open_seed_devices(root, fs_uuid=

, check_mount);

volumes.c static int read_one_dev(struct btrfs_root *ro=

Quoted 4 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (ret)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return ret; =A0 =A0 =A0 =A0}

volumes.c +0 -0
@@ -1311,13 +1326,13 @@ static int read_one_dev(struct btrfs_root *ro=

ot,

volumes.c static int read_one_dev(struct btrfs_root *ro= · line 1314

Quoted 4 lines
volumes.c +0 -1
 =A0 =A0 =A0 =A0return ret;
 =A0}
 
-int btrfs_read_super_device(struct btrfs_root *root, struct extent_b=

uffer *buf)

volumes.c static int read_one_dev(struct btrfs_root *ro= · line 1329

Quoted 1 line
volumes.c +1 -0
+int btrfs_read_super_device(struct btrfs_root *root, struct extent_b=

uffer *buf, int check_mount)

Quoted 4 lines
volumes.c +0 -0
 =A0{
 =A0 =A0 =A0 =A0struct btrfs_dev_item *dev_item;
 

=A0 =A0 =A0 =A0dev_item =3D (struct btrfs_dev_item *)offsetof(struct =

btrfs_super_block,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_item);

volumes.c int btrfs_read_sys_array(struct btrfs_root *roo=

Quoted 6 lines

- =A0 =A0 =A0 return read_one_dev(root, buf, dev_item);
+ =A0 =A0 =A0 return read_one_dev(root, buf, dev_item, check_mount); =A0}

=A0int btrfs_read_sys_array(struct btrfs_root *root)

volumes.c +0 -0
@@ -1378,7 +1393,7 @@ int btrfs_read_sys_array(struct btrfs_root *roo=

t)

Quoted 10 lines
volumes.c +1 -1
 =A0 =A0 =A0 =A0return 0;
 =A0}
 
-int btrfs_read_chunk_tree(struct btrfs_root *root)
+int btrfs_read_chunk_tree(struct btrfs_root *root, int check_mount)
 =A0{
 =A0 =A0 =A0 =A0struct btrfs_path *path;
 =A0 =A0 =A0 =A0struct extent_buffer *leaf;
@@ -1421,7 +1436,7 @@ again:

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct=

btrfs_dev_item *dev_item;

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_it=

em =3D btrfs_item_ptr(leaf, slot,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 =A0 =A0 =A0 =A0 =A0struct btrfs_dev_item);

Quoted 1 line

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D=

read_one_dev(root, leaf, dev_item);

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D=

read_one_dev(root, leaf, dev_item, check_mount);

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BUG_ON=

(ret);

Quoted 2 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else if (found_key.type =3D=3D BTRFS=

_CHUNK_ITEM_KEY) {

volumes.h int btrfs_rmap_block(struct btrfs_mapping_tree =

Quoted 5 lines
volumes.h +0 -0
index bb78751..baf12ff 100644
@@ -103,16 +103,16 @@ int btrfs_rmap_block(struct btrfs_mapping_tree =

*map_tree,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u64 chunk_start, u64 physical=

, u64 devid,

Quoted 1 line

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 u64 **logical, int *naddrs, i=

nt *stripe_len);

Quoted 5 lines

=A0int btrfs_read_sys_array(struct btrfs_root *root);

volumes.h +1 -1
-int btrfs_read_chunk_tree(struct btrfs_root *root);
+int btrfs_read_chunk_tree(struct btrfs_root *root, int check_mount);

=A0int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0struct btrfs_root *extent_=

root, u64 *start,

Quoted 2 lines

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0u64 *num_bytes, u64 type); -int btrfs_read_super_device(struct btrfs_root *root, struct extent_b=

uffer *buf);

Quoted 1 line

+int btrfs_read_super_device(struct btrfs_root *root, struct extent_b=

uffer *buf, int check_mount);

Quoted 6 lines

=A0int btrfs_add_device(struct btrfs_trans_handle *trans, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct btrfs_root *root, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct btrfs_device *device); =A0int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int flags);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int flags, int check_mou=

nt);

Quoted 5 lines

=A0int btrfs_close_devices(struct btrfs_fs_devices *fs_devices); =A0int btrfs_add_device(struct btrfs_trans_handle *trans, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct btrfs_root *root, --
To unsubscribe from this list: send the line "unsubscribe linux-btrfs=

" in

Quoted 3 lines

the body of a message to [email protected]
More majordomo info at =A0http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Hi!
Thanks for the review.

Quoted 3 lines

Would you please add mounted check for multiple devices FS to check_mounted instead of btrfs_open_devices. It's easy to get the list of devices, see code at very beginning of open_ctree_fd().

The new patch is almost done, but it still needs some testing. I'll submit it as soon as all tests are fine.
Are we interested in automated tests? So far, I've written some very simple shell scripts. Do we have a place to put this kind of code? All I could find about that is an entry in the wiki, which says that a "QA Suite for automated regression testing" is planned for v1.0.

Cheers,
Andi