Annotation of Net2/tests/benchmarks/seqrewrite.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Sequential I/O benchmark.
        !             3:  *
        !             4:  * Overwrites existing data in a file.
        !             5:  */
        !             6: #include <sys/types.h>
        !             7: #include <sys/file.h>
        !             8: #include <sys/stat.h>
        !             9: 
        !            10: char   *malloc();
        !            11: 
        !            12: main(argc, argv)
        !            13:        char *argv[];
        !            14: {
        !            15:        register int i, max;
        !            16:        char *buf;
        !            17:        struct stat sb;
        !            18:        int fd;
        !            19: 
        !            20:        if (argc < 2) {
        !            21:                printf("usage: %s file\n", argv[0]);
        !            22:                exit(1);
        !            23:        }
        !            24:        fd = open(argv[1], O_WRONLY, 0644);
        !            25:        if (fd < 0) {
        !            26:                perror(argv[1]);
        !            27:                exit(1);
        !            28:        }
        !            29:        fstat(fd, &sb);
        !            30:        buf = malloc(sb.st_blksize);
        !            31:        max = sb.st_size / sb.st_blksize;
        !            32:        printf("%d writes of %d kilobytes\n", max, sb.st_blksize / 1024);
        !            33:        for (i = 0; i < max; i++)
        !            34:                write(fd, buf, sb.st_blksize);
        !            35: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.