blob: a8e4525d7e4ea8e2308c80ef0f22e8d99a69e681 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/* Simple test program for O_APPEND writes (checked by append_reader.c)
*
* Contributed by hatakeyama@bsd.tnes.nec.co.jp
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/param.h>
int main(int argc, char **argv)
{
char file[MAXPATHLEN];
int fd, i, iterations;
if (argc < 2)
exit(1);
iterations = atoi(argv[1]);
sprintf(file, "testfile.%d", getpid());
if ((fd = open(file, O_CREAT | O_RDWR | O_APPEND, 0600)) == -1) {
perror("couldn't open");
exit(1);
}
for (i = 0; i < iterations;i++) {
if (write(fd, &i, sizeof(i)) != sizeof(i)) {
perror("couldn't write");
exit(1);
}
}
exit(0);
}
|