libblkid: (bcache) also calculate checksum over journal buckets
Fixes #2291 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
This commit is contained in:
parent
158639a2a4
commit
00a19fb8cd
3 changed files with 17 additions and 5 deletions
|
@ -140,8 +140,6 @@ struct bcachefs_super_block {
|
|||
#define BCACHE_SB_MAGIC_OFF offsetof(struct bcache_super_block, magic)
|
||||
/* start of checksummed data within superblock */
|
||||
#define BCACHE_SB_CSUMMED_START 8
|
||||
/* end of checksummed data within superblock */
|
||||
#define BCACHE_SB_CSUMMED_END 208
|
||||
/* granularity of offset and length fields within superblock */
|
||||
#define BCACHEFS_SECTOR_SIZE 512
|
||||
/* maximum superblock size */
|
||||
|
@ -156,9 +154,19 @@ struct bcachefs_super_block {
|
|||
static int bcache_verify_checksum(blkid_probe pr, const struct blkid_idmag *mag,
|
||||
const struct bcache_super_block *bcs)
|
||||
{
|
||||
unsigned char *csummed = blkid_probe_get_sb_buffer(pr, mag, BCACHE_SB_CSUMMED_END);
|
||||
uint64_t csum = ul_crc64_we(csummed + BCACHE_SB_CSUMMED_START,
|
||||
BCACHE_SB_CSUMMED_END - BCACHE_SB_CSUMMED_START);
|
||||
const unsigned char *csummed;
|
||||
size_t csummed_size;
|
||||
uint64_t csum;
|
||||
|
||||
if (le16_to_cpu(bcs->keys) > ARRAY_SIZE(bcs->d))
|
||||
return 0;
|
||||
|
||||
/* up to the end of bcs->d[] */
|
||||
csummed_size = offsetof(typeof(*bcs), d) +
|
||||
sizeof(bcs->d[0]) * le16_to_cpu(bcs->keys);
|
||||
csummed = blkid_probe_get_sb_buffer(pr, mag, csummed_size);
|
||||
csum = ul_crc64_we(csummed + BCACHE_SB_CSUMMED_START,
|
||||
csummed_size - BCACHE_SB_CSUMMED_START);
|
||||
return blkid_probe_verify_csum(pr, csum, le64_to_cpu(bcs->csum));
|
||||
}
|
||||
|
||||
|
|
4
tests/expected/blkid/low-probe-bcache-journal
Normal file
4
tests/expected/blkid/low-probe-bcache-journal
Normal file
|
@ -0,0 +1,4 @@
|
|||
ID_FS_TYPE=bcache
|
||||
ID_FS_USAGE=other
|
||||
ID_FS_UUID=fc6ea56f-372e-474e-bc5b-2ddc8430ddd1
|
||||
ID_FS_UUID_ENC=fc6ea56f-372e-474e-bc5b-2ddc8430ddd1
|
BIN
tests/ts/blkid/images-fs/bcache-journal.img.xz
Normal file
BIN
tests/ts/blkid/images-fs/bcache-journal.img.xz
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue