-#ifdef CONFIG_RD_GZIP
- /*
- * If it matches the gzip magic numbers, return 0
- */
- if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {
- printk(KERN_NOTICE
- "RAMDISK: Compressed image found at block %d\n",
- start_block);
- *decompressor = gunzip;
- nblocks = 0;
- goto done;
- }
-#endif
-
-#ifdef CONFIG_RD_BZIP2
- /*
- * If it matches the bzip2 magic numbers, return -1
- */
- if (buf[0] == 0x42 && (buf[1] == 0x5a)) {
- printk(KERN_NOTICE
- "RAMDISK: Bzipped image found at block %d\n",
- start_block);
- *decompressor = bunzip2;
- nblocks = 0;
- goto done;
- }
-#endif
-
-#ifdef CONFIG_RD_LZMA
- /*
- * If it matches the lzma magic numbers, return -1
- */
- if (buf[0] == 0x5d && (buf[1] == 0x00)) {
- printk(KERN_NOTICE
- "RAMDISK: Lzma image found at block %d\n",
- start_block);
- *decompressor = unlzma;
- nblocks = 0;
- goto done;
+ for (cf = compressed_formats; cf->decompressor; cf++) {
+ if (buf[0] == cf->magic[0] && buf[1] == cf->magic[1]) {
+ printk(KERN_NOTICE
+ "RAMDISK: %s image found at block %d\n",
+ cf->name, start_block);
+ *decompressor = cf->decompressor;
+ nblocks = 0;
+ goto done;
+ }