summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ctree.h6
-rw-r--r--utils.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/ctree.h b/ctree.h
index b9fb732c..89e47abd 100644
--- a/ctree.h
+++ b/ctree.h
@@ -40,6 +40,12 @@ struct btrfs_trans_handle;
struct btrfs_free_space_ctl;
#define BTRFS_MAGIC 0x4D5F53665248425FULL /* ascii _BHRfS_M, no null */
+/*
+ * Fake signature for an unfinalized filesystem, structures might be partially
+ * created or missing.
+ */
+#define BTRFS_MAGIC_PARTIAL 0x4D5F536652484221ULL /* ascii !BHRfS_M, no null */
+
#define BTRFS_MAX_MIRRORS 3
#define BTRFS_MAX_LEVEL 8
diff --git a/utils.c b/utils.c
index 8be0e753..e7195b53 100644
--- a/utils.c
+++ b/utils.c
@@ -2400,7 +2400,12 @@ int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
ret = 0;
disk_super = (struct btrfs_super_block *)buf;
- if (btrfs_super_magic(disk_super) != BTRFS_MAGIC)
+ /*
+ * Accept devices from the same filesystem, allow partially created
+ * structures.
+ */
+ if (btrfs_super_magic(disk_super) != BTRFS_MAGIC &&
+ btrfs_super_magic(disk_super) != BTRFS_MAGIC_PARTIAL)
goto brelse;
if (!memcmp(disk_super->fsid, root->fs_info->super_copy->fsid,