From b2d004db187f844dd3590624ed85722318eff8d8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 25 Dec 2011 22:44:42 +0100 Subject: [PATCH] * grub-core/fs/minix.c (grub_minix_mount) [MODE_MINIX3]: Treat 0xffff as 1024 in block size field. Found on one of my test images. Small optimisation while on it. --- ChangeLog | 6 ++++++ grub-core/fs/minix.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1216c833..228603524 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-12-25 Vladimir Serbinenko + + * grub-core/fs/minix.c (grub_minix_mount) [MODE_MINIX3]: Treat 0xffff + as 1024 in block size field. Found on one of my test images. + Small optimisation while on it. + 2011-12-25 Vladimir Serbinenko * docs/grub.texi (Filesystems): Mention SFS as Latin1 filesystem. diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index 401883e36..0128f1d8c 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -480,12 +480,18 @@ grub_minix_mount (grub_disk_t disk) data->disk = disk; data->linknest = 0; #ifdef MODE_MINIX3 - if ((grub_le_to_cpu16 (data->sblock.block_size) - & (grub_le_to_cpu16 (data->sblock.block_size) - 1)) - || grub_le_to_cpu16 (data->sblock.block_size) == 0) - goto fail; - for (data->log_block_size = 0; (1 << data->log_block_size) - < grub_le_to_cpu16 (data->sblock.block_size); data->log_block_size++); + /* These tests are endian-independent. No need to byteswap. */ + if (data->sblock.block_size == 0xffff) + data->log_block_size = 10; + else + { + if ((data->sblock.block_size & (data->sblock.block_size - 1)) + || data->sblock.block_size == 0) + goto fail; + for (data->log_block_size = 0; (1 << data->log_block_size) + < grub_le_to_cpu16 (data->sblock.block_size); + data->log_block_size++); + } #else data->log_block_size = 10; #endif