1    | /*
2    |   mkfile.c
3    |   --------
4    |   Real stupid program to make an empty file.
5    |   Should take advantage of sparse stuff too!
6    | 
7    |   $Id: mkfile.c,v 1.3 2003/10/12 12:58:53 stewart Exp $
8    | 
9    |   (C)2003 Stewart Smith
10   |   Distributed under the GNU Public License
11   |  */
12   | 
13   | #include <stdio.h>
14   | #include <stdlib.h>
15   | #include <unistd.h>
16   | #include <sys/types.h>
17   | #include <sys/stat.h>
18   | #include <fcntl.h>
19   | 
20   | typedef u_int64_t u64;
21   | 
22   | u64 atou64(const char *nptr)
23   | {
24   |   u64 out,i;
25   |   for(out=0,i=0;nptr[i]!='\0';i++)
26   |     {
27   |       out*=10;
28   |       out+=nptr[i]-'0';
29   |     }
30   | 
31   |   return out;
32   | }
33   | 
34   | int main(int argc,char* argv[])
35   | {
36   |   FILE* file;
37   | 
38   |   if(argc<4)
39   |     {
40   |       fprintf(stderr,"Usage:\n");
41   |       fprintf(stderr,"\t%s file bsize blocksnr\n\n",argv[0]);
42   |       exit(1);
43   |     }
44   |  
45   |   file = fopen(argv[1],"w");
46   |   fseek(file,atou64(argv[2])*atou64(argv[3]),SEEK_SET);
47   |   fprintf(file,"%c",0);
48   |   fclose(file);
49   |   return 0;
50   | }