diff options
-rw-r--r-- | util-linux/volume_id/btrfs.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/util-linux/volume_id/btrfs.c b/util-linux/volume_id/btrfs.c index 53bac7438..777b80923 100644 --- a/util-linux/volume_id/btrfs.c +++ b/util-linux/volume_id/btrfs.c | |||
@@ -80,19 +80,26 @@ struct btrfs_super_block { | |||
80 | 80 | ||
81 | int FAST_FUNC volume_id_probe_btrfs(struct volume_id *id /*,uint64_t off*/) | 81 | int FAST_FUNC volume_id_probe_btrfs(struct volume_id *id /*,uint64_t off*/) |
82 | { | 82 | { |
83 | #define off ((uint64_t) (64 * 1024)) | 83 | // btrfs has superblocks at 64K, 64M and 256G |
84 | // minimum btrfs size is 256M | ||
85 | // so we never step out the device if we analyze | ||
86 | // the first and the second superblocks | ||
84 | struct btrfs_super_block *sb; | 87 | struct btrfs_super_block *sb; |
88 | unsigned off = 64; | ||
85 | 89 | ||
86 | dbg("btrfs: probing at offset 0x%llx", (unsigned long long) off); | 90 | while (off < 64*1024*1024) { |
91 | off *= 1024; | ||
92 | dbg("btrfs: probing at offset 0x%x", off); | ||
87 | 93 | ||
88 | sb = volume_id_get_buffer(id, off, sizeof(*sb)); | 94 | sb = volume_id_get_buffer(id, off, sizeof(*sb)); |
89 | if (sb == NULL) | 95 | if (sb == NULL) |
90 | return -1; | 96 | return -1; |
91 | 97 | ||
92 | if (memcmp(sb->magic, BTRFS_MAGIC, 8) != 0) | 98 | if (memcmp(sb->magic, BTRFS_MAGIC, 8) != 0) |
93 | return -1; | 99 | return -1; |
100 | } | ||
94 | 101 | ||
95 | // N.B.: btrfs supports 256-byte labels | 102 | // N.B.: btrfs natively supports 256 (>VOLUME_ID_LABEL_SIZE) size labels |
96 | volume_id_set_label_string(id, sb->label, VOLUME_ID_LABEL_SIZE); | 103 | volume_id_set_label_string(id, sb->label, VOLUME_ID_LABEL_SIZE); |
97 | volume_id_set_uuid(id, sb->fsid, UUID_DCE); | 104 | volume_id_set_uuid(id, sb->fsid, UUID_DCE); |
98 | 105 | ||