summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@neotion.com>2011-11-02 13:37:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-02 16:06:58 -0700
commitf919b9235f930e649b374a50009c6c268bd9a073 (patch)
treee6e58d209b82add156f53649a78b34f8cdc08222
parent0620d9193cb976ba635d56a6cfd11cb81616d02b (diff)
downloadlinux-3.10-f919b9235f930e649b374a50009c6c268bd9a073.tar.gz
linux-3.10-f919b9235f930e649b374a50009c6c268bd9a073.tar.bz2
linux-3.10-f919b9235f930e649b374a50009c6c268bd9a073.zip
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 <narmstrong@neotion.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Davidlohr Bueso <dave@gnu.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--init/do_mounts_rd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index fe9acb0ae48..887629e24c5 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -120,6 +120,20 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)
}
/*
+ * 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
*/
sys_lseek(fd, (start_block+1) * BLOCK_SIZE, 0);