root/arch/ppc/kernel/cortstrip.c

/* [previous][next][first][last][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 0x10000*/
   8 
   9 /* size of read buffer */
  10 #define SIZE 0x10000
  11 
  12 void main(int argc, char **argv )
     /* [previous][next][first][last][top][bottom][index][help] */
  13 {
  14   int fd, fdo;
  15   unsigned char data[SIZE];
  16   int i, n, skip;
  17 
  18   if ( argc != 4 )
  19   {
  20     fprintf(stderr,"%s infile outfile skip\n", argv[0]);
  21     exit(-1);
  22   }
  23 
  24 
  25   fd = open(argv[1], O_RDONLY);
  26   if ( fd == -1 )
  27   {
  28     fprintf(stderr,"Couldn't open %s\n", argv[1]);
  29     perror("open()");
  30     exit(-1);
  31   }
  32   
  33   fdo = open(argv[2], O_WRONLY|O_CREAT, 755);
  34   if ( fdo == -1 )
  35   {
  36     fprintf(stderr,"Couldn't open %s\n", argv[2]);
  37     perror("open()");
  38     exit(-1);
  39   }
  40 
  41   skip = atoi(argv[3]);
  42   i = lseek(fd, skip, SEEK_SET);
  43   printf("lseek'd %d bytes\n", i);
  44   if ( i == -1 )
  45   {
  46       perror("lseek()");
  47   }
  48 
  49   while ( (n = read(fd, data, SIZE)) > 0 )
  50   {
  51     printf("Read %d bytes\n", n);
  52     i = write(fdo, data, n);
  53     printf("Wrote %d bytes\n", i);    
  54   }
  55 
  56 
  57   close(fdo);
  58   close(fd);
  59   return(0);
  60 }
  61 
  62 

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