1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
9 * use memory mapping to fill a filesystem! :)
12 #include <sys/types.h>
14 #include <sys/fcntl.h>
21 int fd; /* file descriptor */
22 addr_t ptr; /* mapped pointers */
24 long long junk[512] = { -1 };
27 main(int argc, char * argv[])
30 for (i=0; i<512; i++) junk[i]=-1;
33 if ((progname = strrchr(argv[0], '/')) == NULL)
39 fprintf(stderr,"Usage: %s filename\n", progname);
43 fd = open(argv[1], O_RDWR|O_CREAT, 0644);
45 fprintf(stderr,"%s: cannot open %s\n", progname, argv[1]);
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]);
57 for(counter=0; ; counter++) {
59 bcopy(junk, ptr, sizeof(junk));
62 printf("%s complete.\n", progname);