00001
00002
00003
00004
00005 #include <random.h>
00006 #include <stdlib.h>
00007 #include <syscall.h>
00008 #include "tests/lib.h"
00009 #include "tests/filesys/base/syn-write.h"
00010
00011 char buf[BUF_SIZE];
00012
00013 int
00014 main (int argc, char *argv[])
00015 {
00016 int child_idx;
00017 int fd;
00018
00019 quiet = true;
00020
00021 CHECK (argc == 2, "argc must be 2, actually %d", argc);
00022 child_idx = atoi (argv[1]);
00023
00024 random_init (0);
00025 random_bytes (buf, sizeof buf);
00026
00027 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
00028 seek (fd, CHUNK_SIZE * child_idx);
00029 CHECK (write (fd, buf + CHUNK_SIZE * child_idx, CHUNK_SIZE) > 0,
00030 "write \"%s\"", file_name);
00031 msg ("close \"%s\"", file_name);
00032 close (fd);
00033
00034 return child_idx;
00035 }