2 * Copyright (c) 2000-2004 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * Write a bunch of holes to create a bunch of extents.
26 __uint64_t num_holes = 1000;
32 unsigned int blocksize;
33 __uint64_t fileoffset;
38 fprintf(stderr, "%s [-b blocksize] [-n num-holes] [-s status-num]"
39 " [-o start-offset] [-vwp] file\n", progname);
44 main(int argc, char *argv[])
52 unsigned char *buffer = NULL;
57 while ((c = getopt(argc, argv, "b:n:o:ps:vw")) != -1) {
60 blocksize = atoi(optarg);
63 num_holes = atoll(optarg);
75 status_num = atoi(optarg);
78 fileoffset = strtoull(optarg, NULL, 16);
85 filename = argv[optind];
89 buffer = malloc(blocksize);
91 fprintf(stderr, "%s: blocksize to big to allocate buffer\n", progname);
95 oflags = O_RDWR | O_CREAT;
96 oflags |= (preserve ? 0 : O_TRUNC) |
99 if ((fd = open(filename, oflags, 0666)) < 0) {
104 for (i = 0; i < num_holes; i++) {
106 offset = i * 128 * 1024 + fileoffset;
108 if (lseek64(fd, offset, SEEK_SET) < 0) {
113 if (write(fd, buffer, blocksize) < blocksize) {
118 if (verbose_opt && ((i+1) % status_num == 0)) {
119 printf("seeked and wrote %llu times\n", i+1);