You've already forked linux-apfs-rw
mirror of
https://github.com/linux-apfs/linux-apfs-rw.git
synced 2026-05-01 15:01:34 -07:00
Check the superblock magic before the block size
When an attempt is made to mount something other than an apfs container, the driver currently throws a confusing "bad blocksize" error to dmesg. I would expect this to be encountered fairly often, when users try to mount the disk as a whole instead of the apfs partition. Start checking the superblock magic before the block size so that we can give a more helpful error message. Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
This commit is contained in:
@@ -115,6 +115,12 @@ static struct buffer_head *apfs_read_super_copy(struct super_block *sb)
|
||||
msb_raw = (struct apfs_nx_superblock *)bh->b_data;
|
||||
blocksize = le32_to_cpu(msb_raw->nx_block_size);
|
||||
|
||||
sb->s_magic = le32_to_cpu(msb_raw->nx_magic);
|
||||
if (sb->s_magic != APFS_NX_MAGIC) {
|
||||
apfs_warn(sb, "not an apfs container - are you mounting the right partition?");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (sb->s_blocksize != blocksize) {
|
||||
brelse(bh);
|
||||
|
||||
@@ -130,11 +136,6 @@ static struct buffer_head *apfs_read_super_copy(struct super_block *sb)
|
||||
msb_raw = (struct apfs_nx_superblock *)bh->b_data;
|
||||
}
|
||||
|
||||
sb->s_magic = le32_to_cpu(msb_raw->nx_magic);
|
||||
if (sb->s_magic != APFS_NX_MAGIC) {
|
||||
apfs_err(sb, "not an apfs filesystem");
|
||||
goto fail;
|
||||
}
|
||||
if (!apfs_obj_verify_csum(sb, bh))
|
||||
apfs_notice(sb, "backup superblock seems corrupted");
|
||||
return bh;
|
||||
|
||||
Reference in New Issue
Block a user