Skip to content

Commit

Permalink
init/do_mounts_rd.c: fix ramdisk identification for padded cramfs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
superna9999 authored and torvalds committed Nov 2, 2011
1 parent 0620d91 commit f919b92
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions init/do_mounts_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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
*/
Expand Down

0 comments on commit f919b92

Please sign in to comment.