]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
init/do_mounts_rd.c: fix ramdisk identification for padded cramfs
authorNeil Armstrong <narmstrong@neotion.com>
Mon, 24 Oct 2011 14:59:03 +0000 (01:59 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 7 Nov 2011 02:40:30 +0000 (13:40 +1100)
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>
init/do_mounts_rd.c

index 887629e24c54a5065aa0ee9aca16bbe5d0becc66..e79c0234b7c76d583d81368c9edf20184ced93f1 100644 (file)
@@ -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
         */