Annotation of 43BSDReno/sys/vaxstand/drtest.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1982, 1986 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  *
        !             6:  *     @(#)drtest.c    7.4 (Berkeley) 4/4/90
        !             7:  */
        !             8: 
        !             9: /*
        !            10:  * Standalone program to test a disk and driver
        !            11:  * by reading the disk a track at a time.
        !            12:  */
        !            13: #include "param.h"
        !            14: #include "disklabel.h"
        !            15: #include "saio.h"
        !            16: 
        !            17: #define SECTSIZ        512
        !            18: 
        !            19: extern int end;
        !            20: char   *malloc();
        !            21: 
        !            22: main()
        !            23: {
        !            24:        register int fd, sector, lastsector, tracksize;
        !            25:        register char *bp;
        !            26:        struct disklabel dl;
        !            27:        int debug;
        !            28: 
        !            29:        printf("Testprogram for stand-alone driver\n\n");
        !            30: again:
        !            31:        debug = getdebug("Enable debugging (0=none, 1=bse, 2=ecc, 3=bse+ecc)? ");
        !            32:        if (debug < 0)
        !            33:                debug = 0;
        !            34:        fd = getfile("Device to read?", 2);
        !            35:        ioctl(fd, SAIODEVDATA, &dl);
        !            36:        printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n",
        !            37:                dl.d_ncylinders, dl.d_ntracks, dl.d_nsectors);
        !            38:        ioctl(fd, SAIODEBUG, (char *)debug);
        !            39:        tracksize = dl.d_nsectors * SECTSIZ;
        !            40:        bp = malloc(tracksize);
        !            41:        printf("Reading in %d byte records\n", tracksize);
        !            42:        printf("Start ...make sure drive is on-line\n");
        !            43:        lseek(fd, 0, L_SET);
        !            44:        lastsector = dl.d_ncylinders * dl.d_secpercyl;
        !            45:        for (sector = 0; sector < lastsector; sector += dl.d_nsectors) {
        !            46:                if (sector && (sector % (dl.d_secpercyl * 10)) == 0)
        !            47:                        printf("cylinder %d\n", sector/dl.d_secpercyl);
        !            48:                read(fd, bp, tracksize);
        !            49:        }
        !            50:        goto again;
        !            51:        /*NOTREACHED*/
        !            52: }
        !            53: 
        !            54: static
        !            55: getdebug(msg)
        !            56:        char *msg;
        !            57: {
        !            58:        char buf[132];
        !            59: 
        !            60:        printf("%s", msg);
        !            61:        gets(buf);
        !            62:        return (atoi(buf));
        !            63: }
        !            64: 
        !            65: /*
        !            66:  * Allocate memory on a page-aligned address.
        !            67:  * Round allocated chunk to a page multiple to
        !            68:  * ease next request.
        !            69:  */
        !            70: static char *
        !            71: malloc(size)
        !            72:        int size;
        !            73: {
        !            74:        static caddr_t last = 0;
        !            75:        char *result;
        !            76: 
        !            77:        if (last == 0)
        !            78:                last = (caddr_t)(((int)&end + 511) & ~0x1ff);
        !            79:        size = (size + 511) & ~0x1ff;
        !            80:        result = (char *)last;
        !            81:        last += size;
        !            82:        return (result);
        !            83: }

unix.superglobalmegacorp.com

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