check: allow '-e testid' to exclude a single test
[xfstests-dev.git] / dmapi / src / suite2 / src / mm_fill.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 /*
7  *      mmap_fill
8  * 
9  *      use memory mapping to fill a filesystem! :)
10  */
11 #include <stdio.h>
12 #include <sys/types.h>
13 #include <sys/mman.h>
14 #include <sys/fcntl.h>
15 #include <sys/stat.h>
16 #include <strings.h>
17 #include <errno.h>
18
19
20 char * progname;
21 int     fd;                     /* file descriptor */
22 addr_t  ptr;                    /* mapped pointers */
23 off_t   off;
24 long long  junk[512] = { -1 };
25 long long counter;
26
27 main(int argc, char * argv[])
28
29   int i;
30   for (i=0; i<512; i++) junk[i]=-1;
31   
32
33   if ((progname = strrchr(argv[0], '/')) == NULL)
34     progname = argv[0];
35   else
36     progname++;
37   
38   if (argc < 2) {
39     fprintf(stderr,"Usage: %s filename\n", progname);
40     exit(1);
41   }
42   
43   fd = open(argv[1], O_RDWR|O_CREAT, 0644);
44   if (fd < 0) {
45     fprintf(stderr,"%s: cannot open %s\n", progname, argv[1]);
46     perror(argv[1]);
47     exit(3);
48   }
49
50   ptr = mmap64(NULL, (size_t)(0x10000000), PROT_WRITE, MAP_SHARED|MAP_AUTOGROW, fd, 0);
51   if (ptr == MAP_FAILED) {
52     fprintf(stderr,"%s: cannot mmap64 %s\n", progname, argv[1]);
53     perror(argv[1]);
54     exit(3);
55   }
56   
57   for(counter=0; ; counter++) {
58     junk[0] = counter;
59     bcopy(junk, ptr, sizeof(junk));
60     ptr+=sizeof(junk);
61   }
62   printf("%s complete.\n", progname);
63   return 0;
64 }