COMP 301
                       Assignment # 2
Due date: May 16, 2013
Marks = 10

Explain each line of the following program and test it. Also submit a printout of the tests.


#include<sys/types.h>
#include<fcntl.h>
#include<stdlib.h>
#include<unistd.h>
#include<stdio.h>
#define BUF_SIZE 4096
#define OUTPUT_MODE 0700
#define TRUE 1
int main(int argc, char *argv[])
{ int in_fd, out_fd, rd_count, wt_count;
   char buffer[BUF_SIZE];
   if(argc !=3)
   { printf(" Error Too few arguments\n");
      exit(1);
   }
   in_fd = open(argv[1], O_RDONLY);
   if(in_fd <0)
      exit(2);
   out_fd = creat(argv[2], OUTPUT_MODE);
   if(out_fd <0) exit(3);
   while(TRUE)
    { rd_count = read(in_fd, buffer, BUF_SIZE);
       if (rd_count < 0)
           break;
       wt_count = write(out_fd, buffer, rd_count);
       if(wt_count <=0)
           exit(4);
       close(in_fd);
       close(out_fd);
       if (rd_count == 0)
           exit(0);
       else
            exit(5);
      return 0;
    }
}

QUIZ 1 (03-05-2013)

Quiz 1 Includes all the portion cover till file system that is FAT (File allocation table)