10 static unsigned int msg_size = 4096;
11 static unsigned int file_size = 128;
12 static unsigned long seed = 0x9e37fffffffc0001UL;
14 static int usage(const char *name)
16 fprintf(stderr, "%s: [-s( msg size)] [-z(filesize (mb))] file\n", name);
20 static int parse_options(int argc, char *argv[])
24 while ((c = getopt(argc, argv, "s:z:")) != -1) {
27 msg_size = atoi(optarg);
31 file_size = atoi(optarg);
39 printf("msg_size=%u, file_size=%umb\n", msg_size, file_size);
43 static void fill_buf(struct msg *m, unsigned int len)
56 if (left < sizeof(*val))
63 m->crc32 = crc32(p, len);
66 static int fill_file(int fd)
68 struct msg *m = malloc(msg_size);
69 unsigned long long fs = (unsigned long long) file_size * 1024 * 1024ULL;
75 fill_buf(m, msg_size);
76 write(fd, m, msg_size);
84 int main(int argc, char *argv[])
89 return usage(argv[0]);
91 index = parse_options(argc, argv);
92 if (index == -1 || index + 1 > argc)
93 return usage(argv[0]);
95 fd = open(argv[index], O_WRONLY | O_CREAT | O_TRUNC, 0644);
97 return error("open output file");