devpts: remove graffiti
[safe/jmp/linux-2.6] / init / do_mounts_rd.c
index 3ac5904..0f0f0cf 100644 (file)
@@ -9,8 +9,7 @@
 #include <linux/string.h>
 
 #include "do_mounts.h"
-
-#define BUILD_CRAMDISK
+#include "../fs/squashfs/squashfs_fs.h"
 
 int __initdata rd_prompt = 1;/* 1 = prompt for RAM disk, 0 = don't prompt */
 
@@ -43,6 +42,7 @@ static int __init crd_load(int in_fd, int out_fd);
  *     ext2
  *     romfs
  *     cramfs
+ *     squashfs
  *     gzip
  */
 static int __init 
@@ -53,6 +53,7 @@ identify_ramdisk_image(int fd, int start_block)
        struct ext2_super_block *ext2sb;
        struct romfs_super_block *romfsb;
        struct cramfs_super *cramfsb;
+       struct squashfs_super_block *squashfsb;
        int nblocks = -1;
        unsigned char *buf;
 
@@ -64,6 +65,7 @@ identify_ramdisk_image(int fd, int start_block)
        ext2sb = (struct ext2_super_block *) buf;
        romfsb = (struct romfs_super_block *) buf;
        cramfsb = (struct cramfs_super *) buf;
+       squashfsb = (struct squashfs_super_block *) buf;
        memset(buf, 0xe5, size);
 
        /*
@@ -73,7 +75,7 @@ identify_ramdisk_image(int fd, int start_block)
        sys_read(fd, buf, size);
 
        /*
-        * If it matches the gzip magic numbers, return -1
+        * If it matches the gzip magic numbers, return 0
         */
        if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {
                printk(KERN_NOTICE
@@ -101,6 +103,16 @@ identify_ramdisk_image(int fd, int start_block)
                goto done;
        }
 
+       /* squashfs is at block zero too */
+       if (le32_to_cpu(squashfsb->s_magic) == SQUASHFS_MAGIC) {
+               printk(KERN_NOTICE
+                      "RAMDISK: squashfs filesystem found at block %d\n",
+                      start_block);
+               nblocks = (le64_to_cpu(squashfsb->bytes_used) + BLOCK_SIZE - 1)
+                        >> BLOCK_SIZE_BITS;
+               goto done;
+       }
+
        /*
         * Read block 1 to test for minix and ext2 superblock
         */
@@ -162,14 +174,8 @@ int __init rd_load_image(char *from)
                goto done;
 
        if (nblocks == 0) {
-#ifdef BUILD_CRAMDISK
                if (crd_load(in_fd, out_fd) == 0)
                        goto successful_load;
-#else
-               printk(KERN_NOTICE
-                      "RAMDISK: Kernel does not support compressed "
-                      "RAM disk images\n");
-#endif
                goto done;
        }
 
@@ -212,7 +218,7 @@ int __init rd_load_image(char *from)
        }
 
        buf = kmalloc(BLOCK_SIZE, GFP_KERNEL);
-       if (buf == 0) {
+       if (!buf) {
                printk(KERN_ERR "RAMDISK: could not allocate buffer\n");
                goto done;
        }
@@ -267,8 +273,6 @@ int __init rd_load_disk(int n)
        return rd_load_image("/dev/root");
 }
 
-#ifdef BUILD_CRAMDISK
-
 /*
  * gzip declarations
  */
@@ -313,32 +317,11 @@ static int crd_infd, crd_outfd;
 
 static int  __init fill_inbuf(void);
 static void __init flush_window(void);
-static void __init *malloc(size_t size);
-static void __init free(void *where);
 static void __init error(char *m);
-static void __init gzip_mark(void **);
-static void __init gzip_release(void **);
-
-#include "../lib/inflate.c"
-
-static void __init *malloc(size_t size)
-{
-       return kmalloc(size, GFP_KERNEL);
-}
-
-static void __init free(void *where)
-{
-       kfree(where);
-}
-
-static void __init gzip_mark(void **ptr)
-{
-}
 
-static void __init gzip_release(void **ptr)
-{
-}
+#define NO_INFLATE_MALLOC
 
+#include "../lib/inflate.c"
 
 /* ===========================================================================
  * Fill the input buffer. This is called only when the buffer is empty
@@ -425,5 +408,3 @@ static int __init crd_load(int in_fd, int out_fd)
        kfree(window);
        return result;
 }
-
-#endif  /* BUILD_CRAMDISK */