#include #include #include #include /* * make mysteryfile1 -- simply pass it a number of bytes * and this program makes a file that * large. Then use ls -s to see the * number of blocks used... * * usage: makemystery1 filename size */ #define LINELEN 50 int main(int ac, char *av[]) { char *filename; long filesize; int fd; char buf[BUFSIZ]; int i; /** * arg handling **/ if ( ac != 3 ){ fprintf(stderr,"usage: makemystery1 filename filesize\n"); exit(1); } filename = av[1]; filesize = atol(av[2]); /** * initial steps **/ if ( (fd=creat(filename,0644)) == -1 ){ perror(filename); exit(2); } for(i=0;i 0 ){ write(fd, buf, (filesize>=BUFSIZ?BUFSIZ:filesize)); filesize -= BUFSIZ; } close(fd); return 0; }