2 * Copyright (c) 2000-2001 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
23 #include <sys/types.h>
40 fprintf(stderr,"Usage: %s filename\n", Progname);
64 /* Create the file and make it a regular file. */
66 if ((fd = open(pathname, O_RDWR|O_CREAT|O_EXCL, 0600)) < 0) {
67 fprintf(stderr,"%s: Cannot open %s, %s\n", Progname,
68 pathname, strerror(errno));
72 /* Malloc and zero a buffer to use for writes. */
75 if ((buf = malloc(buflen)) == NULL) {
76 fprintf(stderr,"%s: malloc(%d) returned NULL\n",
80 memset(buf, '\0', buflen);
82 for (i = 0; i < 200; i += 2) {
84 if (lseek(fd, offset, SEEK_SET) < 0) {
85 fprintf(stderr, "seek to %zd failed, %s\n", offset,
89 if ((count = write(fd, buf, buflen)) < 0) {
90 fprintf(stderr, "write of %d bytes failed at offset "
91 "%zd, , %s\n", buflen, offset, strerror(errno));
94 if (count != buflen) {
95 fprintf(stderr, "expected to write %d bytes at offset "
96 "%zd, actually wrote %zd\n", buflen, offset,