Annotation of 43BSDReno/sys/nfs/TEST/unix-tests/special/negseek.c, revision 1.1.1.1

1.1       root        1: /*     @(#)negseek.c   1.3 90/01/08 NFS Rev 2 Testsuite
                      2:  *     1.3 Lachman ONC Test Suite source
                      3:  *
                      4:  * test seek to negative offset
                      5:  */
                      6: #include <stdio.h>
                      7: #ifdef SVR3
                      8: #include <fcntl.h>
                      9: #else
                     10: #include <sys/file.h>
                     11: #endif
                     12: 
                     13: main(argc, argv)
                     14:        int argc;
                     15:        char *argv[];
                     16: {
                     17:        int fd;
                     18:        long i;
                     19:        char buf[8192];
                     20:        extern int errno;
                     21:        extern long lseek();
                     22: 
                     23:        if (argc != 2) {
                     24:                fprintf(stderr, "usage: negseek filename\n");
                     25:                exit(1);
                     26:        }
                     27:        fd = open(argv[1], O_CREAT|O_RDONLY, 0666);
                     28:        if (fd == -1) {
                     29:                perror(argv[1]);
                     30:                exit(1);
                     31:        }
                     32: 
                     33:        for ( i = 0L; i>-10240L ;i -= 1024L ) {
                     34:                if (lseek(fd, i, 0) == -1L) {
                     35:                        perror("lseek");
                     36:                        close(fd);
                     37:                        unlink(argv[1]);
                     38: #ifdef SVR3
                     39:                        exit(0);
                     40: #else
                     41:                        exit(1);
                     42: #endif
                     43:                }
                     44:                if (read(fd, buf, sizeof buf) == -1) {
                     45:                        perror("read");
                     46:                        close(fd);
                     47:                        unlink(argv[1]);
                     48: #ifdef SVR3
                     49:                        exit(1);
                     50: #else
                     51:                        exit(0);
                     52: #endif
                     53:                }
                     54:        }
                     55:        close(fd);
                     56:        unlink(argv[1]);
                     57:        exit(1);
                     58: }

unix.superglobalmegacorp.com

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