From 376ec0dc69fa5d18636c6568ab8152b12689f1aa Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Tue, 25 Oct 2011 01:59:03 +1100 Subject: [PATCH] init/do_mounts_rd.c: fix ramdisk identification for padded cramfs When a cramfs ramdisk padded with 512 bytes is given to the kernel, the current identify_ramdisk_image function fails to identify it. Tested with a padded cramfs image on an ARM based board. Signed-off-by: Neil Armstrong Cc: Namhyung Kim Cc: Davidlohr Bueso Cc: Al Viro Signed-off-by: Andrew Morton --- init/do_mounts_rd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c index 887629e24c54..e79c0234b7c7 100644 --- a/init/do_mounts_rd.c +++ b/init/do_mounts_rd.c @@ -133,6 +133,20 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor) goto done; } + /* + * Read 512 bytes further to check if cramfs is padded + */ + sys_lseek(fd, start_block * BLOCK_SIZE + 0x200, 0); + sys_read(fd, buf, size); + + if (cramfsb->magic == CRAMFS_MAGIC) { + printk(KERN_NOTICE + "RAMDISK: cramfs filesystem found at block %d\n", + start_block); + nblocks = (cramfsb->size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS; + goto done; + } + /* * Read block 1 to test for minix and ext2 superblock */ -- 2.39.5