reorganization to move ufsmount ops to be vnode ops;
[unix-history] / usr / src / sys / vax / stand / drtest.c
CommitLineData
8ae0e4b4 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
8ae0e4b4
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
b28b3a13 6 * @(#)drtest.c 7.5 (Berkeley) %G%
8ae0e4b4 7 */
ab600cd3 8
d11414cd
SL
9/*
10 * Standalone program to test a disk and driver
eafa3969 11 * by reading the disk a track at a time.
d11414cd 12 */
b28b3a13
KB
13#include "sys/param.h"
14#include "sys/disklabel.h"
15#include "stand/saio.h"
ab600cd3 16
b3de1049 17#define SECTSIZ 512
ab600cd3 18
eafa3969
SL
19extern int end;
20char *malloc();
308847fc 21
ab600cd3
SL
22main()
23{
4404f8fb
KB
24 register int fd, sector, lastsector, tracksize;
25 register char *bp;
26 struct disklabel dl;
27 int debug;
ab600cd3 28
eafa3969
SL
29 printf("Testprogram for stand-alone driver\n\n");
30again:
4404f8fb 31 debug = getdebug("Enable debugging (0=none, 1=bse, 2=ecc, 3=bse+ecc)? ");
eafa3969
SL
32 if (debug < 0)
33 debug = 0;
48bce5cd 34 fd = getfile("Device to read?", 2);
4404f8fb 35 ioctl(fd, SAIODEVDATA, &dl);
ab52aa28 36 printf("Device data: #cylinders=%d, #tracks=%d, #sectors=%d\n",
4404f8fb 37 dl.d_ncylinders, dl.d_ntracks, dl.d_nsectors);
15309efe 38 ioctl(fd, SAIODEBUG, (char *)debug);
4404f8fb 39 tracksize = dl.d_nsectors * SECTSIZ;
ac86587e 40 bp = malloc(tracksize);
eafa3969
SL
41 printf("Reading in %d byte records\n", tracksize);
42 printf("Start ...make sure drive is on-line\n");
48bce5cd 43 lseek(fd, 0, L_SET);
4404f8fb
KB
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);
eafa3969 48 read(fd, bp, tracksize);
ab600cd3 49 }
eafa3969 50 goto again;
4404f8fb 51 /*NOTREACHED*/
eafa3969
SL
52}
53
4404f8fb 54static
48bce5cd 55getdebug(msg)
eafa3969
SL
56 char *msg;
57{
48bce5cd 58 char buf[132];
eafa3969
SL
59
60 printf("%s", msg);
61 gets(buf);
48bce5cd 62 return (atoi(buf));
eafa3969
SL
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 */
4404f8fb 70static char *
eafa3969
SL
71malloc(size)
72 int size;
73{
eafa3969 74 static caddr_t last = 0;
4404f8fb 75 char *result;
eafa3969
SL
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);
ab600cd3 83}