1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
11 #include <sys/types.h>
28 fprintf(stderr,"Usage: %s filename\n", Progname);
52 /* Create the file and make it a regular file. */
54 if ((fd = open(pathname, O_RDWR|O_CREAT|O_EXCL, 0600)) < 0) {
55 fprintf(stderr,"%s: Cannot open %s, %s\n", Progname,
56 pathname, strerror(errno));
60 /* Malloc and zero a buffer to use for writes. */
63 if ((buf = malloc(buflen)) == NULL) {
64 fprintf(stderr,"%s: malloc(%d) returned NULL\n",
68 memset(buf, '\0', buflen);
70 for (i = 0; i < 200; i += 2) {
72 if (lseek(fd, offset, SEEK_SET) < 0) {
73 fprintf(stderr, "seek to %zd failed, %s\n", offset,
77 if ((count = write(fd, buf, buflen)) < 0) {
78 fprintf(stderr, "write of %d bytes failed at offset "
79 "%zd, , %s\n", buflen, offset, strerror(errno));
82 if (count != buflen) {
83 fprintf(stderr, "expected to write %d bytes at offset "
84 "%zd, actually wrote %zd\n", buflen, offset,