root/drivers/block/rd.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rd_request
  2. rd_ioctl
  3. initrd_read
  4. initrd_release
  5. rd_open
  6. rd_release
  7. rd_init
  8. init_module
  9. cleanup_module
  10. identify_ramdisk_image
  11. rd_load_image
  12. rd_load
  13. initrd_load
  14. malloc
  15. free
  16. gzip_mark
  17. gzip_release
  18. fill_inbuf
  19. flush_window
  20. error
  21. crd_load

   1 /*
   2  * ramdisk.c - Multiple ramdisk driver - gzip-loading version - v. 0.8 beta.
   3  * 
   4  * (C) Chad Page, Theodore Ts'o, et. al, 1995. 
   5  *
   6  * This ramdisk is designed to have filesystems created on it and mounted
   7  * just like a regular floppy disk.  
   8  *  
   9  * It also does something suggested by Linus: use the buffer cache as the
  10  * ramdisk data.  This makes it possible to dynamically allocate the ramdisk
  11  * buffer - with some consequences I have to deal with as I write this. 
  12  * 
  13  * This code is based on the original ramdisk.c, written mostly by
  14  * Theodore Ts'o (TYT) in 1991.  The code was largely rewritten by
  15  * Chad Page to use the buffer cache to store the ramdisk data in
  16  * 1995; Theodore then took over the driver again, and cleaned it up
  17  * for inclusion in the mainline kernel.
  18  *
  19  * The original CRAMDISK code was written by Richard Lyons, and
  20  * adapted by Chad Page to use the new ramdisk interface.  Theodore
  21  * Ts'o rewrote it so that both the compressed ramdisk loader and the
  22  * kernel decompressor uses the same inflate.c codebase.  The ramdisk
  23  * loader now also loads into a dynamic (buffer cache based) ramdisk,
  24  * not the old static ramdisk.  Support for the old static ramdisk has
  25  * been completely removed.
  26  *
  27  * Loadable module support added by Tom Dyas.
  28  *
  29  * Further cleanups by Chad Page (page0588@sundance.sjsu.edu):
  30  *      Cosmetic changes in #ifdef MODULE, code movement, etc...
  31  *      When the ramdisk is rmmod'ed, free the protected buffers
  32  *      Default ramdisk size changed to 2.88MB
  33  *
  34  *  Added initrd: Werner Almesberger & Hans Lermen, Feb '96
  35  *
  36  * 4/25/96 : Made ramdisk size a parameter (default is now 4MB) 
  37  *              - Chad Page
  38  */
  39 
  40 #include <linux/config.h>
  41 #include <linux/sched.h>
  42 #include <linux/minix_fs.h>
  43 #include <linux/ext2_fs.h>
  44 #include <linux/fs.h>
  45 #include <linux/kernel.h>
  46 #include <linux/string.h>
  47 #include <linux/mm.h>
  48 #include <linux/mman.h>
  49 #include <linux/malloc.h>
  50 #include <linux/ioctl.h>
  51 #include <linux/fd.h>
  52 #include <linux/module.h>
  53 
  54 #include <asm/system.h>
  55 #include <asm/segment.h>
  56 
  57 extern void wait_for_keypress(void);
  58 
  59 /*
  60  * 35 has been officially registered as the RAMDISK major number, but
  61  * so is the original MAJOR number of 1.  We're using 1 in
  62  * include/linux/major.h for now
  63  */
  64 #define MAJOR_NR RAMDISK_MAJOR
  65 #include <linux/blk.h>
  66 
  67 /* The ramdisk size is now a parameter */
  68 #define NUM_RAMDISKS 16         /* This cannot be overridden (yet) */ 
  69 
  70 #ifndef MODULE
  71 /* We don't have to load ramdisks or gunzip them in a module... */
  72 #define RD_LOADER
  73 #define BUILD_CRAMDISK
  74 
  75 void rd_load(void);
  76 static int crd_load(struct file *fp, struct file *outfp);
  77 
  78 #ifdef CONFIG_BLK_DEV_INITRD
  79 static int initrd_users = 0;
  80 #endif
  81 #endif
  82 
  83 /* Various static variables go here... mostly used within the ramdisk code only. */
  84 
  85 static int rd_length[NUM_RAMDISKS];
  86 static int rd_blocksizes[NUM_RAMDISKS];
  87 
  88 /*
  89  * Parameters for the boot-loading of the ramdisk.  These are set by
  90  * init/main.c (from arguments to the kernel command line) or from the
  91  * architecture-specific setup routine (from the stored bootsector
  92  * information). 
  93  */
  94 int rd_size = 4096;             /* Size of the ramdisks */
  95 
  96 #ifndef MODULE
  97 int rd_doload = 0;              /* 1 = load ramdisk, 0 = don't load */
  98 int rd_prompt = 1;              /* 1 = prompt for ramdisk, 0 = don't prompt */
  99 int rd_image_start = 0;         /* starting block # of image */
 100 #ifdef CONFIG_BLK_DEV_INITRD
 101 unsigned long initrd_start,initrd_end;
 102 int mount_initrd = 1;           /* zero if initrd should not be mounted */
 103 #endif
 104 #endif
 105 
 106 /*
 107  *  Basically, my strategy here is to set up a buffer-head which can't be
 108  *  deleted, and make that my Ramdisk.  If the request is outside of the
 109  *  allocated size, we must get rid of it...
 110  *
 111  */
 112 static void rd_request(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 113 {
 114         unsigned int minor;
 115         int offset, len;
 116 
 117 repeat:
 118         INIT_REQUEST;
 119         
 120         minor = MINOR(CURRENT->rq_dev);
 121 
 122         if (minor >= NUM_RAMDISKS) {
 123                 end_request(0);
 124                 goto repeat;
 125         }
 126         
 127         offset = CURRENT->sector << 9;
 128         len = CURRENT->current_nr_sectors << 9;
 129 
 130         if ((offset + len) > rd_length[minor]) {
 131                 end_request(0);
 132                 goto repeat;
 133         }
 134 
 135         /*
 136          * If we're reading, fill the buffer with 0's.  This is okay since
 137          * we're using protected buffers which should never get freed...
 138          *
 139          * If we're writing, we protect the buffer.
 140          */
 141 
 142         if (CURRENT->cmd == READ) 
 143                 memset(CURRENT->buffer, 0, len); 
 144         else    
 145                 set_bit(BH_Protected, &CURRENT->bh->b_state);
 146 
 147         end_request(1);
 148         goto repeat;
 149 } 
 150 
 151 static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 152 {
 153         int err;
 154         
 155         if (!inode || !inode->i_rdev)   
 156                 return -EINVAL;
 157 
 158         switch (cmd) {
 159                 case BLKFLSBUF:
 160                         if (!suser()) return -EACCES;
 161                         invalidate_buffers(inode->i_rdev);
 162                         break;
 163                 case BLKGETSIZE:   /* Return device size */
 164                         if (!arg)  return -EINVAL;
 165                         err = verify_area(VERIFY_WRITE, (long *) arg,
 166                                           sizeof(long));
 167                         if (err)
 168                                 return err;
 169                         put_user(rd_length[MINOR(inode->i_rdev)] / 512, 
 170                                  (long *) arg);
 171                         return 0;
 172                         
 173                 default:
 174                         break;
 175         };
 176 
 177         return 0;
 178 }
 179 
 180 
 181 #ifdef CONFIG_BLK_DEV_INITRD
 182 
 183 static int initrd_read(struct inode *inode,struct file *file,char *buf,
     /* [previous][next][first][last][top][bottom][index][help] */
 184     int count)
 185 {
 186         int left;
 187 
 188         left = initrd_end-initrd_start-file->f_pos;
 189         if (count > left) count = left;
 190         if (count <= 0) return 0;
 191         memcpy_tofs(buf,(char *) initrd_start+file->f_pos,count);
 192         file->f_pos += count;
 193         return count;
 194 }
 195 
 196 
 197 static void initrd_release(struct inode *inode,struct file *file)
     /* [previous][next][first][last][top][bottom][index][help] */
 198 {
 199         unsigned long i;
 200 
 201         if (--initrd_users) return;
 202         for (i = initrd_start; i < initrd_end; i += PAGE_SIZE)
 203                 free_page(i);
 204         initrd_start = 0;
 205 }
 206 
 207 
 208 static struct file_operations initrd_fops = {
 209         NULL,           /* lseek */
 210         initrd_read,    /* read */
 211         NULL,           /* write */
 212         NULL,           /* readdir */
 213         NULL,           /* select */
 214         NULL,           /* ioctl */
 215         NULL,           /* mmap */
 216         NULL,           /* open */
 217         initrd_release, /* release */
 218         NULL            /* fsync */ 
 219 };
 220 
 221 #endif
 222 
 223 
 224 static int rd_open(struct inode * inode, struct file * filp)
     /* [previous][next][first][last][top][bottom][index][help] */
 225 {
 226 #ifdef CONFIG_BLK_DEV_INITRD
 227         if (DEVICE_NR(inode->i_rdev) == INITRD_MINOR) {
 228                 if (!initrd_start) return -ENODEV;
 229                 initrd_users++;
 230                 filp->f_op = &initrd_fops;
 231                 return 0;
 232         }
 233 #endif
 234 
 235         if (DEVICE_NR(inode->i_rdev) >= NUM_RAMDISKS)
 236                 return -ENODEV;
 237 
 238         MOD_INC_USE_COUNT;
 239 
 240         return 0;
 241 }
 242 
 243 #ifdef MODULE
 244 static void rd_release(struct inode * inode, struct file * filp)
     /* [previous][next][first][last][top][bottom][index][help] */
 245 {
 246         MOD_DEC_USE_COUNT;
 247 }
 248 #endif
 249 
 250 static struct file_operations fd_fops = {
 251         NULL,           /* lseek - default */
 252         block_read,     /* read - block dev read */
 253         block_write,    /* write - block dev write */
 254         NULL,           /* readdir - not here! */
 255         NULL,           /* select */
 256         rd_ioctl,       /* ioctl */
 257         NULL,           /* mmap */
 258         rd_open,        /* open */
 259 #ifndef MODULE
 260         NULL,           /* no special release code... */
 261 #else
 262         rd_release,     /* module needs to decrement use count */
 263 #endif
 264         block_fsync             /* fsync */ 
 265 };
 266 
 267 /* This is the registration and initialization section of the ramdisk driver */
 268 int rd_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 269 {
 270         int             i;
 271 
 272         if (register_blkdev(MAJOR_NR, "ramdisk", &fd_fops)) {
 273                 printk("RAMDISK: Could not get major %d", MAJOR_NR);
 274                 return -EIO;
 275         }
 276 
 277         blk_dev[MAJOR_NR].request_fn = &rd_request;
 278 
 279         for (i = 0; i < NUM_RAMDISKS; i++) {
 280                 rd_length[i] = (rd_size * 1024);
 281                 rd_blocksizes[i] = 1024;
 282         }
 283 
 284         blksize_size[MAJOR_NR] = rd_blocksizes;
 285 
 286         printk("Ramdisk driver initialized : %d ramdisks of %dK size\n",
 287                                                         NUM_RAMDISKS, rd_size);
 288 
 289         return 0;
 290 }
 291 
 292 /* loadable module support */
 293 
 294 #ifdef MODULE
 295 
 296 int init_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 297 {
 298         int error = rd_init();
 299         if (!error)
 300                 printk(KERN_INFO "RAMDISK: Loaded as module.\n");
 301         return error;
 302 }
 303 
 304 /* Before freeing the module, invalidate all of the protected buffers! */
 305 void cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 306 {
 307         int i;
 308 
 309         for (i = 0 ; i < NUM_RAMDISKS; i++)
 310                 invalidate_buffers(MKDEV(MAJOR_NR, i));
 311 
 312         unregister_blkdev( MAJOR_NR, "ramdisk" );
 313         blk_dev[MAJOR_NR].request_fn = 0;
 314 }
 315 
 316 #endif  /* MODULE */
 317 
 318 /* End of non-loading portions of the ramdisk driver */
 319 
 320 #ifdef RD_LOADER 
 321 /*
 322  * This routine tries to a ramdisk image to load, and returns the
 323  * number of blocks to read for a non-compressed image, 0 if the image
 324  * is a compressed image, and -1 if an image with the right magic
 325  * numbers could not be found.
 326  *
 327  * We currently check for the following magic numbers:
 328  *      minix
 329  *      ext2
 330  *      gzip
 331  */
 332 int
 333 identify_ramdisk_image(kdev_t device, struct file *fp, int start_block)
     /* [previous][next][first][last][top][bottom][index][help] */
 334 {
 335         const int size = 512;
 336         struct minix_super_block *minixsb;
 337         struct ext2_super_block *ext2sb;
 338         int nblocks = -1;
 339         int max_blocks;
 340         unsigned char *buf;
 341 
 342         buf = kmalloc(size, GFP_KERNEL);
 343         if (buf == 0)
 344                 return -1;
 345 
 346         minixsb = (struct minix_super_block *) buf;
 347         ext2sb = (struct ext2_super_block *) buf;
 348         memset(buf, 0xe5, size);
 349 
 350         /*
 351          * Read block 0 to test for gzipped kernel
 352          */
 353         if (fp->f_op->lseek)
 354                 fp->f_op->lseek(fp->f_inode, fp, start_block * BLOCK_SIZE, 0);
 355         fp->f_pos = start_block * BLOCK_SIZE;
 356         
 357         fp->f_op->read(fp->f_inode, fp, buf, size);
 358 
 359         /*
 360          * If it matches the gzip magic numbers, return -1
 361          */
 362         if (buf[0] == 037 && ((buf[1] == 0213) || (buf[1] == 0236))) {
 363                 printk(KERN_NOTICE
 364                        "RAMDISK: Compressed image found at block %d\n",
 365                        start_block);
 366                 nblocks = 0;
 367                 goto done;
 368         }
 369 
 370         /*
 371          * Read block 1 to test for minix and ext2 superblock
 372          */
 373         if (fp->f_op->lseek)
 374                 fp->f_op->lseek(fp->f_inode, fp,
 375                                 (start_block+1) * BLOCK_SIZE, 0);
 376         fp->f_pos = (start_block+1) * BLOCK_SIZE;
 377 
 378         fp->f_op->read(fp->f_inode, fp, buf, size);
 379                 
 380         /* Try minix */
 381         if (minixsb->s_magic == MINIX_SUPER_MAGIC ||
 382             minixsb->s_magic == MINIX_SUPER_MAGIC2) {
 383                 printk(KERN_NOTICE
 384                        "RAMDISK: Minix filesystem found at block %d\n",
 385                        start_block);
 386                 nblocks = minixsb->s_nzones << minixsb->s_log_zone_size;
 387                 goto done;
 388         }
 389 
 390         /* Try ext2 */
 391         if (ext2sb->s_magic == EXT2_SUPER_MAGIC) {
 392                 printk(KERN_NOTICE
 393                        "RAMDISK: Ext2 filesystem found at block %d\n",
 394                        start_block);
 395                 nblocks = ext2sb->s_blocks_count;
 396                 goto done;
 397         }
 398         printk(KERN_NOTICE
 399                "RAMDISK: Couldn't find valid ramdisk image starting at %d.\n",
 400                start_block);
 401         
 402 done:
 403         if (fp->f_op->lseek)
 404                 fp->f_op->lseek(fp->f_inode, fp, start_block * BLOCK_SIZE, 0);
 405         fp->f_pos = start_block * BLOCK_SIZE;   
 406 
 407         if ((nblocks > 0) && blk_size[MAJOR(device)]) {
 408                 max_blocks = blk_size[MAJOR(device)][MINOR(device)];
 409                 max_blocks -= start_block;
 410                 if (nblocks > max_blocks) {
 411                         printk(KERN_NOTICE
 412                                "RAMDISK: Restricting filesystem size "
 413                                "from %d to %d blocks.\n",
 414                                nblocks, max_blocks);
 415                         nblocks = max_blocks;
 416                 }
 417         }
 418         kfree(buf);
 419         return nblocks;
 420 }
 421 
 422 /*
 423  * This routine loads in the ramdisk image.
 424  */
 425 static void rd_load_image(kdev_t device,int offset)
     /* [previous][next][first][last][top][bottom][index][help] */
 426 {
 427         struct inode inode, out_inode;
 428         struct file infile, outfile;
 429         unsigned short fs;
 430         kdev_t ram_device;
 431         int nblocks, i;
 432         char *buf;
 433         unsigned short rotate = 0;
 434         char rotator[4] = { '|' , '/' , '-' , '\\' };
 435 
 436         ram_device = MKDEV(MAJOR_NR, 0);
 437 
 438         memset(&infile, 0, sizeof(infile));
 439         memset(&inode, 0, sizeof(inode));
 440         inode.i_rdev = device;
 441         infile.f_mode = 1; /* read only */
 442         infile.f_inode = &inode;
 443 
 444         memset(&outfile, 0, sizeof(outfile));
 445         memset(&out_inode, 0, sizeof(out_inode));
 446         out_inode.i_rdev = ram_device;
 447         outfile.f_mode = 3; /* read/write */
 448         outfile.f_inode = &out_inode;
 449 
 450         if (blkdev_open(&inode, &infile) != 0) return;
 451         if (blkdev_open(&out_inode, &outfile) != 0) return;
 452 
 453         fs = get_fs();
 454         set_fs(KERNEL_DS);
 455         
 456         nblocks = identify_ramdisk_image(device, &infile, offset);
 457         if (nblocks < 0)
 458                 goto done;
 459 
 460         if (nblocks == 0) {
 461 #ifdef BUILD_CRAMDISK
 462                 if (crd_load(&infile, &outfile) == 0)
 463                         goto successful_load;
 464 #else
 465                 printk(KERN_NOTICE
 466                        "RAMDISK: Kernel does not support compressed "
 467                        "ramdisk images\n");
 468 #endif
 469                 goto done;
 470         }
 471 
 472         if (nblocks > (rd_length[0] >> BLOCK_SIZE_BITS)) {
 473                 printk("RAMDISK: image too big! (%d/%d blocks)\n",
 474                        nblocks, rd_length[0] >> BLOCK_SIZE_BITS);
 475                 goto done;
 476         }
 477                 
 478         /*
 479          * OK, time to copy in the data
 480          */
 481         buf = kmalloc(BLOCK_SIZE, GFP_KERNEL);
 482         if (buf == 0) {
 483                 printk(KERN_ERR "RAMDISK: could not allocate buffer\n");
 484                 goto done;
 485         }
 486 
 487         printk(KERN_NOTICE "RAMDISK: Loading %d blocks into ram disk... ", nblocks);
 488         for (i=0; i < nblocks; i++) {
 489                 infile.f_op->read(infile.f_inode, &infile, buf,
 490                                   BLOCK_SIZE);
 491                 outfile.f_op->write(outfile.f_inode, &outfile, buf,
 492                                     BLOCK_SIZE);
 493                 if (!(i % 16)) {
 494                         printk("%c\b", rotator[rotate & 0x3]);
 495                         rotate++;
 496                 }
 497         }
 498         printk("done.\n");
 499         kfree(buf);
 500 
 501 successful_load:
 502         invalidate_buffers(device);
 503         ROOT_DEV = MKDEV(MAJOR_NR,0);
 504 
 505 done:
 506         if (infile.f_op->release)
 507                 infile.f_op->release(&inode, &infile);
 508         set_fs(fs);
 509 }
 510 
 511 
 512 void rd_load()
     /* [previous][next][first][last][top][bottom][index][help] */
 513 {
 514         if (rd_doload == 0)
 515                 return;
 516         
 517         if (MAJOR(ROOT_DEV) != FLOPPY_MAJOR) return;
 518 
 519         if (rd_prompt) {
 520 #ifdef CONFIG_BLK_DEV_FD
 521                 floppy_eject();
 522 #endif
 523                 printk(KERN_NOTICE
 524                        "VFS: Insert root floppy disk to be loaded into ramdisk and press ENTER\n");
 525                 wait_for_keypress();
 526         }
 527 
 528         rd_load_image(ROOT_DEV,rd_image_start);
 529 
 530 }
 531 
 532 
 533 #ifdef CONFIG_BLK_DEV_INITRD
 534 void initrd_load(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 535 {
 536         rd_load_image(MKDEV(MAJOR_NR, INITRD_MINOR),0);
 537 }
 538 #endif
 539 
 540 #endif /* RD_LOADER */
 541 
 542 #ifdef BUILD_CRAMDISK
 543 
 544 /*
 545  * gzip declarations
 546  */
 547 
 548 #define OF(args)  args
 549 
 550 #define memzero(s, n)     memset ((s), 0, (n))
 551 
 552 
 553 typedef unsigned char  uch;
 554 typedef unsigned short ush;
 555 typedef unsigned long  ulg;
 556 
 557 #define INBUFSIZ 4096
 558 #define WSIZE 0x8000    /* window size--must be a power of two, and */
 559                         /*  at least 32K for zip's deflate method */
 560 
 561 static uch *inbuf;
 562 static uch *window;
 563 
 564 static unsigned insize = 0;  /* valid bytes in inbuf */
 565 static unsigned inptr = 0;   /* index of next byte to be processed in inbuf */
 566 static unsigned outcnt = 0;  /* bytes in output buffer */
 567 static exit_code = 0;
 568 static long bytes_out = 0;
 569 static struct file *crd_infp, *crd_outfp;
 570 
 571 #define get_byte()  (inptr < insize ? inbuf[inptr++] : fill_inbuf())
 572                 
 573 /* Diagnostic functions (stubbed out) */
 574 #define Assert(cond,msg)
 575 #define Trace(x)
 576 #define Tracev(x)
 577 #define Tracevv(x)
 578 #define Tracec(c,x)
 579 #define Tracecv(c,x)
 580 
 581 #define STATIC static
 582 
 583 static int  fill_inbuf(void);
 584 static void flush_window(void);
 585 static void *malloc(int size);
 586 static void free(void *where);
 587 static void error(char *m);
 588 static void gzip_mark(void **);
 589 static void gzip_release(void **);
 590 
 591 #include "../../lib/inflate.c"
 592 
 593 static void *malloc(int size)
     /* [previous][next][first][last][top][bottom][index][help] */
 594 {
 595         return kmalloc(size, GFP_KERNEL);
 596 }
 597 
 598 static void free(void *where)
     /* [previous][next][first][last][top][bottom][index][help] */
 599 {
 600         kfree(where);
 601 }
 602 
 603 static void gzip_mark(void **ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 604 {
 605 }
 606 
 607 static void gzip_release(void **ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 608 {
 609 }
 610 
 611 
 612 /* ===========================================================================
 613  * Fill the input buffer. This is called only when the buffer is empty
 614  * and at least one byte is really needed.
 615  */
 616 static int fill_inbuf()
     /* [previous][next][first][last][top][bottom][index][help] */
 617 {
 618         if (exit_code) return -1;
 619         
 620         insize = crd_infp->f_op->read(crd_infp->f_inode, crd_infp,
 621                                       inbuf, INBUFSIZ);
 622         if (insize == 0) return -1;
 623 
 624         inptr = 1;
 625 
 626         return inbuf[0];
 627 }
 628 
 629 /* ===========================================================================
 630  * Write the output window window[0..outcnt-1] and update crc and bytes_out.
 631  * (Used for the decompressed data only.)
 632  */
 633 static void flush_window()
     /* [previous][next][first][last][top][bottom][index][help] */
 634 {
 635     ulg c = crc;         /* temporary variable */
 636     unsigned n;
 637     uch *in, ch;
 638     
 639     crd_outfp->f_op->write(crd_outfp->f_inode, crd_outfp, window,
 640                            outcnt);
 641     in = window;
 642     for (n = 0; n < outcnt; n++) {
 643             ch = *in++;
 644             c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
 645     }
 646     crc = c;
 647     bytes_out += (ulg)outcnt;
 648     outcnt = 0;
 649 }
 650 
 651 static void error(char *x)
     /* [previous][next][first][last][top][bottom][index][help] */
 652 {
 653         printk(KERN_ERR "%s", x);
 654         exit_code = 1;
 655 }
 656 
 657 static int
 658 crd_load(struct file * fp, struct file *outfp)
     /* [previous][next][first][last][top][bottom][index][help] */
 659 {
 660         int result;
 661         
 662         crd_infp = fp;
 663         crd_outfp = outfp;
 664         inbuf = kmalloc(INBUFSIZ, GFP_KERNEL);
 665         if (inbuf == 0) {
 666                 printk(KERN_ERR "RAMDISK: Couldn't allocate gzip buffer\n");
 667                 return -1;
 668         }
 669         window = kmalloc(WSIZE, GFP_KERNEL);
 670         if (window == 0) {
 671                 printk(KERN_ERR "RAMDISK: Couldn't allocate gzip window\n");
 672                 kfree(inbuf);
 673                 return -1;
 674         }
 675         makecrc();
 676         result = gunzip();
 677         kfree(inbuf);
 678         kfree(window);
 679         return result;
 680 }
 681 
 682 #endif  /* BUILD_CRAMDISK */
 683 

/* [previous][next][first][last][top][bottom][index][help] */