root/arch/ppc/kernel/mkboot.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 #include <stdio.h>
   2 #include <sys/types.h>
   3 #include <unistd.h>
   4 #include <fcntl.h>
   5 
   6 /* amount to skip */
   7 #define PLACE 65536
   8 
   9 /* size of read buffer */
  10 #define SIZE 0x200000
  11 
  12 
  13 void main(int argc, char **argv )
     /* [<][>][^][v][top][bottom][index][help] */
  14 {
  15   int fd, fdo;
  16   unsigned char data[SIZE];
  17   int i, n, skip;
  18 
  19   if ( argc != 3 )
  20   {
  21     fprintf(stderr,"%s infile outfile\n", argv[0]);
  22     exit(-1);
  23   }
  24 
  25 
  26   fd = open(argv[1], O_RDONLY);
  27   if ( fd == -1 )
  28   {
  29     fprintf(stderr,"Couldn't open %s\n", argv[1]);
  30     perror("open()");
  31     exit(-1);
  32   }
  33   
  34   fdo = open(argv[2], O_WRONLY|O_CREAT);
  35   if ( fdo == -1 )
  36   {
  37     fprintf(stderr,"Couldn't open %s\n", argv[2]);
  38     perror("open()");
  39     exit(-1);
  40   }
  41 
  42 #if 0
  43   skip = atoi(argv[3]);
  44 #else
  45   skip = PLACE;
  46 #endif
  47   i = lseek(fd, skip, SEEK_SET);
  48   printf("lseek'd %d bytes\n", i);
  49   if ( i == -1 )
  50   {
  51       perror("lseek()");
  52   }
  53 
  54   while ( (n = read(fd, data, SIZE)) > 0 )
  55   {
  56     printf("Read %d bytes\n", n);
  57     i = write(fdo, data, n);
  58     printf("Wrote %d bytes\n", i);    
  59   }
  60 
  61 
  62   close(fdo);
  63   close(fd);
  64   return(0);
  65 }
  66 
  67 

/* [<][>][^][v][top][bottom][index][help] */